|
Ok, I learned how to do this by trying to get BradleyB's 'How to auto-increment assembly version using a custom MSBuild taskworking
and I failed horribly.
http://weblogs.asp.net/bradleyb/archive/2005/12/02/432150.aspx
So I set out to make my own system, using what I learned about Build Tasks from the above sample.
I eventually got it working from that code, and what I learned from the source code
provided in http://blogs.msdn.com/msbuild/archive/2005/11/11/491947.aspx
While hte MSBuild Team Blog teams code worked, it overwrote the major and minor numbers
and didn't do "exactly" what I wanted... plus their source code was overly complicated.
So I wrote this dll. To get it working, do the below steps.
1. Copy the BuildTask.dll into the same folder that your project file is in. (.vbproj for vb)
2. In your project file itself add this line:
<UsingTask TaskName="BuildTasks.IncrementBuildNumber" AssemblyFile="BuildTask.dll" />
between the <Project> tag and first <PropertyGroup> tag.
ie: the first three lines of my test project look like this:
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="BuildTasks.IncrementBuildNumber" AssemblyFile="BuildTask.dll" />
<PropertyGroup>
3. Now, find hte <Target Name="BeforeBuild"></Target> tags and add this between them.
(Make sure they get uncommented if they are - the <!-- and --> tags workt he same as /* */ in c#
<IncrementBuildNumber
AssemblyFileLocation = "$(MSBuildProjectDirectory)\My Project\AssemblyInfo.vb">
</IncrementBuildNumber>
IMPORTANT! - Make sure the path to your assembly file is CORRECT!
$(MSBuildProjectDirectory) means the folder your project file is in, so it will be relative tot hat
in my case, it's in the My Project folder, and since it's a vb app, it's the AssemblyInfo.vb
4. Save the project and load it. The major and minor numbers will will be whatever you assign in the
assembly file, but the build and revision will be overwritten.
The default that I use is MAJOR.MINOR.Number of days since jan 01 2000.Number of times compiled today
When you run/compile the revision number increases. This will occure EVERY TIME the dll is called.
so if your visual studio calls it multiple times, your number could jump 2 or 3 or more at a time.
I don't care, so I never bothered to try to fix this.
Also, the revision number *may* not increament if you have the assembly or project properties window open
Again, I didn't care enough to fix it as it's not that big a deal.
Enjoy.
Dave Gallant
kaydeng@yahoo.ca
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.