NuGet version: NuGet Client Dev\5.9.0.6971
VS Version: Main\30724.151
OS: Windows-10-Enterprise-19h2
1.In the Developer Command Prompt for VS, create a project with ‘dotnet new classlib -o InvalidNetCoreIcon’
2.Make an invalid image file (size not limited to 1 MB with txt format) and locate in the package.
3.Open the project file and modify the file as follows:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
…
<PackageIcon>icon.txt</PackageIcon>
…
</PropertyGroup>
<ItemGroup>
<None Include="icon.txt" Pack="true" PackagePath="" />
</ItemGroup>
</Project>
4.Pack the project with dotnet pack
There should be Error NU5045 (same with the fix for .NET Framework package) show in Developer Command Prompt for VS.
No error occurred as below.

1.This is to say: the fix for bug 9311---Adds icon filename extension validation NuGet/NuGet.Client#3716 should also available for .NET Core package.
2.This is not a regression bug.
Hey @v-luzh
This is happening because pack in VIsual Studio has a different delivery mechanism than commandline.
Particularly, installing the Package Manager VSIX is not enough, it's all about the SDK version being used, and it's likely that the one inserted doesn't have that change.
Alternatively, if you install the nightly NuGet.Build.Tasks.Pack package, it should fix the problem.
Is this an explicit test or part of your verification for fixed issues?
cc @dominoFire
Hey @nkolev92, I didn't pack the package in VS, I did it in commandline.
That is our regular daily manual test scenario "Verify invalid .NET Core embedded icon in local feed" about sub-feature "Embedded icons". We used only one bug 9311 to track these similar issues on both packing .NET Framework/.NET Core package before.
But Adds icon filename extension validation NuGet/NuGet.Client#3716 only fixed the packing .NET Framework package, didn't fix the latter one. So we filed this bug.
I see.
This is difficult to test because of the different shipping.
The pack SDK ships with .NET SDK, not with NuGet.Tools.vsix.
Can you try installing the latest preview NuGet.Build.Tasks.Pack into the project.
You can do that by doing the following:
<add key="nuget-build" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/nuget-build/nuget/v3/index.json" />
to the config. NuGet.Build.Tasks.Pack latest prerelease. I'd expect this fixes the issue.
Note that in about a week or so, this would work with the default VS, once NuGet has inserted into the SDK and the .NET SDK has inserted back into VS.
@nkolev92 Thanks for the workaround. Yes, that works. And we will check it in default VS in about one week.
Sounds good. Assigning this issue to you for now.
Let's come back to it if once the insertion has happened, things are still broken.
@kartheekp-ms Can you please make sure we follow up here after the insertion has been complete.
@nkolev92 VS 16.9 P3 and .NET 5 NuGet Insertion completed today.
https://github.com/NuGet/Client.Engineering/issues/668
I guess tomorrow's VS Int Preview build should have latest bits.
@v-luzh looks like you should be able to test this again now that the insertion's complete?
@kartheekp-ms @zkat, thanks for your info. This issue still repro on Main\30810.171+NuGet Dev\5.9.0.6980 as below screenshot.
. Did the insertion merge in Main\30810.171?
I downloaded https://aka.ms/dotnet/net5/5.0.2xx/daily/Sdk/dotnet-sdk-win-x64.exe daily dotnet SDK build. pack command with invalid icon failed with the expected error message.
C:\Users\{USER NAME}\source\repos\ClassLibrary4\ClassLibrary4>dotnet pack
Microsoft (R) Build Engine version 16.8.0+126527ff1 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
All projects are up-to-date for restore.
You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
ClassLibrary4 -> C:\Users\{USER NAME}\source\repos\ClassLibrary4\ClassLibrary4\bin\Debug\netcoreapp3.1\ClassLibrary4.dll
C:\Program Files\dotnet\sdk\5.0.200-preview.20611.8\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(221,5): error NU5045: The 'icon' element 'icon.txt' has an invalid file extension. Valid options are .png, .jpg or .jpeg. [C:\Users\{USER NAME}\source\repos\ClassLibrary4\ClassLibrary4\ClassLibrary4.csproj]
SDK -> VS might not have happened yet.
Honestly, at this point we're testing the eventual integration, not NuGet itself, especially given that manually download SDK makes things work.
Can we close this issue now as I am unable to repro on dotnet CLI last week build?
This issue is fixed on Main\30822.27 with .NET SDK 5.0.200-preview.20614.14.