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.
error: NU5017: Cannot create a package that has no dependencies nor content.
# or a .nupkg published under the wrong PackageIdCommon 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
- Add
<PackageId>(and version/authors) to the project that should produce the package. - Ensure the project actually outputs a library to pack.
- Re-run
dotnet pack.
<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.