更改 TFS 构建定义中的流程参数
通常,它使用类似于
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论