如何反序列化和序列化构建过程中的参数的TFS [英] How to Deserialize and Serialize Build Process Parameters in TFS

查看:282
本文介绍了如何反序列化和序列化构建过程中的参数的TFS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个使用TFS 2013 API的新版本的定义。我不得不提到的流程模板中包含多个自定义活动和参数。在创建生成定义,一些属性值的需要进行动态更新。于是,我试着用下面code反序列化工艺参数为:

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);

这code总是引发异常如下:

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.

我也试图反序列化使用下面code中的工艺参数为:

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() }
    )));
}

这个工作,但是当我把它序列化再次使用 XamlServices.Save(作家的XamlWriter,对象实例)方法,参数得到了改变这是不符合构建工作流程兼容。

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.

那么,怎样才能在这里我更新生成过程参数?可以在 WorkflowHelpers 类可以用其他方式使用吗?或者有没有其他的办法,这样它就总是体现在构建定义更新的工艺参数。任何帮助高度AP preciated。

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.

推荐答案

这是现在工作的罚款。
下面是新的code:

This is working fine now. Below is new code:

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

而不是 defaultTemplate.Parameters ,我需要通过 defaultTemplate.ProcessParameters

这篇关于如何反序列化和序列化构建过程中的参数的TFS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆