NuGet 警告 NU5048NuGet Warning NU5048

The 'PackageIconUrl'/'iconUrl' element is deprecated. Consider using the 'PackageIcon'/'icon' element instead. Learn more at https://aka.ms/deprecateIconUrl

問題Issue

圖示 URL 已被取代,以便在 NuGet 套件內內嵌圖示。Icon URL is deprecated in favor of embedding the icon inside the NuGet package. 可能的原因包括:Possible causes are:

  • 從 nuspec 檔案建立套件時,它會包含一個<iconUrl/>專案。When creating a package from a nuspec file, it contains a <iconUrl/> entry.
  • 從 MSBuild 專案檔建立封裝時,它會包含<PackageIconUrl>屬性。When creating a package from a MSBuild project file, it contains a <PackageIconUrl> property.

方案Solution

若要停止看到此警告,請將內嵌圖示新增至您的套件。To stop seeing this warning, add an embedded icon to your package.

針對 MSBuild 專案檔,新增<PackageIcon/>屬性,如下所示:For MSBuild project files, add an <PackageIcon/> property, as follows:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
      ...
      <PackageIcon>icon.png</PackageIcon>
      ...
  </PropertyGroup>

  <ItemGroup>
      ...
      <None Include="images\icon.png" Pack="true" PackagePath=""/>
      ...
  </ItemGroup>
</Project>

針對 nuspec 檔案,新增<icon/>指向檔案的專案,該檔案將會是封裝圖示:For nuspec files, add an <icon/> entry that points to the file that will be the package icon:

<package>
  <metadata>
    ...
    <icon>images\icon.png</icon>
    ...
  </metadata>
  <files>
    ...
    <file src="..\icon.png" target="images\" />
    ...
  </files>
</package>

深入瞭解封裝圖示影像檔Learn more about packaging an icon image file.