I wanted an incrementing Assembly version, but I didn’t want to have to do it manually. Some quick Googling and I found this nice solution:
I’ve been using SubWCRev that’s in the TortoiseSvn installation (I think it’s downloadable seperately too).
First i create a “template”-file for the AssemblyInfo.cs called AssemblyInfo.cs.in
This is created as a copy of the exisiting one.
Then replace the parts you want changed with SubWCRev placeholders like this:
Then create a PreBuildEvent to run SubWCRev with appropriate parameters:
SubWCRev <wcpath> AssemblyInfo.cs.in AssemblyInfo.cs
So, this is translated as follows:
- my AssemblyInfo template file AssemblyInfo.cs.in reads as follows:
// Version Notes: // Updated to 2.0.0 for .net4 switch over
[assembly: AssemblyVersion("2.0.0.$WCREV$")] [assembly: AssemblyFileVersion("2.0.0.$WCREV$")]
- And I tweaked the PreBuildEvent in VisualStudio to use Macros.. it reads as follows:
subwcrev $(ProjectDir) $(ProjectDir)\Properties\AssemblyInfo.cs.in $(ProjectDir)\Properties\AssemblyInfo.cs
Fun stuff indeed.