Search code examples
nugetazure-devopsazure-pipelinesazure-pipelines-release-pipelineazure-artifacts

Configuring Nuget pack for prerelease on VSTS


Note If there is an easier way to create prerelease packages please let me know!

I am using Visual Studio Team Services and have setup a nuget pack and publish step.

I have a build variable called $(BuildSuffix) that allows me to tag build-specific variables onto the end of the build number format like so

$(Build.DefinitionName)_1.0.$(date:yyyy)$(date:MM)$(date:dd)$(rev:.r)$(BuildSuffix)

The idea then is that I can set $(BuildSuffix) to -beta so that my final build version might be Build_1.0.20170119.2-beta.

According to the nuget documentation here, appending -beta to a build number will create a prerelease package. The build in VSTS comes out with -beta appended but the nuget pack stage never seems to contain it. It always comes out as the exact version number but without the -beta tag.

My nuspec files look like this:

<package >
  <metadata>
    <id>MyCompany.Data</id>
    <version>$version$</version>

My NuGet package step looks like this:

enter image description here


Solution

  • After some research and bashing my head against a brick wall I figured out how. You have to:

    • Configure a local Build Agent
    • Install Nuget CLI
    • On Nuget Packager Task set Path To NuGet.exe to the NuGet CLI
    • Set NuGet Arguments on the same screen to -suffix beta