防止VSTS中的构建后事件 [英] Prevent post build event in VSTS

查看:48
本文介绍了防止VSTS中的构建后事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于开发目的,我的团队有一个post build事件,定义为在本地打包和发布nuget软件包.在VSTS中进行构建过程中无需执行此步骤,因为我们在构建过程中为此定义了一个步骤,以将nuget软件包打包并运送到其他服务器(没有符号).现在,此步骤可以在我们运行的任何构建中执行.如何防止仅在构建服务器中发生这种情况?

For development purposes my team has a post build event defined to pack and publish nuget packages locally. This step is not necessary during the build in VSTS because we have a step defined for that during the building to pack and ship the nuget packages to a different server, whithout symbols. Right now this step is executed in any build we run. How to prevent that only in the build server?

推荐答案

为此,您将不得不深入研究MSBuild.您需要添加条件来检查在构建环境中运行时设置的环境变量之一,并且仅在该环境变量为空白时才运行.

You're going to have to dig into MSBuild for this. You need to add a condition to check for one of the environment variables that's set when running in the context of a build, and only run if that environment variable is blank.

例如

  <PropertyGroup>
    <PostBuildEvent Condition=" '$(BUILD_SOURCESDIRECTORY)' == '' ">echo Hello World</PostBuildEvent>
  </PropertyGroup>

BUILD_SOURCESDIRECTORY 是一个环境变量,在构建环境中运行时会被填充,但通常不会在开发人员的桌面上填充.因此, echo Hello World 仅在该值为空时运行.

BUILD_SOURCESDIRECTORY is an environment variable that's populated when running in the context of a build, but isn't populated normally on a developer's desktop. Thus, echo Hello World will only run when that value is blank.

这篇关于防止VSTS中的构建后事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆