Question

I am trying to create a new build definition using TFS 2013 API. The process template that I have to refer contains several custom activities and parameters. While creating the Build Definition, some of the Property value needs to be updated dynamically. So I tried to Deserialize the process parameters using below code:

IDictionary<string, object> processParams = WorkflowHelpers.DeserializeProcessParameters(defaultTemplate.Parameters);

This code always throwing below exception:

An unhandled exception of type 'System.Xaml.XamlObjectWriterException' occurred in System.Xaml.dll

Additional information: No matching constructor found on type 'System.Activities.Activity'. You can use the Arguments or FactoryMethod directives to construct this type.

This is really frustrating and I can't get rid of this error yet.

I have also tried to deserialize the process parameters using below code:

using (StringReader stringReader = new StringReader(parameterValues))
{
    object obj = XamlServices.Load(
          ActivityXamlServices.CreateReader(
              new XamlXmlReader((TextReader)stringReader, new XamlXmlReaderSettings { LocalAssembly  = System.Reflection.Assembly.GetExecutingAssembly() }
    )));
}

This works but when I serialize it again using XamlServices.Save(XamlWriter writer, object instance) method, the parameters got changed which is not compatible with build workflow.

So, how can I update the build process parameters here ? Can the WorkflowHelpers class can be used in other ways ? Or is there any other way to update the process parameters so that it gets reflected in the build definition. Any help is highly appreciated.

Was it helpful?

Solution

This is working fine now. Below is new code:

IDictionary<string, object> processParams = WorkflowHelpers.DeserializeProcessParameters(defaultTemplate.ProcessParameters);

Instead of defaultTemplate.Parameters, I need to pass defaultTemplate.ProcessParameters

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top