I have setup multiple build definitions using TB 2010 for multiple features within our product. I'm wondering how can I create "master build" using existing definitions.
I'll be more specific:
In MSBuild I could use an <MSBuild>
target to invoke another MSBuild project. This way I could chain build definitions to get final master build script.
How can I do it in TB 2010?
Note: I'd like to use WF4... not MSBuild!
You certainly can write a Workflow custom activity to queue a build for a build definition. This activity should be a code activity and accepts the name of the build definition you'd like to queue.
To write the code that interacts with your TFS server to queue a build, you can use the APIs of the Microsoft.TeamFoundation.Build.Client assembly. Also, Jim Lamb blogged about creating custom activities for build here.
In details, your code should do the following steps:
I'm actually surprised that there is no example for the 2010 release when I tried to search for "tfs programmatically queue|create a build". I'll probably blog about this.
One thing to be careful about this though, that the build queued from your custom activity will be queued by the Build Service Account, so you need to make sure this account is granted the correct permissions to queue build. By default when it is added to the TFS Build Services Accounts group, I don't think it has.
UPDATE:
Ewald Hofman just wrote a series about TFS Build, one of which discusses about doing impersonation from a custom activity. It's perfect for your need:
http://www.ewaldhofman.nl/post/2010/05/28/Customize-Team-Build-2010-e28093-Part-9-Impersonate-activities-(run-under-other-credentials).aspx
I also found out that Taylor Lafrine blogged about programmatically creating a build in his post back in 2009:
http://blogs.msdn.com/b/taylaf/archive/2009/12/04/introducing-tfs-impersonation.aspx
Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With