How do I auto increment the package version number?

In your .csproj file, you should add a property named AppxAutoIncrementPackageRevision with the value set to True.

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>

    ...

    <AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>

    ...
  </PropertyGroup>

This will auto-increment the appx package version every time you build it through Visual Studio.


Three liner, versioning by date

I ran into that issue until I figured out after a lot of research how to achieve automatic versioning in just three line in the .csproj file. Here it is:

<Target Name="NugetPackAutoVersioning" AfterTargets="Build">
    <Exec Command="dotnet pack -p:PackageVersion=$([System.DateTime]::Now.ToString(&quot;yyyy.MM.dd.HHmm&quot;)) --no-build --configuration $(Configuration) --output &quot;$(SolutionDir)nuget&quot;" />
</Target>

This will output a NuGet package named like {ProjectName}.{Year}.{Month}.{Day}.{Hour}{Minute} in a "nuget" folder at the project root, guaranteeing that packages built later are versioned as posteriors.