我正在使用TFS2018 api将源映射从我的XAML构建定义复制到新的构建定义。我有以下代码
var def = defs.FirstOrDefault(d => d.Name == xamlDef.Name);
if (def != null)
{
var json = JsonConvert.SerializeObject(mappings);
var tfvs = json.Replace("$(SourceDir)", "");
def.Repository.Properties["tfvcMapping"] = tfvs;
using (var buildClient = new BuildHttpClient(uri, cred))
{
var t = buildClient.UpdateDefinitionAsync(def, teamProject);
var result = t.Result;
}
}
tfvs变量包含以下字符串
{"mappings":[{"serverPath":"$/Utils/TestQueue","mappingType":"map","localPath":"\Utils\TestQueue"},{"serverPath":"$/MyTeamProject/ProjectA","mappingType":"map","localPath":"\MyTeamProject\ProjectA"}]}
我更新源映射后不存在。如果我查看构建定义,它只包含以下字符串
{[tfvcMapping, {"mappings":[{"serverPath":"$/MyTeamProject","mappingType":"map","localPath":"\\"}]}]}
tfvcMapping字符串是否不正确?是否可能无法使用tfs api更新源映射?
答案 0 :(得分:2)
当然你可以使用tfs api更新源映射,api是Update a build definition。
以下是源映射的JSON文件示例,您可以查看它:
"tfvcMapping": "{\"mappings\":[{\"serverPath\":\"$/TestCase/TestCase1\",\"mappingType\":\"map\",\"localPath\":\"\\\\TestCase1\"},{\"serverPath\":\"$/TestCase/TestCaseProject\",\"mappingType\":\"map\",\"localPath\":\"\\\\TestCaseProject\"}]}"