How to publish nuget prerelease version package

PackageNugetPack

Package Problem Overview


I understand how to publish a nuget package using nuget command line

nuget command line

But I Have searched around I don't find docs about how to publish a nuget prerelease package

enter image description here

Package Solutions


Solution 1 - Package

You only need to specify a version string that uses SemVer format (e.g. 1.0-beta) instead of the usual format (e.g. 1.0) and NuGet will automatically treat it as a prerelease package.

"As of NuGet 1.6, NuGet supports the creation of prerelease packages by specifying a prerelease string in the version number according to the Semantic Versioning (SemVer) specification." See NuGetDocs - Prerelease Versions

Solution 2 - Package

Also, prerelease version don't show up if their version number is lower than the stable version. For example if you have

  • MyNuget v1.0.26
  • MyNuget v1.0.25-beta

Only the stable version will appear in the list.

If you have

  • MyNuget v1.0.26
  • MyNuget v1.1.25-beta

The Prerelease version will be installable.

Solution 3 - Package

Just simply add "-alpha" or "-beta" to version key of your .nuspec file. This will publish your client as prerelease version.

Important Tip: Suppose, you want to test a version 7.6.6.4, then you can add -alpha in 7.6.6.4-alpha. Avoid adding -alpha to your already published version, like: 7.6.6.3-alpha

Sample:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
  <metadata>
    <id>AnalyticalService.Client</id>
    <version>7.6.6.4-alpha</version>
    <title>.net client for Analytical Service</title>
    <authors>Kushal Seth</authors>
    <owners>Kushal Seth</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Alpha version for events integration</description>
    <summary>Alpha version for events integration</summary>
    <dependencies>
      <dependency id="EntityFramework" version="6.1.3" />
      <dependency id="Newtonsoft.Json" version="11.0.2" />
      <dependency id="System.Net.Http" version="4.0.0" />
      <dependency id="System.Net.Http.Formatting.Extension" version="5.2.3" />
      <dependency id="WindowsAzure.Storage" version="9.3.3" />
      <dependency id="Polly" version="7.1.0" />
      <dependency id="Microsoft.Azure.KeyVault.Core" version="1.0.0" />
      <dependency id="NETStandard.Library" version="1.6.1" />
      <dependency id="Microsoft.NETCore.Platforms" version="1.1.0" />
    </dependencies>
  </metadata>
  <files>
    <file src="E:\service\AnalyticalService\src\AnalyticalService.Client\bin\Release\AnalyticalService.Client.dll" target="lib\AnalyticalService.Client.dll" />
    <file src="E:\service\AnalyticalService\src\AnalyticalService.Client\bin\Release\AnalyticalService.Model.dll" target="lib\AnalyticalService.Model.dll" />
  </files>
</package>

To check your published package in Nuget Package Manager, you must select this checkbox: (I am using VS 2019 Professtional 16.8 version, you may have similar option in your VS version)

enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionicnView Question on Stackoverflow
Solution 1 - PackageAlexandre DionView Answer on Stackoverflow
Solution 2 - PackageLukView Answer on Stackoverflow
Solution 3 - PackageKushalSethView Answer on Stackoverflow