简体   繁体   中英

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.

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.

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)
  • we added options to automatically deploy our web applications after the build
  • we would like to start using the now official Release Management tool (previously owned by InRelease) to manage our releases. The tool has a feature to trigger releases from TFS Builds, and again requires adding certain steps to the overall build workflow

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.

Is there a way to gracefully extend a xaml workflow in a modular way, preferably without affecting the original 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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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