I've been migrating our nuget packages to using Self-contained icons support. When I publish them to MyGet, we're not seeing the icon image in Visual Studio package manager UI.
Is this a bug? Has anyone else published a nuget package to MyGet using self-contained icons and they show in the VS package manager UI?
Sure. It is an issue and check this link. Self-contained icons which is packed into the nupkg cannot be used on the local nuget package source.
So my suggestions are that:
Suggestions
One suggestion is that you could upload your nuget package into nuget.org.
Second is to use icon Url. Unload your icon on a website.
New-sdk format lib pack:
nuspec file with this:
Update 1
Actually,
PackageIconUrlandiconUrlare removed. And thanks for your guidance.But when I tested in a new-sdk style(net core or net standard) lib project, I can use these on
csprojfile:That use the
PackageIconnode seems to work. And for new-sdk project, usedotnet packcommand line or just right-click on the project on the Solution Explorer-->Pack.Note: My VS is VS2019 Community 16.8.6 and if your VS2019 is too old, please update it first.
Also,
PackageSources5is local feed.Besides, if you used a non-sdk style net framework project, it actually can be done. You should use msbuild -t:pack rather than traditional nuget pack with custom nuspec file.
1) install a nuget package called NuGet.Build.Tasks.Pack on the lib project and remember that you should use PackageReference format to install it. If not, you should right-click on the
packages.configfile-->Migrate packages.config into PackageReference.2) delete
binandobjfile and alsonuspecfile in your project folder, the file is redundant and if it exists, it will affect themsbuild -t:pack.3) add these on the
csprojfile at the bottom of thecsprojfile:You could also add on
csprojfile:After that, click
Rebuildbutton and it could generate the nupkg file underproject folder\Debug or Release\.