Home: dotnet pack doesn't build when "Generate NuGet Pkg on Build"

Created on 30 Oct 2017  路  6Comments  路  Source: NuGet/Home

_From @robertmuehsig on October 29, 2017 21:28_

The documentation tells me that "dotnet pack" should build the project (https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-pack?tabs=netcore2x)

Unfortunatly this behaviour is missing if I enable the "create nuget package on build":

image

When I now execute dotnet pack, it fails:
image

Repo steps:

  • Create a new .NET Core Lib
  • Enable "Generate NuGet Package on build"
  • run "dotnet pack" inside the lib folder

_Copied from original issue: dotnet/sdk#1698_

Pack 1 ByDesign Bug

Most helpful comment

At the very least, the documentation of dotnet pack should be updated to make this behavior clear.

All 6 comments

"Generate NuGet Package on build" is a build property and dotnet build should create the NuGet package by calling pack target in MSBuild.

dotnet pack should just work with/without the "Generate NuGet Package on build" property

Tried the scenario now and it indeed is a bug.

  1. Do not set "Generate NuGet Package on build" property and dotnet pack works fine
  2. Set the property and dotnet pack does not work.

This is likely by design (https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.Build.Tasks.Pack/Pack.targets#L38), probably adding Build as a target dependency causes a circular dependency (after Build, Pack is called, which would call Build).
Anyway, this is definitely a bug and it can probably be fixed.

closing it by design

At the very least, the documentation of dotnet pack should be updated to make this behavior clear.

Was this page helpful?
0 / 5 - 0 ratings