Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How to increase automatic by "1"

[assembly: AssemblyVersion("1.0.0.1")]
[assembly: AssemblyFileVersion("1.0.0.1")]
Version
Upgrade Code

In each build...

Thanks
Posted

With the "Built in" stuff, you can't, as using 1.0.* or 1.0.0.* will replace the revision and build numbers with a coded date/timestamp, which is usually also a good way.

For more info, see the Assembly Linker[^] Documentation in the /v tag.

As for automatically incrementing numbers, use the AssemblyInfo Task:

AssemblyInfo Task
[^]

This can be configured to automatically increment the build number.

There are 2 Gotchas:

Each of the 4 numbers in the Version string is limited to 65535. This is a Windows Limitation and unlikely to get fixed.
Why are build numbers limited to 65535? [^]
Using with with Subversion requires a small change:

Using MSBuild to generate assembly version info at build time (including SubVersion fix)[^]
Retrieving the Version number is then quite easy:
C#
Version v = Assembly.GetExecutingAssembly().GetName().Version;
string About = string.Format(CultureInfo.InvariantCulture, @"YourApp Version {0}.{1}.{2} (r{3})", v.Major, v.Minor, v.Build, v.Revision);
 
Share this answer
 
v2
Comments
Rieth L 20-Nov-13 6:56am    
But in Add/Remove programs it still the older version and the new version doesn't appear ... It appear if i open Add/Remove programs, then close, then open again.

Update: some times it work
Nicholas Marty 20-Nov-13 7:13am    
Those settings aren't carried over to your installer. I don't know if there is something that changes the version of your installer. And as far as I know (at least for the Visual Studio Setup Project) this is not possible. You could take a look at the WIX Toolset but I haven't really used it yet.. You might want to clarify your question to include the setup version too.
Remove the line
C#
[assembly: AssemblyFileVersion("1.0.0.1")]

and modify the AssemblyVersion to
C#
[assembly: AssemblyVersion("1.0.*")]

This will create a Version in the following format:

1.0.{date}.{time} (this does not mean it is a human readable date, however each build will have a higher version)

And the AssemblyFileVersion will then be the same as the AssemblyVersion

other than that I believe Visual Studio doesn't offer anything like that itself so you might have to look for 3rd party products to increment the version by another value other than date/time related.

You might want to take a look at http://autobuildversion.codeplex.com/[^]
 
Share this answer
 
v2
Comments
Rieth L 20-Nov-13 6:56am    
But in Add/Remove programs it still the older version and the new version doesn't appear ... It appear if i open Add/Remove programs, then close, then open again.

Update: some times it work
You can also use Addin for Visual Studio to set different auto increment styles per major, minor, build or revision number.

Refer here
http://autobuildversion.codeplex.com/[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900