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,
PackageIconUrl
andiconUrl
are 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
csproj
file:That use the
PackageIcon
node seems to work. And for new-sdk project, usedotnet pack
command 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,
PackageSources5
is 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.config
file-->Migrate packages.config into PackageReference.2) delete
bin
andobj
file and alsonuspec
file in your project folder, the file is redundant and if it exists, it will affect themsbuild -t:pack
.3) add these on the
csproj
file at the bottom of thecsproj
file:You could also add on
csproj
file:After that, click
Rebuild
button and it could generate the nupkg file underproject folder\Debug or Release\
.