是否可以重命名当前正在进行或已经完成的发行版?
我尝试使用下面的语法重命名发行版,但是它总是抛出一个错误:“不允许在发行版中添加或删除阶段”
var releases = releaseClient.GetReleasesAsync(definitionId: 100, searchtext: "OldReleaseName").Result;
var release = release.FirstOrDefault();
release.Name = "new release name";
releaseClient.UpdateReleaseAsync(release, "projectName", release.Id).Wait();
答案 0 :(得分:1)
是的,可以重命名发行版。
在这种特殊情况下看到的错误是由于以下事实:GetReleases API返回了发行版的浅表副本,而UpdateRelease API则接受了完整的对象。
要解决上面代码中的错误,我们还需要调用GetRelease API来加载完整的发布对象,并在Update调用中使用它。
var releases = releaseClient.GetReleasesAsync(definitionId: 100, searchtext: "OldReleaseName").Result;
var release = release.FirstOrDefault();
// Add a null check here? This is to load the complete release object.
release = releaseClient.GetReleaseAsync("projectName", release.Id).Result;
release.Name = "new release name";
releaseClient.UpdateReleaseAsync(release, "projectName", release.Id).Wait();