Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Setting up visual studio 2010 to set as auto-increment version of project on each build

How to setting-up visual studio 2010 to set as auto-increment version of project on each build?

Does this feature exist on vs2010?

like image 664
Sadegh Avatar asked Aug 11 '10 11:08

Sadegh


People also ask

Can I automatically increment the file build version when using Visual Studio?

By default, Visual Studio automatically increments the Revision number of the Publish Version each time you publish the application. You can disable this behavior on the Publish page of the Project Designer.

What is the difference between Assembly version and file version?

AssemblyVersion: Specifies the version of the assembly being attributed. AssemblyFileVersion: Instructs a compiler to use a specific version number for the Win32 file version resource.


3 Answers

Change the AssemblyInfo.cs-File:

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

to

[assembly: AssemblyVersion("1.0.*")]
//[assembly: AssemblyFileVersion("1.0.0.0")]
like image 102
Floyd Avatar answered Oct 26 '22 01:10

Floyd


As someone else mentions the 1.0.* is always replaced with 1.0.{date}.{time] so it should be always be increment (you would have thought)

In VS2010 changing the AssemblyVersion to [assembly: AssemblyVersion("1.0.*")] works, be warned that you must close the solution/project, re-open it then re-build it (not build) to refresh/change the build+revision values.

The date/time appears to be obtained from the time the project is opened thus the close/re-open to refresh the revision/build values, I guess this is useful if you are changing various bits within the project in one go and it won't keep changing the AssemblyVersion possibly breaking other bits.

To return the date from the build value:
   DateAdd(DateInterval.Day, build, DateValue("01/01/2000"))
   ' build is the number of days from 1/1/2000
To return the time from the revision value:
   Date.FromOADate(revision / 1800 / 24) 
   ' depending on your timezone you may have DST/BST issue with resulting time 
like image 45
Nick Giles Avatar answered Oct 26 '22 01:10

Nick Giles


The AssemblyInfo.cs - file doesnt exist if you're deveolping native software with c/c++ ... hence this answer is useless for a whole lot of developers out there - one could have a look into http://autobuildversion.codeplex.com ... but this extension doesnt seem to work with VS2010 although the website says otherwise - you may be good to go if you're using older versions of VS, though

like image 29
specializt Avatar answered Oct 26 '22 00:10

specializt