NuGet / Home

Repo for NuGet Client issues
Other
1.5k stars 253 forks source link

Self-contained NuGet Packages - Icons should be embedded in Packages #352

Closed johnataylor closed 5 years ago

johnataylor commented 9 years ago

Package Icon should be able to come form inside the package. It should be possible to put a path in the iconUrl that is relative to the package.

veleek commented 9 years ago

Note: Transferred from issue on CodePlex - Packages containing Icon and License

Packages containing Icon and License

Problem Statement

Currently, the NuGet schema only allows the package author to specify the LicenseUrl and IconUrl as external URLs for the license and icon respectively. This puts the burden on the developer to find a place to host those files and update the NuSpec with their locations.

Solution

The NuGet Gallery should support unpacking a license and icon within the package folder both explicitly specified and by convention.

Details

Convention Based Approach

The convention based approach is very simple.

File Description
Icon.png An Icon.png at the root of the package will be unpacked and used as the icon for the package
License.txt A license.txt file at the root of the package will be used as the license

Explicit Reference

Alternatively, we can support explicit references using the file:// prefixed URLs relative to the package root. For example:

<iconUrl>file://content/images/nugetIcon.png</iconUrl>

This grabs the file from the content/images folder of the package and hosts it on the server. This is useful in cases where the icon is also hosted.

Device Specific Icon Images

There a multiple places where icons are displayed.

We should consider a convention that allows developers to include an icon specific to each of these devices.

Proposal

Use a file extension for each.

csharpfritz commented 9 years ago

We see some customers unable to view icons as the web location of the icon image is blocked by their corporate firewall. Possible solution could be to download and serve the images from NuGet.org as a resource at the same URI as the package when an image media type is requested

maartenba commented 9 years ago

-> https://github.com/NuGet/NuGetGallery/issues/2613

xavierdecoster commented 8 years ago

To support an embedded package icon in the nupkg, it seems we only need the 32x32 icon. All other images are only served on the gallery and don't need to be in the package.

As this issue is about supporting an embedded icon in the package, it sounds to me that a convention-based icon.png in the package root could be sufficient? IconUrl is an optional nuspec element, so not sure if we should make it required to support an embedded icon. Perhaps we should simply fallback from IconUrl to icon.png (if present) to default nuget icon?

maartenba commented 8 years ago

That's an entirely different discussion. All we need is package icon proxying over www.nuget.org.

xavierdecoster commented 8 years ago

Nope, your discussion is here: https://github.com/NuGet/NuGetGallery/issues/2613 Related, but not the topic of this client issue 😊 So, on topic, how about this client issue?

yishaigalatzer commented 8 years ago

Proposal

Use a file extension for each.

Icon_dialog.png (32x32) Icon_list.png (50x50) Icon_details.png (100x100)

We should specify the size in the icon name instead

icon32x32.png icon50x50.png icon100x100.png

We need to discuss if we require all of them, can they be updated later etc.

Allann commented 8 years ago

I'd prefer to see the scale convention used by win8 manifests used here too. this would mean that brand images can be re-used and we don't need to create even more files named differently.

hesantan commented 8 years ago

We should specify the size in the icon name instead

icon32x32.png icon50x50.png icon100x100.png

We need to discuss if we require all of them, can they be updated later etc.

I think that just requiring the biggest required size is enough. That image can be downsized to all the other necessary resolutions.

ghuntley commented 8 years ago
ohadschn commented 7 years ago

Downsizing is suboptimal. There is no escape from separate files if you want decent quality. Even the official purple ".NET" icon doesn't look that great in its downsized 32x32 form.

Having the option to only provide one size and have the rest downsized is great, as long as there's a way to provide files for the different sizes separately.

adamralph commented 7 years ago

The image in package details on nuget.org is 128x128, not 100x100.

image

Although, in order to have that showing with full fidelity on a high DPI display, you need a larger image. E.g. I run my display scaled at 200%. Notice the difference between a 128x128 image and a 256x256 image, even though the dimensions within the page are still 128x128:

image

For this reason, I am gradually changing all my NuGet packages to have 256x256 logos instead of 128x128. Of course, that only solves this precisely for high DPI scaling at 200%, and any other level of scaling, e.g. 125%, 150% or greater than 200% will still be suboptimal. One thing that would solve all these issues, forever, is SVG support, since that eliminates the need for image scaling entirely.

BTW - the dimensions in the package list are 48x48, not 50x50:

image

SimonCropp commented 7 years ago

+1 for svg as the default

angamuthu-g commented 7 years ago

hi, I'm facing issue while creating windows installer. this is the issue i'm getting

electron-windows-installer:spawn Spawning mono /var/www/html/Extraction/node_modules/electron-winstaller/vendor/nuget.exe pack /tmp/si-11702-14710-a00hji.hot6ueg66r/app.nuspec -BasePath dist/app-win32-ia32 -OutputDirectory /tmp/si-11702-14710-a00hji.hot6ueg66r -NoDefaultExcludes +3ms No dice: Failed with exit code: 1 Output:

Unhandled Exception: System.TypeLoadException: Could not load type 'NuGet.Program' from assembly 'NuGet, Version=2.8.50926.602, Culture=neutral, PublicKeyToken=null'. [ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type 'NuGet.Program' from assembly 'NuGet, Version=2.8.50926.602, Culture=neutral, PublicKeyToken=null'. WARNING: The runtime version supported by this application is unavailable. Using default runtime: v2.0.50727

sturlath commented 7 years ago

Hi I must be missing something since I just can´t get a local icon to load up in VS og VSTS packages.

  1. My nuspec file contains file://Resources/myIcon.png that is 32x32 (also tried 128x128).
  2. The myIcon.png file is in the project where I have tried all combos (I can think of) of "Build Action" and "Copy to Output Directory".

I have tried searching for a solution without luck and even here in this thread its totally not clear if this is possible. Is it even?

I´m using NuGet Version: 3.5.0.1938

adamralph commented 7 years ago

@sturlath AFAIK it is not possible, and that is the reason that this issue exists.

StingyJack commented 6 years ago

Solution

The NuGet Gallery should support unpacking a license and icon within the package folder both explicitly specified and by convention.

The solution should really have nothing to do with the nuget gallery specifically. I cant put icons on stuff in my local repo without throwing an image on a webserver somewhere on the LAN,

karann-msft commented 6 years ago

@johnataylor It should be possible to put a path in the iconUrl - what problem does this solve?

StingyJack commented 6 years ago

It solves the problem of needing a webserver just to host an icon.

The package is also self contained at that point. I think requiring this one piece of content to be external to the package seems inconsistent or weird to most who have tried to author packages.

karann-msft commented 6 years ago

@StingyJack to clarify, this path is to a folder within the package? So this is about flexibility to put the icon at a custom location versus a standard location say the package root.

PathogenDavid commented 6 years ago

I think the idea of using a file path for iconUrl was simply inspired by the way icons work today. I imagine most people would be OK if the package icon was just a specially named file at the root of the package.

karann-msft commented 6 years ago

Here is the spec - https://github.com/NuGet/Home/wiki/Packaging-Icon-within-the-nupkg

StingyJack commented 6 years ago

@karann-msft - that spec is missing "Browse from a private repository". We have a private repo from running Nuget.Server.

To your earlier question, I dont really think I care about where in the package the icon needs to be.

Replace Icon URL with Icon, keeping it a free text field (for the MVP)

Only Most Valuable Players get to use the icon field?

<PacakgeIcon

You may want to fix that spelling before it becomes the next "configuration file wather "

augustoproiete commented 6 years ago

@StingyJack "MVP", in this context, stands for Minimum Viable Product.

markusschaber commented 6 years ago

Just a question from one jumping in here late: Why is SVG not in the current spec, only PNG and JPG?

PathogenDavid commented 6 years ago

@karann-msft

Spec looks great, thanks for pushing this issue through!


@StingyJack

that spec is missing "Browse from a private repository". We have a private repo from running Nuget.Server.

I would assume that private NuGet servers (MyGet, NuGet.Server, Nexus, Chocolatey, etc) would all work the same as NuGet.org


@markusschaber

Why is SVG not in the current spec, only PNG and JPG?

I would suspect because SVG is non-trivial for non-web clients like Visual Studio to render.

StingyJack commented 6 years ago

I would assume that private NuGet servers (MyGet, NuGet.Server, Nexus, Chocolatey, etc) would all work the same as NuGet.org

So many features that I need from nuget are removed with every release (ps1, tt, mutable content, 4 part version numbering, consistent restore, etc). With this omission in the spec I could reasonably assume non-nuget.org repos will go the same way, and the omission being the only notice about it.

adamralph commented 6 years ago

Would it be possible to default to using icon.{known extension} if present, to avoid having to boilerplate <PackageIcon source="icon.png", target=""/> across the ecosystem?

augustoproiete commented 6 years ago

@karann-msft - spec looks great!

Would be nice if SVG was supported - with a fallback to PNG or JPG. i.e. Would be nice if developers could include multiple image types in the same package, for example, SVG and/or PNG and/or JPG and the client can decide which one to render, based on what it supports... If client can't render SVG, then fallback to PNG or JPG, etc.

e.g. in the package root: /icon.svg /icon.png /icon.jpg

karann-msft commented 6 years ago

@adamralph Great feedback and we considered doing that. Since multiple extensions are supported, we didn't want to cycle through to check for the presence of one and then for the next. This may have perf implications for clients.

@caioproiete @markusschaber Supporting SVG would be great and is definitely on our backlog. At present, supporting SVG will break many NuGet clients that do not support SVG. We could change the protocol that allows the client to express the supported types for icons to the server and server then provides the right format for package icons to the requesting client. But then this felt like something that's beyond the MVP and can be taken up later.

augustoproiete commented 6 years ago

@karann-msft Great! All makes sense to me... Supporting PNG and/or JPG would be a fantastic start. Just wanted to make sure you guys leave the door open for other formats in future versions!

markusschaber commented 6 years ago

@karann-msft I see, thanks.

My first thought was that if we allow a list of ;-separated filenames in the source tag, this cannot be added later in a backwards compatible way if clients don't know how to parse that kind of list.

But then I realized that we could add a separate attribute, e. G. highsource="icon.svg", to the PackageIcon tag (in analogy to <img lowsrc="..." in HTML), or nested tags, so capable clients can display the high resolution image, while non-capable clients will use the pixel version by default...

Btw, if the protocol is HTTP based, there's already the http Accept header which could serve the purpose of letting the client decide which image types it supports.

adamralph commented 6 years ago

@karann-msft why not bake in the default icon at packaging time? Effectively, when creating the package, the presence of icon.{known extension} in the project root would result in the same packaging action as would the presence of <PackageIcon source="icon.png", target=""/>.

markusschaber commented 6 years ago

@adamralph As far as I can see, this is not backwards compatible (there might be projects which happen to have an icon.png in the root directory for other reasons - I'm not sure whether it's a good idea to start exposing this image silently.

Citing "The Zen of Python":

Explicit is better than implicit.

adamralph commented 6 years ago

@markusschaber

As far as I can see, this is not backwards compatible (there might be projects which happen to have an icon.png in the root directory for other reasons - I'm not sure whether it's a good idea to start exposing this image silently.

I was waiting for someone to play this card. 😉

I agree that it is not backwards compatible, but I expect the number of affected packages to be vanishingly small, and it would only cause a minor, cosmetic, problem. The cost of fixing those packages will be much less than the cost of having to boilerplate <PackageIcon source="icon.png", target=""/> across almost very package in the entire ecosystem.

Explicit is better than implicit.

In some contexts I would strongly disagree. e.g. compare the new "SDK-style" csproj format (sensible, implicit defaults) to the old one (everything explicit).

karann-msft commented 6 years ago

@adamralph the potential perf impact I cited was for clients to have to cycle through to look for multiple files with different extensions when for example browsing packages from a folder based

ohadschn commented 6 years ago

@karann-msft just to nit pick, "cycle through" implies sequentiality, where I don't see any reason for the client not to try all 3 (or whatever number of possible fallbacks) files in parallel...

adamralph commented 6 years ago

@karann-msft the location of the icon inside the package can still be baked into the package metadata. My suggestion doesn't change that. What I am saying is that when creating the package, the presence of icon.{known extension} in the project folder has the same effect as <PackageIcon source="icon.{known extension}", target=""/> in the csproj file.

karann-msft commented 6 years ago

@adamralph I now see what you mean. What's your typical package creation workflow? Do you run pack on a folder, nuspec, or a csproj?

markusschaber commented 6 years ago

@karann-msft about the perf impact with "cycle through": As the client knows which file types it supports, it can filter by known extensions and choose the first hit, just while parsing the list of icon pathes, long before hitting the network. Also, it's usually only a handful of icons (I don't see any need to add more than 2 - a bitmap and a vector one). So the performance impact is not that serious.

adamralph commented 6 years ago

@karann-msft I use both nuspec and csproj for creating packages.

StingyJack commented 6 years ago

These all sound great, but can we get <iconUrl>file://content/images/nugetIcon.png</iconUrl> to work first? That I think is the minimum for me.

adamralph commented 6 years ago

@StingyJack you'd have less to do if icon.png in the root of your project were used automatically.

StingyJack commented 6 years ago

True, but someone would have to program that extra bit of automagic instead of just using the existing setting and uri. Either would be less than figuring out all the scaling and image format support. None of these are as important as the other open issues I have.

karann-msft commented 6 years ago

@markusshaber we'd rather not make package consumers take any perf hit if possible. On the authoring side, you used to specify a url before (and had to find a place to host the image), now it's a file path to an image within the package.

@adamralph would you expect only a specific file name and extension to get picked up from that known location? So only if the image is named icon.png and is placed right next to the csproj or is at the root of the folder you run pack on, it'll get picked up at pack.

adamralph commented 6 years ago

@karann-msft yes, I would expect only icon.png at the root of the project/folder to be used by default. I guess you could also support icon.jpg or other extensions, but PNG will probaby take care of 99% of cases.

karann-msft commented 6 years ago

Thanks for the feedback @adamralph, updated the spec.

adamralph commented 6 years ago

Thanks @karann-msft. The spec looks good.

StingyJack commented 6 years ago

@karann-msft - spec still only talks about Nuget.org and folder based repos, and even has provisions for nuget.org webmasters to block some images.

Am i reading that support for icons in private nuget repositories based on NuGet.Server is not happening and that this could break them or the packages therein (like the unwanted version normalization)? Or is it not included because private repo's themselves are not going to be supported? Or is it just an oversight?

josesimoes commented 5 years ago

Any update on this, please?