Edit

NuGet Error NU5041

Cannot open the readme file 'readme.md'

Issue

NuGet is unable to find and open the readme file in the package.

Solution

  • Make sure that the file that is marked as the package readme exists at the source and it is readable, and the target matches the path expected by the readme property.
  • Ensure that the file is referenced in the nuspec or in the project file.
    • When creating a package from an MSBuild project file, make sure to reference the readme file in the project, as follows:

      <Project Sdk="Microsoft.NET.Sdk">
        <PropertyGroup>
            ...
            <PackageReadmeFile>readme.md</PackageReadmeFile>
            ...
        </PropertyGroup>
      
        <ItemGroup>
            ...
            <None Include="docs\readme.md" Pack="true" PackagePath=""/>
            ...
        </ItemGroup>
      </Project>
      
    • When you are creating a package from a nuspec file, make sure to include the readme file in the <files/> section:

      <package>
        <metadata>
          ...
          <readme>docs\readme.md</readme>
          ...
        </metadata>
        <files>
          ...
          <file src="..\readme.md" target="docs\" />
          ...
        </files>
      </package>
      

Learn more about packaging a readme file.