Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSBuild Condition IsDebug

How can I determine if a project is build in Debug (or Release) mode within an MSBuild .targets file and use this information as a condition for another property?

Something like:

<OutDir Condition="IsDebug">bin\Debug\$(SomeOtherProperty)\</OutDir>
<OutDir Condition="!IsDebug">bin\Release\$(SomeOtherProperty)\</OutDir>

Is there such thing as Debug/Release mode, or are they just conventional names for different sets of configuration properties' values?

like image 255
Thanasis Ioannidis Avatar asked Dec 27 '13 12:12

Thanasis Ioannidis


1 Answers

Debug/Release or whatever are just conventional values for the Configuration property.

So, as long the project that includes/calls your .targets file adheres to the convention; you can check for debug mode as follows:

<OutDir>bin\Release\$(SomeOtherProperty)\</OutDir>
<OutDir Condition=" '$(Configuration)' == 'Debug' ">bin\Debug\$(SomeOtherProperty)\</OutDir>

or you could just use that variable directly:

<OutDir>bin\$(Configuration)\$(SomeOtherProperty)\</OutDir>
like image 173
Thomas Gerstendörfer Avatar answered Oct 21 '22 07:10

Thomas Gerstendörfer