Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config option to show the nuspec title field in NuGet.Server's OData title field instead of package ID #9010

Open
D4N4M8 opened this issue Feb 18, 2022 · 5 comments

Comments

@D4N4M8
Copy link

D4N4M8 commented Feb 18, 2022

NuGet Product Used

NuGet.exe, NuGet SDK

Product Version

NuGet.Protocol (6.1.0)

Worked before?

No response

Impact

It's more difficult to complete my work

Repro Steps & Context

I'm in the process of transitioning from a local NuGet feed to a self-hosted NuGet server. I encountered a problem when testing the self-hosted NuGet server, which affects the NuGet packages or the NuSpec files: The "GetMetaDataAsync" method and the "SearchAsync" method do not return the title of the NuSpec file or the NuGet package in the "title" field of the "IPackageSearchMetadat" object. Apparently the "ID" is returned in the "Title" field.

I use the "title"-field in the installation process of my packages to display less technical text to the end-user. Of course I could use the "description"-field as a temporary solution, but then I don't have this field for a detailed description.

The following steps must be carried out to reproduce the error:

  1. Create and start your own NuGet.Server (Link: https://docs.microsoft.com/en-us/nuget/hosting-packages/nuget-server)
    image

  2. Create a NuSpec-File.
    image

  3. Build the nuget package and add it to your nuget server.
    image

  4. Check if the package is in the packages folder.
    image

  5. Open the NuSpec file of your package, which is located on the NuGet server, in a text editor and check the "id"-, the "title"- and the "description"-field.
    image

  6. Create a console application (e.g. with NET 6.0) and install the NuGet package "NuGet.Protocol" (version 6.1.0)
    image

  7. Connect your console application to your NuGet server (packageSource) and search your NuGet package by package id (e.g. MyId000123).

  8. Write the "ID", "Title" and "Description" to your console window via the WriteLine method.
    image

Problem:
The "GetMetaDataAsync" method and the "SearchAsync" method do not return the title of the NuSpec file or the NuGet package in the "title" field of the "IPackageSearchMetadat" object (siehe screenshot)

image

Analyse:
The NuSpec title is returned correctly via a GET request.
image

I think the error happens on client side. Probably inside the "V2FeedParser.cs" class. The XML structure is converted into the internal object in the "ParsePackage" method. I think the wrong "Title" element is being mapped here.

image

image

image

I hope I described the error sufficiently and it's okay that I didn't upload any example applications.

I look forward to feedback!

Best regards Daniel

Verbose Logs

No response

@D4N4M8 D4N4M8 changed the title [Bug]: IPackageMetadataSearch does not return the "Title" of a NuGet package's NuSpec file [Bug]: IPackageMetadataSearch does not return the "title" of a NuGet package's NuSpec file Feb 18, 2022
@nkolev92 nkolev92 transferred this issue from NuGet/Home Feb 18, 2022
@nkolev92
Copy link
Member

This seems like a NuGet.Server problem.

Moving to the gallery repo.

@joelverhagen
Copy link
Member

@D4N4M8 thanks for the detailed bug report. I am not sure if this is specific to NuGet.Server. Could you try your sample app against NuGet.org's V2 endpoint? i.e. https://www.nuget.org/api/v2

If you query for a package like Newtonsoft.Json, which has a title field of JSON.NET, I think you may see the same problem.
https://www.nuget.org/api/v2/Packages(Id='Newtonsoft.Json',Version='9.0.1')
image

I am thinking this may be an expected behavior of the client SDK (e.g. NuGet.Protocol). There has been a long running effort to move away from using the title attribute and use only the package ID. I think behavior in the client may be part of (or a side effect of) that broader effort.

Anyhow, please try against NuGet.org with a package having a set title attribute and let me know if you run into the same problem. If you do, I think this is expected behavior and not a NuGet.Server bug.

One possible route would be for you to open a PR against the NuGet/NuGet.Server repo which allows this behavior to be changed from configuration, e.g. a "UseTitleAsODataTitle = true | false" setting.

@joelverhagen joelverhagen self-assigned this Feb 22, 2022
@D4N4M8
Copy link
Author

D4N4M8 commented Feb 22, 2022

@joelverhagen: Thank you for your quick reply. I tested it again with the NuGet.org's V2 endpoint. Your guess is correct. The behavior is identical (see attached screenshot).

image

Do you close this issue or how do we proceed with this?

Greetings Daniel

@joelverhagen
Copy link
Member

You can keep this issue open until that PR is merged. Typically we have a tracking issue for all PRs. This issue can be the tracking issue for the NuGet.Server PR.

@joelverhagen joelverhagen changed the title [Bug]: IPackageMetadataSearch does not return the "title" of a NuGet package's NuSpec file Add config option to show the nuspec title field in NuGet.Server's OData title field instead of package ID Feb 22, 2022
@joelverhagen joelverhagen removed their assignment Mar 15, 2022
@altncsab
Copy link

Is there any progress in this issue?
I'm using 6.7 already and the mapping problem is still present.
Usage of "UseTitleAsODataTitle = true | false" setting is not clearly described hire.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants