简体   繁体   中英

How do I register workflow Extension classes for the TFS Build Workflow?

I'm basically trying to do some inversion of control on a few custom activities developed to work on the TFS build workflow.

I've heard WF supports the service locator pattern through the ActivityContext.GetExtension<T> method , but I'm unable to find a reference as to where/when I should register my custom 'Extension' objects on the host that runs the build process.

I feel it is a similar situation to a IIS hosted workflow service, where one needs to write a custom WCF behavior for injection of extensions into the host , but I fail to see the equivalent of that on the TFS build process' case.

Take a look at

http://msdn.microsoft.com/en-us/library/vstudio/system.activities.codeactivity(v=vs.100).aspx CodeActivity.CacheMetadata(CodeActivityMetadata) method you can override this in your custom activities

The passed parameter gives you access to extensions and other context items http://msdn.microsoft.com/en-us/library/vstudio/system.activities.codeactivitymetadata(v=vs.100).aspx AddDefaultExtensionProvider

I used an 'init' activity to inject custom items into context and reuse this items in other activities, take note that workflow is 'persisted' across builds make sure that your actvities reset the state or take this in account.

2 extensions that should be available and be useful in tfs builds default templates are IBuildDetail and IBuildEnvironment (name might be wrong). You can store data in BuildDetails BuildInformation nodes, and you can get access to tfs api services or their properties from here. BuildEnvironment houses info on your loaded assembly folders etc, might be useful to load something as a file.

Note this applies to tfs 2010, there might be changes since and im quite sure there are better ways how to achieve injection.

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