Azure Pipeline Nuget Package Versioning Scheme, How to Get "1.0.$(Rev:r)" : <p>I'm setting up an Azure Pipelines build that needs to package a C# .NET class library into a NuGet package.</p>

<p>In <a href="https://docs.microsoft.com/en-us/azure/devops/pipelines/artifacts/nuget?view=azure-devops&amp;tabs=yaml#package-versioning" rel="noreferrer">this documentation</a>, it lists a couple different ways to automatically generate SemVer strings. In particular, I want to implement this one:</p>

<blockquote>
  <p><code>$(Major).$(Minor).$(rev:.r)</code>, where <code>Major</code> and <code>Minor</code> are two variables
  defined in the build pipeline. This format will automatically
  increment the build number and the package version with a new patch
  number. It will keep the major and minor versions constant, until you
  change them manually in the build pipeline.</p>
</blockquote>

<p>But that's all they say about it, no example is provided. A link to learn more takes you to <a href="https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/package/nuget?view=azure-devops" rel="noreferrer">this documentation</a>, where it says this:</p>

<blockquote>
  <p>For <code>byBuildNumber</code>, the version will be set to the build number, ensure
  that your build number is a proper SemVer e.g. <code>1.0.$(Rev:r)</code>. If you
  select byBuildNumber, the task will extract a dotted version, <code>1.2.3.4</code>
  and use only that, dropping any label. To use the build number as is,
  you should use byEnvVar as described above, and set the environment
  variable to <code>BUILD_BUILDNUMBER</code>.</p>
</blockquote>

<p>Again, no example is provided. It looks like I want to use <code>versioningScheme: byBuildNumber</code>, but I'm not quite sure how to set the build number, I think it pulls it from the <code>BUILD_BUILDNUMBER</code> environment variable, but I can't find a way to set environment variables, only script variables. Furthermore, am I suppose to just set that to <code>1.0.$(Rev:r)</code>, or to <code>$(Major).$(Minor).$(rev:.r)</code>? I'm afraid that would just interpret it literally.</p>

<p>Googling for the literal string "versioningScheme: byBuildNumber" returns a single result... Does anyone have a working <code>azure-pipelines.yml</code> with this versioning scheme?</p>
