2
votes

I am working with Visual Studio 2012 .NET 4.5 ASP.NET MVC 4 project that uses TFS for source control and TFS Build for continuous integration (CI).

I want to create functionality that on each check in the build number gets updated prior to the CI build is kicked off.

From research it seems that a custom activity can be created and integrated in TFS 2010 build template.

I have also seen examples of this can be achieved with MSBuild task.

I haven't done work in this area before, so I am wondering which is the better approach or the recommended approach based upon the options open to me? In general when would I use MSBuild tasks as oppose to custom activity? For example, I will be looking to run FxCop and StyleCop against check ins also in the future, so I would like a common approach to this.

1

1 Answers

5
votes

In the case of incrementing the build number, I'd vote for the TFS Build Activity so that the implementation is not tied to your msbuild implementation. This allows you to easily apply the TFS workflow activity to any number of branches without tying it to the branches directly. In addition, it keeps your MSBuild project files clean of the task so that it isn't mistakenly executed on developer machines.

Holistically, I'd say that you need to take a variety of factors into account when deciding between MSBuild and Workflow activities:

1 - Does MSBuild support the functionality out of the box (like Code Analysis/FxCop)?

2 - Does the build step need to run on developer boxes as well as servers (StyleCop/FxCop)?

3 - Does the build step need to interact with the TFS API or source control directly (checking out/in a version file for incrementing)?

4 - Are you going to change build job schedulers later to something free (for example, Jenkins)?

It's the combination of these things that determines the implementation of any given tool integration in my book. I'd implement FxCop, StyleCop and any other tool that should be run on a developer box build via MSBuild. I'd implement build steps such as version incrementing, bin-placing and CI deployment invocation (for example, deployment of a SharePoint webpart as a post-build step) via a Code Activity or some scriptware.