MSBuild Condition IsDebug

China☆狼群 提交于 2019-12-11 08:58:37

问题


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?


回答1:


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>


来源:https://stackoverflow.com/questions/20800726/msbuild-condition-isdebug

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