Automatically use subversion revision as version in .Net projects
26. April 2011After a long search I discovered the „Build Version Increment Add-In“ (for Visual Studio 2005, 2008 and 2010) which enables to auto increment the build version of the AssemblyFileVersion attribute – currently C#, VB.NET and C++.NET projects are supported. The Add-In is quickly installed and comes with various incrementor styles. But I missed an incrementor style which provides the subversion revision if the project is under version control. Luckily the Add-In exposes an interface for creating own incrementor styles: After some hacking I got it working using Sharpsvn to get the revision.
The final plug-in for the Add-In is available for download here: SubversionIncrementor v1.0
Some users report to have issues using the Build Version Incrementor (version 2.4) with Visual Studio 2010 SP1 or Visual Studio Ultimate 2010: I also had that issue but building the whole project solved it. If you don’t want to rebuild the whole project the version is also available for download here.
Update 15.09.2011:
I’ve updated the Plugin to work with Build Version Incrementor (version 2.5) and fixed a bug which prevented the SubversionIncrementor to get the revision when not conncted to the subversion server.
The new plug-in for the Add-In is available for download here: SubversionIncrementor v1.1
Update 30.10.2012:
I’ve updated the Plugin to work with the latest SharpSVN version that supports the 1.7 working copy format and the latest Build Version Incrementor (version 2.5.11219.2200).
The new plug-in for the Add-In is available for download here: SubversionIncrementor v1.2
Update 11.11.2012:
Now you can get the sources of the plugin from: https://github.com/crea-doo/Subversion.Incrementor
Update 18.07.2013:
I’ve updated the Plugin to work with the latest SharpSVN version that supports the 1.8 working copy format and the latest Build Version Incrementor (version 2.5.11219.2200).
The new plug-in for the Add-In is available for download here: SubversionIncrementor v1.3
Sounds nice... However, I have installed your plug-in and nothing
Karol | 21. September 2011 | 13:24Sounds nice… However, I have installed your plug-in and nothing happened. I am also missing any explanation how to configure it – should it work straight away? Do I need any additional plugins? Can I make it work with TortoiseSVN or do I need SharpSVN?
You have to install the Build Version Increment Add-In too
admin | 22. September 2011 | 17:13You have to install the Build Version Increment Add-In too because the SubversionIncrementor is only a plugin of the Build Version Increment Add-In.
Also the whole configuration has to be done via the Build Version Increment Add-In. For details see http://autobuildversion.codeplex.com/
Hi, The link from the "Update" section (the new plugin) contains
adrian | 7. Oktober 2011 | 13:17Hi,
The link from the „Update“ section (the new plugin) contains a version of SharpLib newer than the referenced one, so I had some erros with this (VS2010). However, I replaced it in Addins with the one available on their website.
Many thanks for your work.
SharpSVN, sorry :)
adrian | 7. Oktober 2011 | 13:18SharpSVN, sorry 🙂
I've updated the link to Build Version Incrementor (version 2.5)
admin | 7. Oktober 2011 | 18:38I’ve updated the link to Build Version Incrementor (version 2.5) above and added an updated version of the plugin (still version 1.1) which shouldn’t have the mentioned issue…
Hi, I have just installed your plugin. Unfortunately, after enabling the
Uwe | 13. Oktober 2011 | 22:32Hi,
I have just installed your plugin. Unfortunately, after enabling the revision no. in BVI I got the following error message twice on a rebuild:
>>>
Error 1 Error while retrieving revision: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
at System.Collections.Generic.List`1.get_Item(Int32 index)
at Incrementor.SubversionIncrementor.GetRevision(String path)
at Incrementor.SubversionIncrementor.Increment(IncrementContext context, VersionComponent versionComponent)
>>>
This error is reproducible.
Any thoughts what went wrong.
Many thanks for your help.
I tried using your incrementor with the most recent version
Peter | 13. September 2012 | 10:09I tried using your incrementor with the most recent version of build version increment and VS 2010 pro. Somehow it always returns ‚0‘ for revision number. Any ideas?
I do not see any obvious problems in the logging:
[Debug] Updating attribute AssemblyVersion of project xxxxxxxx.yyyyyyyyy
[Debug] Found „D:\Workspaces\xxx\Components\xxxxxxxx.yyyyyyyyy\My Project\AssemblyInfo.vb“
[Info] Revision retrieved from the working copy: 0
Is the subversion repo you are using in 1.7 format? If
admin | 13. September 2012 | 20:55Is the subversion repo you are using in 1.7 format?
If so Subversion.Incrementor can’t read the version information because it is using SharpSvn version 1.6.xxxx.
To use a WC format like 1.7 first the dependency has to be upgraded.
I’ve tried that but had no time to test it – you can find the sources under http://github.com/crea-doo/Subversion.Incrementor
Im not sure how to use it correctly: If I configure
Enrico Horn | 19. September 2012 | 15:21Im not sure how to use it correctly:
If I configure the Build Version Increment Add-In to directly change AssemblyInfo.cs and this AssemblyInfo.cs is in Subversion in creates a local change which in turn is a new subversion revision.
How is the best way to solve this?
Can you please please PLEASE, update it to work with
Oriol | 30. Oktober 2012 | 16:08Can you please please PLEASE, update it to work with the 1.7 format? I downloaded the source but i sadly didn’t get it to work by myself and I really need this…
Cheers
Hi! I've uploaded a new version that supports the 1.7 working
admin | 30. Oktober 2012 | 22:35Hi!
I’ve uploaded a new version that supports the 1.7 working copy format.
See the post for details…
You Sir, are a hero. Cheers.
Oriol | 31. Oktober 2012 | 08:46You Sir, are a hero.
Cheers.