I tried to set a Build Process Parameter by a C# program which uses the TFS API. This BuildDefinition is a BuildDeployTest workflow (slightly modifie LabDefaultTemplate.11.xaml). I am able to change all the Lab Process Settings (Lab Workflow Parameters) by this code:
System.Collections.Generic.IDictionary<string, object> myDictionary = Microsoft.TeamFoundation.Build.Workflow.WorkflowHelpers.DeserializeProcessParameters(buildDefinition.ProcessParameters);
foreach (var Parameter in myDictionary)
{
if (Parameter.Key == "LabWorkflowParameters")
{
// copy the entry
Microsoft.TeamFoundation.Lab.Workflow.Activities.LabWorkflowDetails myCopy = Parameter.Value as Microsoft.TeamFoundation.Lab.Workflow.Activities.LabWorkflowDetails;
foreach(TestAgentListItem testAgent in listOfTestAgents)
{
if(testAgent.Checked == true)
{
myCopy.EnvironmentDetails.LabEnvironmentName = testAgent.TestAgentName;
myCopy.EnvironmentDetails.LabEnvironmentUri = new Uri(testAgent.LabEnvironmentUri);
break;
}
}
myDictionary[Parameter.Key] = myCopy;
}
break;
}
request.ProcessParameters = Microsoft.TeamFoundation.Build.Workflow.WorkflowHelpers.SerializeProcessParameters(myDictionary);
// trigger a new Build
buildServer.QueueBuild(request);
I have another Build process parameter called "TestDirectory" which is shown under Build process parameters -> 3. Misc -> TestDirectory. I tried to change this parameter by
myDictionary["TestDirectory"] = @"TestDir";
but it doesn't change.
In PowerShell I'm able to change this parameter by just typing
[Microsoft.TeamFoundation.Build.Client.IBuildDefinition] $BuildDef = $buildserver.GetBuildDefinition($project,$buildDefinition)
[Microsoft.TeamFoundation.Build.Client.IBuildRequest] $BuildReq = $BuildDef.CreateBuildRequest();
$processParameters = [Microsoft.TeamFoundation.Build.Workflow.WorkflowHelpers]::DeserializeProcessParameters($BuildReq.ProcessParameters)
$processParameters.TestDirectory = "TestDir"
but how can I do this with C#?
Regards