Search code examples
azure-devopsnugetnuget-cli

How to publish a nuget prerelease package to a feed?


I am manually pushing nuget packages to Azure Devops feed by running nuget.exe push command. When I build my project, the AssemblyName.1.0.0.nupkg file is created and I am pushing it as:

nuget.exe push -Source URL -ApiKey key ..\AssemblyName.1.0.0.nupkg

This works fine and the package is published successfully (as package version 1.0.0). However, I am not able to publish a prerelease package like 1.0.0-beta.

What I tried?

  1. I added the following in AssemblyInfo.cs:
[assembly: AssemblyInformationalVersion("1.0.0-beta")]

When I build the project, it still generates AssemblyName.1.0.0.nupkg but not AssemblyName.1.0.0-beta.nupkg.

  1. I added the following in csproj:
<PropertyGroup>
    <PackageVersion>1.0.0-beta</PackageVersion>
</PropertyGroup>

Still it generates only AssemblyName.1.0.0.nupkg.

What I want?

Could you let me know how to publish a prerelease nuget package like 1.0.0-beta please?

EDIT:

The project's target framework is .NET Framework 4.5.


Solution

  • Use <Version> element in the project file and it should work!