Dot-Net
MSBuild 條件 IsDebug
如何確定項目是否在 MSBuild .targets 文件中以調試(或發布)模式建構,並將此資訊用作另一個屬性的條件?
就像是:
<OutDir Condition="IsDebug">bin\Debug\$(SomeOtherProperty)\</OutDir> <OutDir Condition="!IsDebug">bin\Release\$(SomeOtherProperty)\</OutDir>是否有諸如調試/發布模式之類的東西,或者它們只是不同配置屬性值集的正常名稱?
Debug/Release 或其他只是
Configuration屬性的正常值。因此,只要包含/呼叫您的 .targets 文件的項目遵守約定;您可以按如下方式檢查調試模式:
<OutDir>bin\Release\$(SomeOtherProperty)\</OutDir> <OutDir Condition=" '$(Configuration)' == 'Debug' ">bin\Debug\$(SomeOtherProperty)\</OutDir>或者您可以直接使用該變數:
<OutDir>bin\$(Configuration)\$(SomeOtherProperty)\</OutDir>