visual-studio - 如何在 Visual Studio.csproj 中的 <Target Name ="AfterBuild"> 中编写内联代码

标签 visual-studio build msbuild gruntjs

如果 $(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 中检查构建是否处于 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/

相关文章:

c# - 使用 EnumWindows 在 WinForm 的面板内启动 .exe 应用程序 - 而不是记事本

vb.net - 使用 VB.NET 从 API 读取

java - 基本的maven问题: Does maven transitively install dependencies?

.net - 如何从 NuGet 包提供全局 AnalyzerConfig 文件?

c# - 从 MSBuild 中的程序集获取 AssemblyInformationalVersion 的正确方法是什么?

msbuild - 如何在安装了 Visual Studio 2017 的情况下获取 Signtool.exe 的路径

visual-studio - 我在哪里可以找到 tsconfig.json 默认值?

c++ - dlldata.c不是在win32下生成的?

parameters - TeamCity 条件参数值

java - 在 Eclipse 下实现 Java/Android 中的构建配置