views:

21

answers:

2

Is it possible to include tasks in a build, in VS 2010, to e.g. update an assembly version number, without having to run an external application through a build event? That is, I would prefer if I could write an extension for VS 2010 that would listen for a 'build starting' event, and run a task, e.g. a macro or plugin that updates the assembly version property.

+2  A: 

You could write a custom MSBuild task.

Darin Dimitrov
I am building one right now, plus getting to know the CodeDOM for a 'proper' way to edit the AssemblyInfo.cs file. Good stuff. I assume manual editing of the csproj file is required to add the task?
ProfK
Yes one way is to edit the csproj, but you could also edit the more global `$(MSBuildToolsPath)\Microsoft.CSharp.targets` and it will apply to all projects and all solutions.
Darin Dimitrov
+1  A: 

Or, you could use an existing add-in. Here is one available on CodePlex which could potentially suite your needs by either A) achieving exactly what you want or B) allowing you to delve into how you could achieve what you want.

On a side note, if incrementing the version number/s is all you want, the VS should still support using a wildcard character to get this done via the AssemblyVersion in the assembly information file. For example:

[assembly: AssemblyVersion("1.*")]
Mr. Disappointment
@Mr. Disappointment, I'm actually trying to avoid the auto-increment, but thanks for the link, it looks good.
ProfK