-
Notifications
You must be signed in to change notification settings - Fork 197
Description
The spec says nothing about how NuGet package names should be normalized, but the test suite ensures that NuGet package names are case sensitive.
This is not true about NuGet package names. The NuGet API documentation is very specific about how the names are converted to lowercase on the client side before making a request to the API: https://learn.microsoft.com/en-us/nuget/api/package-base-address-resource This precludes the ability for multiple packages to exist with names that vary only by capitalization because the package data for all such packages would need to exist simultaneously at the same address.
This can be verified by installing packages:
$ docker run --rm -it mcr.microsoft.com/dotnet/sdk:6.0
root@f796b64be31c:/# mkdir test
root@f796b64be31c:/# cd test
root@f796b64be31c:/test# dotnet new console
The template "Console App" was created successfully.
Processing post-creation actions...
Running 'dotnet restore' on /test/test.csproj...
Determining projects to restore...
Restored /test/test.csproj (in 51 ms).
Restore succeeded.
root@f796b64be31c:/test# dotnet add package NeWtOnSoFt.jSoN
Determining projects to restore...
Writing /tmp/tmpjQ7OCK.tmp
info : X.509 certificate chain validation will use the fallback certificate bundle at '/usr/share/dotnet/sdk/6.0.407/trustedroots/codesignctl.pem'.
info : Adding PackageReference for package 'NeWtOnSoFt.jSoN' into project '/test/test.csproj'.
info : GET https://api.nuget.org/v3/registration5-gz-semver2/newtonsoft.json/index.json
info : OK https://api.nuget.org/v3/registration5-gz-semver2/newtonsoft.json/index.json 48ms
info : Restoring packages for /test/test.csproj...
info : GET https://api.nuget.org/v3-flatcontainer/newtonsoft.json/index.json
info : OK https://api.nuget.org/v3-flatcontainer/newtonsoft.json/index.json 45ms
info : GET https://api.nuget.org/v3-flatcontainer/newtonsoft.json/13.0.3/newtonsoft.json.13.0.3.nupkg
info : OK https://api.nuget.org/v3-flatcontainer/newtonsoft.json/13.0.3/newtonsoft.json.13.0.3.nupkg 33ms
info : Installed Newtonsoft.Json 13.0.3 from https://api.nuget.org/v3/index.json with content hash HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ==.
info : Package 'NeWtOnSoFt.jSoN' is compatible with all the specified frameworks in project '/test/test.csproj'.
info : PackageReference for package 'NeWtOnSoFt.jSoN' version '13.0.3' added to file '/test/test.csproj'.
info : Writing assets file to disk. Path: /test/obj/project.assets.json
log : Restored /test/test.csproj (in 518 ms).
root@f796b64be31c:/test# cat test.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NeWtOnSoFt.jSoN" Version="13.0.3" />
</ItemGroup>
</Project>
Even though I used clearly the wrong capitalization, the HTTP requests use lowercase names and the correct package is found.
I don't know if the spec should be expanded to specify that NuGet names are case insensitive, but the tests asserting that the package name is case sensitive should probably be removed.