Changing processParameters in a TFS Build Definition
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, O开发者_如何学Gobject) = 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.
精彩评论