Stack Overflow Asked by Ivan Caravanio on February 22, 2021
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?
Do not try to import Microsoft.CSharp.targets
- like suggested in another answer.
First of all - it will lead to additional warning like
Warning MSB4011: "Microsoft.CSharp.targets" cannot be imported again. ...
But additionally to that if you try to edit pre-/post- build Visual studio will crash. (Observed in Visual studio 2019, 16.7.7 version)
Better to use $(MSBuildProjectName)
macro instead of $(ProjectName)
- works identically.
Answered by TarmoPikaro on February 22, 2021
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.
Answered by Steven Spyrka on February 22, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP