Pinco Pallino
Pinco Pallino

Reputation: 1016

Conditional OutDir in Solution between MSBuild and VisualStudio

When I build in Visual Studio I'd like the output path to be the usual relative one (bin/Debug, bin/Release). On the other hand, when I use msbuild I would like the output path to be different but using macros like $(SolutionDir)Build\xxx.

How can I define a conditional output path in the Solution file that is conditionally selected based on the fact that it is a MSBuild command line build or a Visual Studio IDE build?

Upvotes: 1

Views: 338

Answers (1)

stijn
stijn

Reputation: 35911

When building inside Visual Studio, the property $(BuildingInsideVisualStudio) is set to true, according to the docs. As such redefining the OutDir property using that property as a condition should do the trick:

<PopertyGroup>
  <OutDir Condition="'$(BuildingInsideVisualStudio)'=='True'"/>$(SolutionDir)Build\xxx</OutDir>
</PopertyGroup>

Upvotes: 3

Related Questions