Tips, tricks, and guides for developing on modern Windows platforms
Here’s a quick tip to get your app’s version number directly from the package. You can then display the current version number in your UI or put it in debug logs, and you can use the actual package version as a ‘single source of truth’ for your app’s version.
You get the package version from
version property has four values: major version, minor version, revision, and buid. You’ll recognise these from when you upload your packages to the store where it has a four-part version number like 126.96.36.199.
Here’s the code for turning those numbers into a string:
public string AppVersion
var package = Windows.ApplicationModel.Package.Current;
var packageId = package.Id;
var version = packageId.Version;
return "Version " + version.Major + "." + version.Minor + "." + version.Revision;
In this example I am only using three of the available four version components, as the build number doesn’t matter the the end user. Visual Studio can automatically increment your build number, but you’ll still need to determine when to raise the major and minor version numbers according to your own style or needs.
Now you only have to worry about updating your app’s version when you submit a new package to the store, and your app’s UI will always display the correct version.
If you include error logging or give users a link to email for support, you can include the build number to help with troubleshooting.