简体   繁体   English

MyGet 不显示 nuget package 自包含图标

[英]MyGet doesn't show nuget package Self-contained icons

I've been migrating our nuget packages to using Self-contained icons support.我一直在将我们的 nuget 包迁移到使用独立图标支持。 When I publish them to MyGet, we're not seeing the icon image in Visual Studio package manager UI.当我将它们发布到 MyGet 时,我们在 Visual Studio package 管理器 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?有没有其他人使用独立的图标向 MyGet 发布了 nuget package 并且它们显示在 VS package 管理器 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.打包到 nupkg 中的自包含图标不能在本地 nuget package 源上使用。

So my suggestions are that:所以我的建议是:

Suggestions建议

One suggestion is that you could upload your nuget package into nuget.org.一个建议是您可以将 nuget package 上传到 nuget.org。

Second is to use icon Url.其次是使用图标 Url。 Unload your icon on a website.在网站上卸载您的图标。

New-sdk format lib pack:新的sdk格式库包:

<PackageIconUrl> https://company.com/icon.png </PackageIconUrl>

nuspec file with this: nuspec 文件与此:

<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
  <metadata minClientVersion="3.3">
    <icon>images\icon.png</icon>
    <iconUrl>https://company.com/icon.png</iconUrl>
  </metadata>
  <files>
    <file src="..\..\icon.png" target="images\icon.png" />
  </files>
</package>

Update 1更新 1

Actually , PackageIconUrl and iconUrl are removed.实际上PackageIconUrliconUrl已被删除。 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:但是当我在一个新的 SDK风格(网络核心或网络标准)lib 项目中进行测试时,我可以在csproj文件中使用这些:

 <PropertyGroup>
        <PackageId>moqq</PackageId>
        <Version>1.0.0</Version>
        <Authors>me</Authors>
        <PackageIcon>images\test.png</PackageIcon>              
 </PropertyGroup>
 <ItemGroup>
        <None Include="mysql.png" Pack="true" PackagePath="images"></None>
 </ItemGroup>

That use the PackageIcon node seems to work.使用PackageIcon节点似乎有效。 And for new-sdk project, use dotnet pack command line or just right-click on the project on the Solution Explorer--> Pack .对于 new-sdk 项目,使用dotnet pack命令行或在 Solution Explorer--> Pack上右键单击该项目。

Note : My VS is VS2019 Community 16.8.6 and if your VS2019 is too old, please update it first.注意:我的VS是VS2019 Community 16.8.6 ,如果你的VS2019太旧,请先更新。

Also , PackageSources5 is local feed.此外PackageSources5是本地提要。

在此处输入图像描述

Besides , if you used a non-sdk style net framework project, it actually can be done.另外,如果你用的是非sdk风格的net framework项目,其实也可以。 You should use msbuild -t:pack rather than traditional nuget pack with custom nuspec file.您应该使用msbuild -t:pack而不是带有自定义 nuspec 文件的传统 nuget 包。

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. 1)在 lib 项目上安装一个名为NuGet.Build.Tasks.Pack的 nuget package 并记住您应该使用PackageReference格式来安装它。 If not, you should right-click on the packages.config file--> Migrate packages.config into PackageReference .如果没有,您应该右键单击packages.config文件-->将 packages.config 迁移到 PackageReference中。

2) delete bin and obj file and also nuspec file in your project folder, the file is redundant and if it exists, it will affect the msbuild -t:pack . 2)删除项目文件夹中的binobj文件以及nuspec文件,该文件是多余的,如果存在,它将影响msbuild -t:pack

3) add these on the csproj file at the bottom of the csproj file: 3)将这些添加到csproj文件底部的csproj文件中:

<PropertyGroup>
        <PackageId>moqqq</PackageId>
        <Version>1.0.0</Version>
        <Authors>me</Authors>
        <PackageIcon>images\test.png</PackageIcon>
        <PackageIconUrl></PackageIconUrl> 
         
</PropertyGroup>
<ItemGroup>
        <None Include="test.png" Pack="true" PackagePath="images"></None> 
</ItemGroup>

You could also add on csproj file:您还可以添加csproj文件:

<PropertyGroup>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>

After that , click Rebuild button and it could generate the nupkg file under project folder\Debug or Release\ .之后,点击Rebuild按钮,它可以在project folder\Debug or Release\下生成 nupkg 文件。

在此处输入图像描述

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM