【问题标题】:Updating source mappings更新源映射
【发布时间】:2018-09-25 03:53:04
【问题描述】:

我正在使用 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 更新源映射?

【问题讨论】:

    标签: tfs


    【解决方案1】:

    当然你可以使用 tfs api 更新源映射,api 是Update a build definition

    以下是源映射的JSON文件示例,您可以查看:

    "tfvcMapping": "{\"mappings\":[{\"serverPath\":\"$/TestCase/TestCase1\",\"mappingType\":\"map\",\"localPath\":\"\\\\TestCase1\"},{\"serverPath\":\"$/TestCase/TestCaseProject\",\"mappingType\":\"map\",\"localPath\":\"\\\\TestCaseProject\"}]}"
    

    【讨论】:

    • 如何在 TFS 2017 U3 上执行此操作? (没有 4.1 rest api)现在我正在尝试使用 JObject 来解析值字段 json,更新它然后复制整个属性。那么我想我需要删除该属性并添加新属性吗?
    猜你喜欢
    • 1970-01-01
    • 2021-10-28
    • 1970-01-01
    • 1970-01-01
    • 2020-06-13
    • 1970-01-01
    • 2019-07-07
    • 2014-06-07
    • 1970-01-01
    相关资源
    最近更新 更多