我有一个在签到时构建项目的触发器。但我想在某些情况下添加一些检查并取消构建。
我创建了一个带有我要检查的条件的任务。我可以使用带有如下代码的 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));