在MSDN上,TFS Build API在文档上未得到充分记录。如何通过API删除现有的构建定义?
(我想在更新设置之前删除一个......)
答案 0 :(得分:2)
到目前为止,这似乎对我有用(通过反复试验找到)。
try
{
var def = buildServer.GetBuildDefinition(
teamProject, buildDefinition.Name, QueryOptions.Definitions);
buildServer.DeleteBuilds(def.QueryBuilds());
def.Delete();
}
catch (Microsoft.TeamFoundation.Build.Client.BuildDefinitionNotFoundException)
{
// didn't exist, so do nothing..
}
答案 1 :(得分:1)
您可以在此处指定特定版本(仅限放置文件夹)
var bs = tpc.GetService<IBuildServer>();
var bSpec = bs.CreateBuildDetailSpec(projectName, buildDefinitionName);
bSpec.QueryOptions = QueryOptions.None;
bSpec.InformationTypes = null;
bSpec.QueryDeletedOption = QueryDeletedOption.ExcludeDeleted;
var targetBuild = bs.QueryBuilds(bSpec).Builds.Where(b => b.Uri == build.Uri).ToArray();
bs.DeleteBuilds(targetBuild, DeleteOptions.DropLocation);