I realize that the build/revision number of the assembly can be auto incremented by changing
[assembly: AssemblyVersion("1.0.0.0")]
to
[assembly: AssemblyVersion("1.0.*")]
in the AssemblyInfo.cs file.
But how do I auto-increment the version number defined in Package.appxmanifest? That is, the version number accessible through:
Windows.ApplicationModel.Package.Current.Id.Version
I'm using Visual Studio 2013.
Edit: Should not be flagged as duplicate, I'm asking about Package version and not Assembly version.
Three line solution, versioning by date
I ran into that issue until I figured out after a lot of researches how to achieve automatic versioning in just three line in the
.csproj
file, here it is:This will output a nuget package named like
{ProjectName}.{Year}.{Month}.{Day}.{Hour}{Minute}{Second}
in a "nuget" folder at the project root guaranteeing that packages built later are versioned as posteriors.Whenever you create package there is option for this functionality here is screenshot for that. All you have to do is check the Automatically increment option.
From VS Navigate Like PROJECT -> STORE -> Create App Packages -> Automatically increment
In VS2017, I created a PowerShell script to pull package id and version number information by looking in a few places and update the .csproj file if needed. The help comment in the file describes how to call it from your .csproj during a build (and build the NuGet package as part of the build):
This scripts enforces the questionable practice of keeping the file/assembly/package version numbers in sync - we have found that practice useful. To accomplish this, revision numbers need special handling. A delta is given for beta, release candidate, and release so version numbers don't decrease when moving from package alpha-->beta, etc.
There is a trick in there because the writing of the project file comes after the build. This means the file and assembly version numbers must be kept one increment behind the package version number (the package gets built after the increment).
This script assumes you have a NuGet server to query. It shouldn't be hard to chop that code out if you don't have one.
In your
.csproj
file, you should add a property namedAppxAutoIncrementPackageRevision
with the value set toTrue
.This will auto-increment the appx package version every time you build it through Visual Studio.