NuGet Error NU5030

The license file 'LICENSE.txt' does not exist in the package.

Issue

The license file is referenced in the metadata with either PackageLicenseFile in the csproj or the license element in the nuspec, but the file itself was not included in the expected location within the package.

Solution

Include the file in the package, for example:

If pack with the targets:

<PropertyGroup>
    <PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
</PropertyGroup>

<ItemGroup>
    <None Include="licenses\LICENSE.txt" Pack="true" PackagePath="" />
</ItemGroup>

If packing with a nuspec:

<package>
  <metadata>
    <license type="file">LICENSE.txt</license>
  </metadata>
  <files>
      <file src="licenses\LICENSE.txt" target="" />
  </files>
</package>