Create simple CodeActivity for TFS Build 2010

Sometimes that you need to customize TFS Build 2010, you need to create a custom CodeActivity. A CodeActivity is written in C# and you can do what you can’t in TFS Build itself, there. The simplest way to create a custom CodeActivity, deploy and use it, is as follow:

1. Create a .Net 4.0 based Class Library project. CodeActivity exists in .Net framework 4.0 only.

2. Add a Code Activity to it by right click on the project, select Add New Item and navigating to Workflow tab.

3. Add a reference to “C:Program Files (x86)Microsoft Visual Studio 10.0Common7IDEReferenceAssembliesv2.0Microsoft.TeamFoundation.Build.Client.dll”.

4. Add “[BuildActivity(HostEnvironmentOption.All)]” as your CodeActivity’s class attribute.

5. Add desired arguments and codes.

6. Build the project.

7. Copy generated dll to “C:Program Files (x86)Microsoft Visual Studio 10.0Common7IDEPrivateAssemblies”. If you don’t do this, you will not be able to use Visual Studio to add your CodeActivity to any build process template.

8. Add generated dll to a specific location in TFS Source Control.

9. Open up your desired build process template.

10. Add generated dll to the toolbox by right clicking on empty space in General tab, select “Choose Items…”, click Browse, navigate to “C:Program Files (x86)Microsoft Visual Studio 10.0Common7IDEPrivateAssemblies” again and select your generated dll. After this you will see your CodeActivity there.

11. Drag Code Activity on the desired placed in process template.

12. Add any arguments that you want to be accessed via Build Definition to the template process and pass them to your CodeActivity’s arguments. To add any arguments to a template process, open Arguments tab in the bottom-left corner of the screen and add them there.

13. Check-in template process. If you don’t so, you will not see your added arguments in Process tab of build definitions.

14. Open Build Definition that uses this build process template. You will see any arguments that you have previously added to build process. You can set any value in them.

Note: Above addresses are based on a x64 installation.
Note: For more info refer to Jim’s guide and Ewald’s guide.

پاسخ دهید

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *