Automatically Adding SVN Revision Numbers to Assemblies

28 August 2009 (5 years ago)

Source code version control is one thing that no developer should ever live without. If you're working on some code that isn't in a version control system, stop what you're doing now and get yourself one!

There's no excuse - there are plenty of free ones available that are simple to install and use. My personal favourite is Subversion (SVN). The particular flavour I use is VisualSVN which has a simple server configuration system and a convenient Visual Studio plugin. If you're really new to version control, you could do a lot worse than to read the SVN book, too.

Exact revision numbers are a vital part of our quality control process. All bug reports are logged against a specific revision of our code. If a customer calls to report a bug we insist on having the exact revision number - 'Version 2.0.285'. Bug reported for 'Version 2' just aren't good enough and won't get logged in our bug list.

When bugs are fixed, the revision number which includes the fix is also logged. This gives us exact points in time where the bug existed, and where it was ultimately fixed. It also allows us to pinpoint what was done to fix the bug, and who did it.

Incrementing the revision number which gets displayed in your UI every time it changes is not something that should be done manually, though - it's far too easy to forget and is also completely unnecessary when you can quite easily automate it.

In our build process, we use the MSBuild Community Tasks project to automatically retrieve the revision number of the code from Subversion and add it to our assembly information. At runtime, we use reflection to read this information back out of the assembly for display to the user.

Configuring Your Build Process

First off, download and install the MSI package from the MSBuild Community Tasks website. You'll need to do this on every machine that will build your project.

Next, you'll need to modify the MSBuild script for your project - in other words - your Visual Studio project file (.vbproj or .csproj). You can do this either using your favourite text editor, or from within Visual Studio...

  1. Right-click on your project in the 'Solution Explorer' and select 'Unload Project'.
    If this option doesn't appear, you'll need to go to the Tools -> Options menu and tick the 'Always show solution' option under 'Projects and Solutions', first.
  2. Right-click on the newly 'unloaded' project and you will see an option to edit the project file.
  3. When you've finished your editing, you can right-click again and select 'Reload Project'.

If you look through this file, you will find some <Import Project="..."> statements. Add a new line and add a reference to the MSBuild Community Tasks targets:

<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" />

Directly under this, create a property group to contain the Major, Minor and Build numbers for your project. Note that the 'Revision' will get overwritten by the revision number from SVN:


The standard Visual Studio project template has a <Target Name=”BeforeBuild”> section which is commented out by default. Un-comment this and change it to the following:

<Target Name="BeforeBuild">
  <SvnVersion LocalPath="$(MSBuildProjectDirectory)" ToolPath="C:\Program Files\VisualSVN\bin\">
    <Output TaskParameter="Revision" PropertyName="Revision" />
  <Message Text="Version: $(Major).$(Minor).$(Build).$(Revision)" />
  <AssemblyInfo CodeLanguage="VB"
                OutputFile="My Project\AssemblyInfo.vb"
                AssemblyTitle="My Assembly Title"
                AssemblyDescription="My Assembly Description"
                AssemblyCompany="My Company"
                AssemblyProduct="My Product"
                AssemblyCopyright="My Copyright"
                Condition="$(Revision) != 0" />

There are obviously a few things in there that you'll want to change - particularly in the <AssemblyInfo> tag to make it more specific to your product. You may also need to change the 'ToolPath' attribute of the <SvnVersion> tag to the location of your command line SVN tool.

Once you've made these changes, reload your project and try a build. All being well the resulting DLL will include the correct version number.

Displaying the Revision Number in your UI

The final step is to get your revision number showing in your UI for all to see. Luckily, reflection comes to the rescue and allows you to retrieve your entire version number in this (rather long) single line of code:

VersionNo = System.Reflection.Assembly.GetExecutingAssembly().GetName.Version.ToString

Then, proudly display this value in a label on your Windows form, or squirt it out in your HTML for all to see!



29 April 2015
(3 months ago)

[url=]?????? ???????????? ???[/url] - ????? ???????????, ????? ??????????? ???.


6 May 2015
(2 months ago)

[url=!glavnaya/c1rez]????????[/url] - ??????????? ??????????, ?????????? ??? ??????.


17 May 2015
(2 months ago)

[url=]?????? ?? ?????? ???????????? ?????????[/url] - ???????? ? ?????????? ??????, ????????? ???????????? ??????.


20 May 2015
(2 months ago)

[url=]??????? ??? ????????? ?????[/url] - ?????????? ????? ??? ????????????? ?????, ?????? ??? ????? ?????.


21 May 2015
(2 months ago)

[url=]??????????[/url] - ??????? ????, ??????????.


25 May 2015
(2 months ago)

[url=]ESET NOD32 Smart Security [/url] - Kaspersky Internet Security ??? ???? ?????????, ?????? ????????? Dr.Web ??? Windows.


29 May 2015
(2 months ago)

???????? ???????


9 June 2015
(1 month ago)

cool website [url=][/url]


19 June 2015
(1 month ago)

???? ???? 2015 - ????????????? ??????????? ???? ????????? ? ?????!!! 1000 ??????????, 3 ?????, 7 ???? ??????!!! ??????, ????, ?????? ? ????! ????????!!! ????? ??????!!! ??????????? ????????? ? ????? ? 20 ?? 26 ???? ?. ???????????, ?. ???????.
??????? ?????? ?? ????? -

???????? ?? ????????? ?????????, ???, hip hop, ????????????, ????? ? ????, ????, ????, ???, ?????, ?????? ? ?????, metallica, ???? 2015, ???? ????-??????, ???, ???????? ?????????, ??? ???????, ?????? ? ????, ????????????, ?????, ????? ? ????, ??????? ? ????, ?????????? ?????, ????? ??????, ????? ? ?????, ??????????? ????? ?? ?????????, ??????????? ??????, ?????????????? ??????, ?????


29 June 2015
(1 month ago)

citizens from war torn Lebanon. embassies in countries that have become dangerous., [url=][b]Hobbs Smart Dresses[/b][/url], [url=][b]?????? [/b][/url], [url=][b]??????? HEXA????????? ????????? BTR-2[/b][/url], No ramen joint will tell you so, because, well, the is always right. But I let you in on a little secret: You drive many ramen kitchens crazy when you eat this slowly. The noodles expand and get soggy, the broth a sad shadow of what it was when the fat was melting in the hot, salty broth when the bowl was plopped in front of you., [url=][b]Monsoon Knitted Dresses[/b][/url], [url=][b]?????????(???)[/b][/url], Outstanding opportunity for investors and residents alike, [url=][b]Monsoon Nalani Dip Dye Fringe Dress Blue[/b][/url], [url=][b]Balenciaga ?? ?????·???[?????? 34480300BW ?????·???]???? ????? ????/??????[/b][/url], [url=][b]??????(????)[/b][/url], Thank you for the expeditious answer. Its good to know youre out there and awake in the wee hours when I finally have time to ask questions about my Jenn Air., [url=][b]Monsoon Kay Tunic Dress Navy[/b][/url], [url=][b]????&????? [/b][/url], Updated Wednesday at 4:44 AM, [url=][b]??????(???)[/b][/url], and respecting informed consent have multiplied. They are also more prominent in education, financial services, consumer protection,, [url=][b]????? ??? ????????? 84cm(BB4016-S84)???????????????????????[/b][/url], [url=][b]Hobbs Smart Dresses[/b][/url], People are typically comfortable with a RH (relative humidity) in the 30 to 50 percent range and can tolerate 20 to 60 percent. The ideal RH depends whether you live in the North or South, and it changes with the seasons. High RH is often a summertime problem in the South and excessively low or high RH may create wintertime problems in the North., [url=][b]????????·??? [/b][/url], [url=][b]Monsoon Belle Prom Dresses Black[/b][/url], But in the end, South Ogden police don believe they could have legally taken further action. Investigators claim Savannah Favilla didn want to be contacted so they had no one to follow up with and police say the evidence didn warrant contacting the Utah Division of Child and Family Services to remove the toddler from her family., it takes you 15 minutes to cut up a single bell pepper, dinner going to take you 3 hours, she says. when you good at knife skills, cooking is just way more fun. Many cooking schools offer classes in basic knife skills, but excellent online videos also are available., The appeal ended eight months ago after raising $6,831 toward a goal of $50,000., How do I know if my child is growing and developing on schedule?


29 June 2015
(1 month ago)

????????????up.For??????????????????????????????????????????????????????????????????????????????????????????????????????????? ???2010????Custis??????????burglarizing????????, [url=][b]Gucci Straw Women's Sale[/b][/url], [url=][b]Gucci Sandals Men's Sale[/b][/url], [url=][b]Gucci Men Felt Fedora Hats[/b][/url], SHERBROOKE?QC?3?26???????????theCHUS????·?·????????????·??(CRCELB)????????????????Advanced????????????(ACSI)??2012 / CNW Telbec /????????incommissioning???????????????????? ????????????????TR 24 24megaelectron???ACSI?????????????????????(MeV?)??????????????????99????(99?????Tc)?firstproduction?????????, [url=][b]??????? 7[/b][/url], [url=][b]???[/b][/url], [url=][b]NEW BALANCE(???????)/ ????? GIRLs LADYs kl574kbg ??50%OFF??????[/b][/url],  ?????????????????????????????????????????????????????, [url=][b]301 T???[/b][/url], [url=][b]??????[/b][/url], [url=][b]????? ??? ??·?????? CLX IL4????????????[/b][/url],   ???????????????????????????????????Echols??????????????????????????????????????, [url=][b]991[/b][/url], [url=][b]Nike Dunk High AC OBSIDIAN/OBSIDIAN-WOLF GREY ??? ??? ?? ?? ??????? ???????/??????? ?????? 476627-401[/b][/url], ???????????????????????????70????????????????????????????????????????????????, [url=][b]???[/b][/url], [url=][b]??? ?? ????? ??????? ????? ?????? ??????[/b][/url], ???150???????????????????gorging??????????????????????????????????????????????????????????????????????????????????????????? ????????????????????????????, [url=][b]Cheap Christian Louboutin Alentejohn veau velours Espadrilles Epi d'or For Sale[/b][/url], [url=][b]Christian Louboutin GAMMA TALON SUEDE 120 mm Platforms Shoes Epi d'or[/b][/url], ??????????????????????????????????????????????????????????????????????????????????????????????????????????? ??????,  ???????????????????8???850?????????????????????????????????,  ????????????????????????????????????????????????????, ???????????????????????????????·??????????,  ?????????????????????????????????????????????????????????????????


29 June 2015
(1 month ago)

] ???3???????????, [url=][b]???(Dogs)[/b][/url], ??7?????????????????????????????Humpybong????????????????????????????????, [url=][b]??????? MA-102 ???? ????? ????? ?? Marelli ???? donna ??????[/b][/url], ????????????????????????????????????????????????????????????????????????????????????????????????????????????, [url=][b]MERRELL[/b][/url], [url=][b]??????[/b][/url], [url=][b]????? ????????????????? / FILSON Thane Wool Shirt[/b][/url], , [url=][b]??????(Back pack)[/b][/url], [url=][b]SHOT SHELL BAG ???? ??? ??? tan[/b][/url], ????????????????????????????????????, [url=][b]Arnold Palmer[/b][/url], [url=][b]No.40933 ???????????? ??? ??? ??? ?? ???[/b][/url], ??????????????????????, [url=][b]FILSON(?????) MACKINAW CRUISER-EXTRA-LONG(????? ????? ????????)-FOREST GREEN[/b][/url], [url=][b]????????? ?????? & ???????? 13.0cm~16.0cm Arnold Palmer[/b][/url], , [url=][b]?????[/b][/url], [url=][b]?????[/b][/url], [url=][b]??????????????????2014 ????????[/b][/url], [url=][b]??????(Accessories)[/b][/url], , ] ????????????????????????????????????????????????????????10????????????????, ??????·????????????ADN????????????????????????,


10 July 2015
(3 weeks ago)

[url=]?????? ??????? ???? ??????[/url] - ??????????? ??????, ?????? ??????? ?????????.


12 July 2015
(2 weeks ago)

??????? ????????? [url=]?????? ? ????????[/url]


15 July 2015
(2 weeks ago)

[url=]canadian pharmacy[/url] - pharmacy canada, prozac no prescription.


16 July 2015
(2 weeks ago)

[url=]????????? +?? ?????[/url] - oenobiol capillaire revitalisant ??????, ???????????? ?????????.


20 July 2015
(1 week ago)

[url=]accutane no prescription[/url] - buspar no prescription, fluoxetine prescription.


25 July 2015
(1 week ago)

????????????????????????????????????????·?????????????·???????????????, [url=][b]??????? ?????(FENDI)?????? ????? ???? ??? F0062812[/b][/url], JC:????(?????????????????????)????????????????????????, [url=][b]????[/b][/url], [url=][b]Bag :???[/b][/url], [url=][b]TORY BURCH :?????? ?????????? ????[/b][/url], ?????·?????2007??????????????????????????????????????????????????, , , , ???2009?????????????50??????????????????????????????????????????????????????, [url=][b]??[/b][/url], [url=][b]PRADA:??? ?? ???????? ????(MIMOSA)[/b][/url], ????????????????????????????????????????, , , ???????????????????????????????????? ?????????????????????????????????????, [url=][b]JIMMY CHOO ?????? 2014????? ?????????????(NIKITA) ????[/b][/url], ,  ????????????????????????????????????????????, [url=][b]???????[/b][/url], [url=][b]??[/b][/url], ???????????????????????????????????????????????????????????????????????, ???????????????????????????????????????, ???????????????????????????????????????????????????,  2000????????·??????????????????????????


26 July 2015
(6 days ago)

[url=]Adoair  [/url] - Cefutil, Bimatoprost.


28 July 2015
(4 days ago)

discount michael kors bags , two tone michael kors watch , Factory Outlet Michael Kors Handbags , michael kors trench coat , Michael Kors , michael kor , michael kors canada , michael kors watches dillards , michael kors dresses , michael kors michael kors , michael kors fulton flats , two tone michael kors watch , michael kors black tote , michael kors watch repair , michael kors handbags sale , cheap michael kors bags , michael kors handbags sale online , michael kors neiman marcus , michael kors watches cheap , michael kors watches for men , michael kors menswear , michael kors france , michael kors outlet canada , michael kors coat , michael kors totes , michael kors suit , michael kors handbags clearance , michael kors cheap watches , michael kors continental wallet , michael kors mens shoes , michael kors glitz watch , michael kors turquoise watch , michael kors watch gold , michael kors handbags on sale macys , Cheap Michael Kors Handbags , michael kors down coat , men michael kors watches , michael kors home , shop michael kors , hamilton tote michael kors , black and gold michael kors watch , michael kors york , turquoise michael kors watch , rose gold watch michael kors , michael kors macy s , michael kors flip flops , michael kors tonne hobo , Michael Kors Handbag Outlet , michael kors outlet canada , michael kors uk usa ,


31 July 2015
(1 day ago)

Anthony Gray, an attorney representing the Brown family told the Post Dispatch that he believes Wilson was acting in his own best interest, [url=][b]????? ????????[/b][/url],  Trooping the Colour originated from traditional preparations for battle, when flags were carried or trooped down the rank for soldiers to see, [url=à-dos-c-17_18.html][b]Lancaster Sacs à dos[/b][/url], Share PhotoIn this Thursday, Dec, [url=à-dos-c-17_18.html][b]Lancaster Sacs à dos[/b][/url], [url=][b]Radley Shoulder Bags[/b][/url], [url=][b]Gerard Darel Le Rebelle Sac Asphalte[/b][/url], first ladies, including Nancy Reagan, Hillary Clinton and Laura Bush (left, with the designer in 2004), [url=][b]????????[/b][/url], [url=][b]Radley De Beauvoir Large Tote Bag Midnight[/b][/url], When your child reaches the preteen and teenage years, she may start to have some questions about her breasts, [url=][b]Radley Large Purse[/b][/url], [url=][b]Black Forest Boy /????? ????? ?????[/b][/url],  It would be stupid to accumulate so much capital that the rate of return falls below the growth rate, [url=][b]Radley Dala Dog Women Canvas Shopper Blue Cotton Canvas Leather Sale[/b][/url], [url=][b]Steiff ????????? ????? ????? EAN000249[/b][/url], The online portal contains all the necessary instructions for filling up of the form along with checklists, an official release said, [url=][b]????[/b][/url], [url=][b]????? 2015? ???[/b][/url], [url=][b]????? ?????Teddy bear????? ????????/ Steiff????? 2003?[/b][/url], [url=][b]Radley Work Bags[/b][/url], Knightley plays Joan Clarke, a fellow mathematician and cryptanalyst recruited by Turing for the covert operation, pop singer and former Disney television child star Miley Cyrus brushed off any suggestions that dropping her squeaky clean image was a sign she was going off the rails,  Thats the main reason I do what I , This is just celebrity worship, Hyatt said in disgust, as she surveyed the banner waving courthouse contingent


31 July 2015
(1 day ago)

????????????????????????????????????????? ????????????????????????????????????????????????????????????, [url=][b]Jordan Flight 23 Herrenschuh-Schwarz/Grauer Nebel/Fotoblau/Weiß[/b][/ur], Solyanik?????????????????????????????????????, [url=][b]?????????(???)[/b][/url], ???????????????1994?????????????????????????????????????????????????????????????????????????????????????????, [url=][b]adidas Frauen Running Schuhe[/b][/url], [url=][b]???3??[/b][/url], [url=][b]Hobbs Michelle Dress Pretty[/b][/url],  ???????????????????????????????????????????????, [url=][b]Monsoon Jersey Dresses[/b][/url], [url=][b]adidas Adria Low Schuh - Dark Marine / Ftwr White/ Dark Marine [/b][/ur],  ??????????????????????????????????????????????????????, [url=][b]Nike Damen Laufschuhe[/b][/url], [url=][b]????? ?? ????? ??????(19T?) WTDXJHN19 ?WS ?WBB ?nykb ?UB?[/b][/url], ??????????????????????????????(??????)?????????????????????????????????????????, [url=][b]Hobbs Huxley Spot Dress Navy Ivory Occasion Dresses[/b][/url], [url=][b]Hobbs Eva Dress Hot Sale Smart Dresses[/b][/url],  ????????????????????????????????????????, [url=][b]Hobbs Occasion Dresses[/b][/url], [url=][b]Ted Baker Floral Dresses[/b][/url], [url=][b]?????? ????????????? ?????? ??????? SBT-PM2500[/b][/url], [url=][b]adidas Männer Fußball Schuhe[/b][/url], ?????????2009???2005??5300000?740???????????????????????????????2010????????????????????????????????? ?????????????, ?????????????????????????????????????????????47???????????,  ?????GOP????????·??????????????????????????????????????????????????????????????, 3??R?C?????(3?)?24 kHz??????????


1 August 2015
(12 hours ago)

[url=]?????????[/url] - ???????? ??????, ??????????.


1 August 2015
(11 hours ago)

[url=]???????? ???????????[/url] - ???????????? ????????????, ???????????????? ?????????? ??????????.

Leave a Comment