Miscellaneous Ramblings on Hacking

May 23, 2012

SVN version into your Assembly.cs file

Filed under: Uncategorized — Zack Bethem @ 8:10 pm

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:
[assembly: AssemblyVersion(“1.2.3.$WCREV$”)]
Then create a PreBuildEvent to run SubWCRev with appropriate parameters:
SubWCRev <wcpath> AssemblyInfo.cs.in AssemblyInfo.cs
Done.

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.

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: