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.
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.
<PropertyGroup>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup>Confirm the path resolves at pack time
- Verify the README path is relative to the project and exists in the checkout.
- Pack and inspect the
.nupkg(it is a zip) to confirm the README is at the root. - Fix
PackagePathif the file landed in a subfolder instead of the root.
How to prevent it
- Pack the README with
Pack="true" PackagePath="\"wheneverPackageReadmeFileis set. - Keep
PackageReadmeFileand the packed filename identical. - Inspect the produced
.nupkgcontents as a CI step for packaged libraries.