简体   繁体   English

扩展.Net Workflow XAML文件的替代方法

[英]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: 为了实例化,我们已经对标准文件进行了一些更改,我们希望对它们进行一些更改:

  • we customized the template to check for .cab installer projects in the solution and compiling them using a local Visual Studio 2008 installation in the build server (msbuild does not support .vdproj files) 我们自定义了模板,以检查解决方案中的.cab安装程序项目,并使用生成服务器中的本地Visual Studio 2008安装进行编译(msbuild不支持.vdproj文件)
  • we added options to automatically deploy our web applications after the build 我们添加了在构建后自动部署Web应用程序的选项
  • we would like to start using the now official Release Management tool (previously owned by InRelease) to manage our releases. 我们想开始使用现在正式的版本管理工具 (以前由InRelease拥有)来管理我们的版本。 The tool has a feature to trigger releases from TFS Builds, and again requires adding certain steps to the overall build workflow 该工具具有触发TFS Builds发行的功能,并且再次要求在整个构建工作流程中添加某些步骤

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM