0

我有一个在签到时构建项目的触发器。但我想在某些情况下添加一些检查并取消构建。

我创建了一个带有我要检查的条件的任务。我可以使用带有如下代码的 TFSBuild.proj 文件运行此任务,其中CheckIfBuildNeeded我的任务的名称是:

<Target Name="BeforeCompile">
  <CheckIfBuildNeeded>
    .....
  </CheckIfBuildNeeded>
</Target>

所以,答案是,我怎样才能取消/停止从 Task 的Execute()方法或任何其他地方构建?如何获取 Build 对象?

我知道我可以使用此代码从 TFS 获得构建。但是要对构建做一些事情,我自然需要知道它的 ID。

TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer("http://foo.bar/tfs");
IBuildServer buildServer = (IBuildServer)tfs.GetService(typeof(IBuildServer));
4

1 回答 1

1

Take a look at the Error Task.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Target Name="ValidateCommandLine">
        <Error
            Text=" The 0 property must be set on the command line."
            Condition="'$(0)' == ''" />
        <Error
            Text="The FREEBUILD property must be set on the command line."
            Condition="'$(FREEBUILD)' == ''" />
    </Target>
    ...
</Project>
于 2013-12-12T19:27:39.823 回答