Dotnet Pack Din't Build

Monday, July 20, 2026

My team is a assigned a small project to build a NuGet package. And since I'm familiar with DevOps practice, I took the initiative to build the CI/CD pipeline.


Our client has a standard pipeline that needs to be incorporated. The standard pipeline stage for NuGet only runs dotnet pack and it's failing. The error message indicated that it can't find the dll.


Checking various online documentation and discussion, dotnet pack is supposed to do implicit build, so it should have produced the dll.


After couples of back and forth with the engineer over at the client side, I happened to notice the following note at dotnet pack page:

In some cases, the implicit build cannot be performed. This can occur when GeneratePackageOnBuild is set, to avoid a cyclic dependency between build and pack targets. The build can also fail if there is a locked file or other issue.

And indeed, our project has GeneratePackageOnBuild since we wanted to make sure that our project indeed produce the package when run locally.


Removing the GeneratePackageOnBuild property then allows dotnet pack to implicitly build the project and produced the dll again.