MSBuild条件IsDebug

Tha*_*dis 1 .net msbuild msbuild-task visual-studio-2010 targets

如何确定是否在MSBuild .targets文件中以调试(或发布)模式构建项目,并将此信息用作另一个属性的条件?

就像是:

<OutDir Condition="IsDebug">bin\Debug\$(SomeOtherProperty)\</OutDir>
<OutDir Condition="!IsDebug">bin\Release\$(SomeOtherProperty)\</OutDir>
Run Code Online (Sandbox Code Playgroud)

是否有诸如“调试/发布”模式之类的东西,或者它们仅仅是不同配置属性值集的常规名称

Tho*_*fer 6

调试/发布或仅是Configuration属性的常规值。

因此,只要包含/调用您的.targets文件的项目符合约定,就可以;您可以按以下方式检查调试模式:

<OutDir>bin\Release\$(SomeOtherProperty)\</OutDir>
<OutDir Condition=" '$(Configuration)' == 'Debug' ">bin\Debug\$(SomeOtherProperty)\</OutDir>
Run Code Online (Sandbox Code Playgroud)

或者您可以直接使用该变量:

<OutDir>bin\$(Configuration)\$(SomeOtherProperty)\</OutDir>
Run Code Online (Sandbox Code Playgroud)