[英]Alternatives to extending .Net Workflow XAML files
I think this is a general question for workflow files but I will scope it to the TFS Build workflow system. 我认为这是工作流程文件的普遍问题,但我将其范围限定在TFS Build工作流程系统中。
When you create a Team Project from a template in TFS, a folder is automatically created containing the default build templates that can be used later on to define builds for the projects inside. 当您从TFS中的模板创建Team Project时,会自动创建一个文件夹,其中包含默认的构建模板,这些模板以后可用于定义内部项目的构建。
There are a few changes we already made to the standard files and some that we would like to, for instace: 为了实例化,我们已经对标准文件进行了一些更改,我们希望对它们进行一些更改:
Lastly, we would like to update our workflow to use the most up to date features in the latest project templates. 最后,我们想更新工作流程,以使用最新项目模板中的最新功能。
This is all very hard to maintain, because everything is contained in a massive .xaml file with everything crammed in. 这一切都很难维护,因为所有内容都包含在庞大的.xaml文件中,而且所有内容都塞满了。
Is there a way to gracefully extend a xaml workflow in a modular way, preferably without affecting the original xaml? 有没有办法以模块化的方式优雅地扩展xaml工作流程,最好不影响原始的xaml? I'm thinking about something like the decorator pattern here, in that I would be able to add behavior between certain steps of the workflow without tying the original implementation to it.
我正在考虑类似装饰器模式的事情,因为我可以在工作流的某些步骤之间添加行为,而无需将原始实现与它绑定。
If the whole build system was split into multiple workflows divided in stages (like compiling, testing, etc) it would be a bit more manageable, but in our case it is getting very hard to keep the thing updated. 如果将整个构建系统划分为多个工作流,并分阶段进行 (例如编译,测试等),那么它会更易于管理,但就我们而言,要保持更新非常困难。
For instance, what if another project in the company wanted some of our additions, but not all? 例如,如果公司中的另一个项目想要我们的一些增添但不是全部增添怎么办? What if they have changed the template too and added other things, that we later wanted to use?
如果他们也更改了模板并添加了其他我们以后要使用的东西怎么办? Ideally, it would be possible to 'attach' new actions to an existing workflow from an external file of sorts.
理想情况下,有可能将新操作从各种外部文件“附加”到现有工作流程。
I've never seen this mentioned in any tutorial for updating/creating workflow files so I'm assuming there is no way to do this, but I would love to be proven wrong. 我从未在任何教程中提到过用于更新/创建工作流文件的内容,因此我假设没有办法做到这一点,但我希望证明这一点是错误的。
You could create a new workflow, and call the built-in workflow. 您可以创建一个新的工作流程,然后调用内置的工作流程。 If you have hard time, you can create an activity that load the built-in xaml
如果您有困难,可以创建一个加载内置xaml的活动
private Activity createActivityFromXml(string xml)
{
if (!string.IsNullOrEmpty(xml))
{
return ActivityXamlServices.Load(new StringReader(xml));
}
return null;
}
Once you have this activity (which is the default built-in workflow), you can create a new workflow and include this activity. 进行此活动(这是默认的内置工作流程)后,您可以创建一个新的工作流程并包括此活动。 This will allow you to add other activities before or after the default workflow.
这将允许您在默认工作流程之前或之后添加其他活动。
EDIT: creating the activity by code (as shown above) should be your latest option, I think you could just put the existing xaml in Visual Studio and use it directly, ie with the visual editor you could include it in a new wf. 编辑:通过代码创建活动(如上所示)应该是您的最新选择,我认为您可以将现有的xaml放在Visual Studio中并直接使用它,即,通过可视化编辑器可以将其包含在新的wf中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.