I'm trying to use the .net Core tools RC4 dotnet pack command to create a nuget package with a suffix.
I can create "MyProject.1.2.3.nupkg" successfully but I want "MyProject.1.2.3-beta.nupkg".
According to the documentation here the --version-suffix "Updates the star in -* package version suffix with a specified string."
I've managed to find where dotnet pack is getting it's version from - dotnet pack uses msbuild under the covers which uses the <version/>
element in the csproj file. For example <version>1.2.3</version>
creates a file called "MyProject.1.2.3.nupkg".
If I set the <version/>
in the csproj to something like 1.2.3 and specify --version-suffix beta then it doesn't append the -beta but it does build.
If I set version to be <version>1.2.3-*</version>
then dotnet restore breaks saying '1.2.3-*' is not a valid version string.
I think I'm close; what have I got wrong?
The dotnet pack command builds the project and creates NuGet packages. The result of this command is a NuGet package (that is, a . nupkg file).
dotnet pack : The output is a package that is meant to be reused by other projects. dotnet publish : The output is mean to be deployed / "shipped" - it is not a single "package file" but a directory with all the project's output.
You don't have to run dotnet restore because it's run implicitly by all commands that require a restore to occur, such as dotnet new , dotnet build , dotnet run , dotnet test , dotnet publish , and dotnet pack . To disable implicit restore, use the --no-restore option.
According the documentation, the Version
property override the version on packing, instead, use the VersionPrefix
.
<PropertyGroup> <VersionPrefix>1.0.0</VersionPrefix> </PropertyGroup>
And use the command to pack solution:
dotnet pack --version-suffix beta
Optionally you can set VersionPrefix
and VersionSuffix
in .csproj
file.
<PropertyGroup> <VersionPrefix>1.0.0</VersionPrefix> <VersionSuffix>alpha</VersionSuffix> </PropertyGroup>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With