Home: License and icon file existence check should always use a case-sensitive comparison

Created on 18 Jul 2020  路  6Comments  路  Source: NuGet/Home

When you attempt to create a NuGet package with a license file that doesn't exist, NuGet will complain with NU5030:

The license file 'LICENSE.txt' does not exist in the package.

However, this check uses an OS-dependent string comparison.

This isn't correct as NuGet packages are zip files, which use case-sensitive paths. As a result, using the wrong case for the license element results in an invalid package.


Consider this modified PackageLicenseFileExample from NuGet/Samples. Namely the typo made to PackageLicenseFile:

<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>

Running dotnet pack results in a "successful" nupkg:

image

Attempting to upload this package to NuGet.org results in an error:

image

If you put the package into a local feed and attempt to view the license from Visual Studio 2019 (16.6.4) you'll get an error:

image

I also tried an old instance of Nexus Package Manager, which did accept the package. (However that may be more due to the fact that it doesn't understand embedded licenses.) I did not check how any other package servers reacted to the broken package.


Versions and stuff from the issue template

NuGet product used: dotnet and VS UI.

NuGet version: Whatever dotnet is using under the hood. (The old nuget.exe I have kicking around in my environment is 4.8.1.5435)

dotnet.exe --version: 5.0.100-preview.6.20318.15

VS version: 16.6.4

OS version: Windows 10 v1909 (18363.959)

Worked before? Unlikely, Git blame suggests this check has always worked this way.


I considered submitting a PR to fix this, but it is unclear whether this change can be made or if it should be a new warning instead to avoid a backwards compatibility issues. (Especially considering the package is still valid to package servers which aren't aware of embedded license files.)

PackageDefinition Community Pack Backlog Icebox 2 Bug help wanted

All 6 comments

We can take a patch from you to address this! My first gut feeling is that your second suggestion (making it a warning) would be the safest one to go with, if you want to get started with something like that. We can review a proposal from you and help review the code.

Sorry for ghosting on this issue, my random contribution energy/time evaporated between when I filed this issue and your response. I finally found some time this morning to write up a design (hopefully that's what you meant by proposal), and I've submitted it as https://github.com/NuGet/Home/pull/10049

An issue with multiple upvotes was created at https://github.com/NuGet/Home/issues/10102.

Bumping up pri as per that.

@PathogenDavid I looked at the design again and it looks good to me.
I think we need some more people from the owners to chime in as far as error vs warning discussion goes.

We'll try to get back to you as soon as possible!

Thank you for working on this!

No problem! Thanks for pinging the PR since I've been meaning to do the same.

@PathogenDavid thank you for your contribution! This will be released with NuGet.exe 5.9, and the .NET 5 SDK 5.0.200.

@zivkan No problem, thanks for the merge!

Was this page helpful?
0 / 5 - 0 ratings