如果 $(ConfigurationName) 在 <AfterBuild>
中不起作用
<Target Name="AfterBuild">
if $(ConfigurationName) == Release (
<Exec Command="grunt karma:unit --no-color > grunt-karma-output.txt" IgnoreExitCode="true" />
<Exec Command="type grunt-karma-output.txt" CustomErrorRegularExpression=".*mPhantomJS.*FAILED" IgnoreExitCode="false" />
)
</Target Name="AfterBuild">
如果 $(ConfigurationName) 在
<PostBuildEvent>
中有效<PostBuildEvent>
if $(ConfigurationName) == Release (
<Exec Command="grunt karma:unit --no-color > grunt-karma-output.txt" IgnoreExitCode="true" />
<Exec Command="type grunt-karma-output.txt" CustomErrorRegularExpression=".*mPhantomJS.*FAILED" IgnoreExitCode="false" />
)
</PostBuildEvent>
任何人都可以建议如何在
AfterBuild
中检查构建是否处于 Release模式?
最佳答案
在目标上使用条件:
<Target Name="AfterBuild" Condition="$(Configuration)==Release">
<Exec Command="echo AfterBuild"/>
</Target>
顺便说一句,这对于 PostBuildEvent 也以相同的方式工作(并且您发布的代码肯定不起作用)。
<PropertyGroup Condition="$(Configuration)==Release">
<PostBuildEvent>echo PostBuild</PostBuildEvent>
</PropertyGroup>
关于visual-studio - 如何在 Visual Studio.csproj 中的 <Target Name ="AfterBuild"> 中编写内联代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19090702/