I set version numbers in my assemblies to:
[assembly: AssemblyVersion("1.0.*")]
After first rebuild I got this version number:
1.0.3835.35633
<major version>.<minor 开发者_开发技巧version>.<build number>.<revision>
In MSDN article about assembly version attribute there is really short description:
The default build number increments daily.
Is there any way for me to reset default build number to e.g. 1 and have Visual Studio automatically increments.
Edit:
I found information that build number is number of days since 2000-01-01. I checked it on two different computers and it really is. In above build number, 3835 is number of days between 2000-01-01 and 2010-07-02. So, it looks that default build number cannot be changed and it's identical for all VS2008 installations. I don't like this numbering schema, so I'll try two add-in's - one that Alek suggested in his answer and another one I found: Build Version Increment Add-In Visual StudioI don't think you can make it work like this natively in Visual Studio, but you can try the Versioning Controlled Build add-in and see if it does what you need.
If you are using MSBuild, I encourage you to install msbuildtasks (https://github.com/loresoft/msbuildtasks) which can be nuget installed.
Once you do this it will make a build.proj in the root of your solution and you can create your own version file that it will use to manage version information.
It supports using MS's build and revision properties and also supports overriding the start date
I made a Major and Minor version file and put them in the initial
<VersionFile Condition=" '$(VersionFile)' == '' ">$(MsBuildProjectDirectory)\VersionMajor.txt</VersionFile>
<VersionSuffixFile Condition=" '$(VersionSuffixFile)' == '' ">$(MsBuildProjectDirectory)\VersionMinor.txt</VersionSuffixFile>
In those files I simply have the number 2 and the number 1 (respectively)
I then created another file that contains the full version number (where the result effectively goes) as version.txt. It contained 2.1.0.0
Then, in my Task for the actual build I added
<Version VersionFile=".\Version.txt" BuildType="Automatic" RevisionType="BuildIncrement" StartDate="2015-01-01">
<Output TaskParameter="Build" PropertyName="Build" />
<Output TaskParameter="Revision" PropertyName="Revision" />
</Version>
That gave me a Build and Revision parameter to use elsewhere.
Where the assembly info is written I use them all like so:
AssemblyVersion="$(Version).$(VersionSuffix).$(Build).$(Revision)"
AssemblyFileVersion="$(Version).$(VersionSuffix).$(Build).$(Revision)"
And boom! I have nice versions. I manage my major and minor myself (I'm going to switch those to use the git branch which is also 2.1 and which buildtasks can pull) and the build is incremented by the number of days since StartDate (which I set to when I made the branch) and the revision autoincrements with each build and resets to 0 when the build resets to 0.
You can see more if you look at the buildtasks source code on github: https://github.com/loresoft/msbuildtasks/blob/master/Source/MSBuild.Community.Tasks/Version.cs
精彩评论