Skip to content
Latchkey

dotnet pack "NU5039: readme file does not exist" in CI

A PackageReadmeFile is declared but the referenced README is not actually included in the package, so dotnet pack fails NU5039. The file path is wrong, or it is not added with Pack="true" to the package root.

What this error means

dotnet pack fails with NU5039 saying the readme file does not exist in the package (or NU5046 that the element is not specified). It is deterministic and tied to the project’s README packing configuration.

dotnet pack output
error NU5039: The readme file 'README.md' does not exist in the package.

Common causes

README declared but not packed

The project sets <PackageReadmeFile>README.md</PackageReadmeFile> but never adds the file to the package via a <None Include="README.md" Pack="true" PackagePath="\" /> item, so it is missing from the .nupkg.

Wrong path or package path for the README

The README lives in a different directory than expected, or its PackagePath does not place it at the package root where NuGet looks.

How to fix it

Include the README in the package

Declare the readme file and pack it to the package root.

.csproj
<PropertyGroup>
  <PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
<ItemGroup>
  <None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup>

Confirm the path resolves at pack time

  1. Verify the README path is relative to the project and exists in the checkout.
  2. Pack and inspect the .nupkg (it is a zip) to confirm the README is at the root.
  3. Fix PackagePath if the file landed in a subfolder instead of the root.

How to prevent it

  • Pack the README with Pack="true" PackagePath="\" whenever PackageReadmeFile is set.
  • Keep PackageReadmeFile and the packed filename identical.
  • Inspect the produced .nupkg contents as a CI step for packaged libraries.

Frequently asked questions

What causes ""NU5039: ... readme file does not exist""?
The project sets <PackageReadmeFile>README.md</PackageReadmeFile> but never adds the file to the package via a <None Include="README.md" Pack="true" PackagePath="\" /> item, so it is missing from the .nupkg.
How do I fix "NU5039: ... readme file does not exist"?
Declare the readme file and pack it to the package root.

Related guides

References

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