dan
dan

Reputation: 893

Build Event MS Properties Blank in .Net 8 WPF Application Upgraded From .Net Framework

$(OutDir) and $(ProjectDir) MSBuild properties are empty with a .net framework 4.8 project I upgraded to .net 8 with upgrade assistant. This article specifies these: https://learn.microsoft.com/en-us/visualstudio/ide/how-to-specify-build-events-csharp?view=vs-2022#macros

This is my result

1>Configuration: Debug
1>DevEnvDir: C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\
1>OutDir:
1>ProjectDir:
1>VisualStudioVersion: 17.0
1>AssemblySearchPaths: {CandidateAssemblyFiles};{HintPathFromItem};{TargetFrameworkDirectory};{RawFileName}
1>AssemblyName: AcquisitionCoreTestApp
1>BaseIntermediateOutputPath: obj\
1>CscToolPath:

This is result from new .net 8 wpf application project I created, these show properly. How come? I compared the csproj file but didn't see anything obvious...

1>WpfApp1 -> C:\temp\net8prototypes\WpfApp1\bin\Debug\net8.0-windows\WpfApp1.dll
1>Configuration: Debug
1>DevEnvDir: C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\
1>OutDir: bin\Debug\net8.0-windows\
1>ProjectDir: C:\temp\net8prototypes\WpfApp1\
1>VisualStudioVersion: 17.0
1>AssemblySearchPaths: {CandidateAssemblyFiles};{HintPathFromItem};{TargetFrameworkDirectory};{RawFileName}
1>AssemblyName: WpfApp1
1>BaseIntermediateOutputPath: obj\
1>CscToolPath:

Upvotes: 0

Views: 188

Answers (1)

Cody Liang
Cody Liang

Reputation: 1118

It may be related to the way MSBuild properties are initialized. At the beginning of the build process, the item's include attribute is evaluated. So, if you depend on files created during the build process, you must declare these as dynamic. Dynamic items are defined inside the target or using the CreateItem task. Additionally, (ProjectDir) is only available after importing Microsoft.Common.Targets, while (MSBuildProjectDir) is a reserved property of MSBuild itself. Therefore, using the $(MSBuildXXX) properties will ensure that they are always available to you without having to import all the necessary references.

Upvotes: 0

Related Questions