4

如果 $(ConfigurationName) 不起作用<AfterBuild>

<Target Name="AfterBuild">
if $(ConfigurationName) == Release (
    <Exec Command="grunt karma:unit --no-color &gt; 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 &gt; grunt-karma-output.txt" IgnoreExitCode="true" />
    <Exec Command="type grunt-karma-output.txt" CustomErrorRegularExpression=".*mPhantomJS.*FAILED" IgnoreExitCode="false" />
)
</PostBuildEvent>

谁能建议如何检查构建是否处于发布模式AfterBuild

4

1 回答 1

8

在目标上使用条件:

<Target Name="AfterBuild" Condition="$(Configuration)==Release">
  <Exec Command="echo AfterBuild"/>
</Target>

顺便说一句,这也适用于 PostBuildEvent (并且您发布的代码肯定不起作用

<PropertyGroup Condition="$(Configuration)==Release">
  <PostBuildEvent>echo PostBuild</PostBuildEvent>
</PropertyGroup>
于 2013-09-30T09:41:13.143 回答