Skip to content
Latchkey

dotnet pack missing PackageId in CI

When dotnet pack has no explicit PackageId, it falls back to the assembly name - which for multi-project or renamed builds produces the wrong package identity, and an empty/invalid id can fail packing outright. The fix is to set the package identity explicitly in the project.

What this error means

The pack step fails (e.g. NU5017 "Cannot create a package that has no dependencies nor content") or produces a package whose id is unexpectedly the assembly name. It is deterministic.

dotnet
error: NU5017: Cannot create a package that has no dependencies nor content.
# or a .nupkg published under the wrong PackageId

Common causes

PackageId is not set

The project never declares <PackageId>, so pack uses the assembly name, which may not be the intended package identity.

Nothing packable in the project

The project produces no lib output or content, so pack has nothing to put in the package and errors.

How to fix it

Set PackageId and packable metadata

  1. Add <PackageId> (and version/authors) to the project that should produce the package.
  2. Ensure the project actually outputs a library to pack.
  3. Re-run dotnet pack.
csproj
<PropertyGroup>
  <PackageId>Contoso.Widgets</PackageId>
  <Version>1.2.3</Version>
  <Authors>Contoso</Authors>
</PropertyGroup>

How to prevent it

  • Declare package identity explicitly for every packable project.
  • Keep packaging metadata in the csproj or a shared Directory.Build.props.

Frequently asked questions

What causes ""dotnet pack ... PackageId not set""?
The project never declares <PackageId>, so pack uses the assembly name, which may not be the intended package identity.
How do I fix "dotnet pack ... PackageId not set"?
Set PackageId and packable metadata

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card