NuGet Error NU5046
The icon file 'icon.png' does not exist in the package.
Issue
NuGet is unable find the icon file in the package.
Solution
- Make sure that the file that is marked as the package icon exists at the source and it is readable, and the target matches the path expected by the
icon
property. - Ensure that the file is referenced in the nuspec or in the project file.
When creating a package from a MSBuild project file, make sure to reference the icon file in the project, as follows:
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> ... <PackageIcon>icon.png</PackageIcon> ... </PropertyGroup> <ItemGroup> ... <None Include="images\icon.png" Pack="true" PackagePath=""/> ... </ItemGroup> </Project>
When you are creating a package from a nuspec file, make sure to include the icon file in the
<files/>
section:<package> <metadata> ... <icon>images\icon.png</icon> ... </metadata> <files> ... <file src="..\icon.png" target="images\" /> ... </files> </package>