$(ProjectName) and $(TargetName) MSBuild macros not working

可紊 提交于 2019-12-13 02:14:07

问题


I am using Visual Stduio 2015 Community Edition. I have loaded a C# project and want to configure it to use shadow building, so that source files are not messed up with any binaries or intermediate build files. Tried to set the [output]/[intermediate output] directory paths of the C# project using the VS UI - the only UI-editable output path is the "bin" one and it doesn't accept MSBuild macros. Then I've unloaded the project and manually edited it. Also set the IntermediateOutputPath which is not available in the VS UI when using C# project, but when using C++ one all such kind of directories are editable. Currently, the OutputPath is set to: <OutputPath>$(SolutionDir)..\build_$(SolutionName)_$(Configuration)_$(Platform)\$(ProjectName)</OutputPath>

$(ProjectName) is empty for some reason. Tried $(TargetName) (it is not correct to use it but just for the test) but it is empty, too. Any suggestions?


回答1:


The problem is that some of the MSBuild properties like ProjectName are set after the following line in your .csproj file.

<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

After this line you can access all variables.



来源:https://stackoverflow.com/questions/33126926/projectname-and-targetname-msbuild-macros-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!