NuGet / Samples

NuGet team sample repo
Other
136 stars 108 forks source link

Icon still not showing up #57

Closed maslewandowski closed 1 year ago

maslewandowski commented 1 year ago

I have followed your sample but the icon is not showing up in azure artifacts.

Project File:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <PackageIcon>nugetIcon.png</PackageIcon>
    <Version>1.0.0.1</Version>
  </PropertyGroup>

  <ItemGroup>
    <None Include="Resources\nugetIcon.png" Pack="true" PackagePath="" />
  </ItemGroup>

  <ItemGroup>
    <Compile Update="Properties\Resources.Designer.cs">
      <DesignTime>True</DesignTime>
      <AutoGen>True</AutoGen>
      <DependentUpon>Resources.resx</DependentUpon>
    </Compile>
  </ItemGroup>

  <ItemGroup>
    <EmbeddedResource Update="Properties\Resources.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
    </EmbeddedResource>
  </ItemGroup>

</Project>

Project in Solution Explorer image

Image Properties image

What am I doing wrong?

Thanks for help.

P.S.: Azure Artifacts image

DaleMckeown commented 1 year ago

Yeah, the Azure Artifacts team doesn't care. They have only exposed the image in the Azure Artefacts feed if it is contained in the PackageIconUrl field.

https://learn.microsoft.com/en-us/nuget/create-packages/package-authoring-best-practices#package-metadata

So, Microsoft recommends deprecating the PackageIconUrl property in favor of the PackageIcon field and using an embedded image in the NuGet package, but this is completely unsupported by Azure DevOps. So if you try to embed the icon in the NuGet package in the recommended way, you'll only ever see the default NuGet image in both Visual Studio and the DevOps Azure Artifact list.

Your option is either ignore the recommendation and continue to use the PackageIconUrl field, or move to PackageIcon and host your package somewhere other than Azure Artifacts.

There have been issues created for this going back 4 years, but apparently agreeing to and then implementing a spec is too much for teams within the Microsoft organization to accomplish.

Tough for us customers, I guess!

maslewandowski commented 1 year ago

Seems to be fixed, because now I can see those icons.

DaleMckeown commented 1 year ago

Interesting, I'll check this out today and see!

DaleMckeown commented 1 year ago

@maslewandowski Can you share your package project file? I've just switched over a package from PackageIconUrl to PackageIcon and it's definitely not showing the image in DevOps or in VS, despite the image being bundled into the NuGet package. Thanks 👍

WeihanLi commented 1 year ago
<Project>
  <PropertyGroup>
    <PackageIcon>icon.jpeg</PackageIcon>
  </PropertyGroup>
  <ItemGroup>
    <None Include="icon.jpeg" Pack="true" Visible="false" PackagePath=""/>
  </ItemGroup>
</Project>

hope it helps

DaleMckeown commented 1 year ago

This is exactly what I have in my NuGet config, it definitely is not showing the package icon in Visual Studio or on the DevOps artifact feed.

WeihanLi commented 1 year ago

Is there a sample project? Seemed to work for me, here's my project https://github.com/WeihanLi/nocker and the NuGet package https://www.nuget.org/packages/nocker

DaleMckeown commented 1 year ago

I appreciate the help, but that's being hosted on NuGet and not via Azure Artifacts, which is what this issue is about.

I've just dug into my Azure Artifacts feed, it looks like the iconUrl is being returned in the feeds now.

Feed example: https://pkgs.dev.azure.com/{teamName}/_packaging/{feedId}/nuget/v3/query2/?prerelease=true&semVerLevel=2.0.0

returns my feed:

{
  "@context": {
    "@vocab": "http://schema.nuget.org/schema#",
    "comment": "http://www.w3.org/2000/01/rdf-schema#comment",
    "label": "http://www.w3.org/2000/01/rdf-schema#label"
  },
  "data": [
    {
      "@id": "",
      "@type": "Package",
      "id": "TestPackage",
      "version": "7.0.0-beta.1",
      "description": "Package description.",
      "versions": [
        {
          "@id": "TestPackage",
          "downloads": 0,
          "version": "7.0.0-beta.1"
        }
      ],
      "authors": [
        "authorName"
      ],
      "iconUrl": "https://pkgs.dev.azure.com/{teamName}/_packaging/{feedId}/nuget/v3/flat2/testpackage/7.0.0-beta.1/testpackage.7.0.0-beta.1.nupkg?extract=Icon.png",
      "licenseUrl": "",
      "projectUrl": "https://{teamName}@dev.azure.com/{teamName}/{feedName}/_git/TestPackage",
      "registration": "",
      "summary": null,
      "tags": null,
      "title": null
    }
  ]
}

So it looks like the icon has indeed been added to the DevOps NuGet feed. However, when viewing the iconUrl above, I get the following error:

{
    "$id": "1",
    "innerException": null,
    "message": "TF400813: The user 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' is not authorized to access this resource.",
    "typeName": "Microsoft.TeamFoundation.Framework.Server.UnauthorizedRequestException, Microsoft.TeamFoundation.Framework.Server",
    "typeKey": "UnauthorizedRequestException",
    "errorCode": 0,
    "eventId": 3000
}

Seems that there is some kind of permission issue. I'll keep digging.

DaleMckeown commented 1 year ago

VS2022 issues seems to be authorization based - have reported to the VS team at https://developercommunity.visualstudio.com/t/post/10433567.

I assume that the DevOps frontend is similar. @maslewandowski could you prove a screenshot showing custom icons in your private feed on DevOps?