更改 TFS 构建定义中的流程参数

发布于 2024-11-17 22:20:27 字数 1373 浏览 3 评论 0原文

通常,它使用类似于

    Dim dicParamValues As IDictionary(Of String, Object) = WorkflowHelpers.DeserializeProcessParameters(pStrProcParam)
    'dicParamValues(<ProcessID>) = <Value>
    '...
    WorkflowHelpers.SerializeProcessParameters(dicParamValues)

但 BuildDefinition 中的正常 processParameters 没有我需要更改的参数来完成。我在 BuildDefinition.Process.Parameters 中找到了它们,但它不是一个可以使用 WorkFlowHelpers 解析为字典的文件,而是反序列化为 Activity。

由于有一种方法可以将“活动”转换为参数的字典列表,因此我尝试了这段

    Dim actParamValues As Activity = WorkflowHelpers.DeserializeWorkflow(pStrProcParam)
    Dim dicParamValues As IDictionary(Of String, Object) = WorkflowHelpers.GetProcessParameters(actParamValues)

我认为可行的代码,但它返回 processParameters 而不是对象,我不确定如何更改它们或解决问题。

我已经在 msdn TFS 论坛上询问过,但尚未收到回复。任何帮助或提示将不胜感激。

编辑: 看来我是个白痴。当我无法设置不存在的值时,问题就开始了......事实证明,我可以将它们添加到字典列表中,然后设置新列表,没有任何问题(到目前为止)。

正确的代码是

        Dim dicParamValues As IDictionary(Of String, Object) = WorkflowHelpers.DeserializeProcessParameters(pStrProcParamShort)
    dicParamValues.Add("PublishToDevelopment", pBolDev)
    dicParamValues.Add("PublishToMainOrDemo", pBolDemo)
    dicParamValues.Add("PublishToLiveOrReleaseLocation", pBolRelease)
    Return WorkflowHelpers.SerializeProcessParameters(dicParamValues)

我会尽力关注这一点,以防其他人遇到类似的问题。

Typically its done using something similar to

    Dim dicParamValues As IDictionary(Of String, Object) = WorkflowHelpers.DeserializeProcessParameters(pStrProcParam)
    'dicParamValues(<ProcessID>) = <Value>
    '...
    WorkflowHelpers.SerializeProcessParameters(dicParamValues)

But the normal processParameters in BuildDefinition did not have the parameters I needed to change. I found them in BuildDefinition.Process.Parameters, but its not a file that can be parsed into a dictionary using WorkFlowHelpers, it is instead deserialized into an Activity.

Since there is a way to turn Activities into a dictionary list of parameters, I tried this code

    Dim actParamValues As Activity = WorkflowHelpers.DeserializeWorkflow(pStrProcParam)
    Dim dicParamValues As IDictionary(Of String, Object) = WorkflowHelpers.GetProcessParameters(actParamValues)

which I would think would work, but it returns processParameters instead of objects and I am not sure how to get them changed over or work around the problem.

I've already asked on the msdn TFS forums, but haven't received a response there yet. Any help or hints would be appreciated.

EDIT:
It appears as if I'm an idiot. The problem started when I couldn't set values that weren't there... well it turns out I can ADD them to the dictionary list, then set the new list without any problem (so far).

The correct code is

        Dim dicParamValues As IDictionary(Of String, Object) = WorkflowHelpers.DeserializeProcessParameters(pStrProcParamShort)
    dicParamValues.Add("PublishToDevelopment", pBolDev)
    dicParamValues.Add("PublishToMainOrDemo", pBolDemo)
    dicParamValues.Add("PublishToLiveOrReleaseLocation", pBolRelease)
    Return WorkflowHelpers.SerializeProcessParameters(dicParamValues)

I'll try to keep an eye on this in case anyone else has a similar problem.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文