NuGet package with uppercase characters in prerelease version suffix not found
Summary
NuGet package with uppercase characters in prerelease version suffix not found when using nuget.exe restore
Steps to reproduce
- Create NuGet package: Tool.Dummy.Test.1.0.25-TST1.nupkg
- Push nuget package to the server:
nuget push ../nuget_packages/Tool.Dummy.Test.1.0.25-TST1.nupkg -Source [Your NuGet Source]
- Create packages.config file:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Tool.Dummy.Test" version="1.0.25-TST1" />
</packages>
- Execute command:
nuget restore -PackagesDirectory . -Source [Your NuGet Source]
Example Project
https://gitlab.com/hvandenwijngaerden/uppercasenugettest
- Checkout repository
- Add nuget source to the project
- Run the command:
nuget restore -PackagesDirectory . -Source [Your NuGet Source]
What is the current bug behavior?
Unable to find the NuGet package: Unable to find version '1.0.25-TST1' of package 'Tool.Dummy.Test'.
What is the expected correct behavior?
Package found and installed in the current folder
Relevant logs and/or screenshots
PS C:\dev\GitLabPacketIssue\UpperCaseNuGetTest> nuget restore -PackagesDirectory . -Source UpperCaseNuGetTest
Restoring NuGet package Tool.Dummy.Test.1.0.25-TST1.
GET https://gitlab.com/api/v4/projects/22097589/packages/nuget/download/tool.dummy.test/1.0.25-tst1/tool.dummy.test.1.0.25-tst1.nupkg
NotFound https://gitlab.com/api/v4/projects/22097589/packages/nuget/download/tool.dummy.test/1.0.25-tst1/tool.dummy.test.1.0.25-tst1.nupkg 464ms
WARNING: Unable to find version '1.0.25-TST1' of package 'Tool.Dummy.Test'.
C:\Users\hvandenwijngaerden\.nuget\packages\: Package 'Tool.Dummy.Test.1.0.25-TST1' is not found on source 'C:\Users\hvandenwijngaerden\.nuget\packages\'.
https://gitlab.com/api/v4/projects/22097589/packages/nuget/index.json: Package 'Tool.Dummy.Test.1.0.25-TST1' is not found on source 'https://gitlab.com/api/v4/projects/22097589/packages/nuget/index.json'.
WARNING: Unable to find version '1.0.25-TST1' of package 'Tool.Dummy.Test'.
C:\Users\hvandenwijngaerden\.nuget\packages\: Package 'Tool.Dummy.Test.1.0.25-TST1' is not found on source 'C:\Users\hvandenwijngaerden\.nuget\packages\'.
https://gitlab.com/api/v4/projects/22097589/packages/nuget/index.json: Package 'Tool.Dummy.Test.1.0.25-TST1' is not found on source 'https://gitlab.com/api/v4/projects/22097589/packages/nuget/index.json'.
Errors in packages.config projects
Unable to find version '1.0.25-TST1' of package 'Tool.Dummy.Test'.
C:\Users\hvandenwijngaerden\.nuget\packages\: Package 'Tool.Dummy.Test.1.0.25-TST1' is not found on source 'C:\Users\hvandenwijngaerden\.nuget\packages\'.
https://gitlab.com/api/v4/projects/22097589/packages/nuget/index.json: Package 'Tool.Dummy.Test.1.0.25-TST1' is not found on source 'https://gitlab.com/api/v4/projects/22097589/packages/nuget/index.json'.
NuGet Config files used:
C:\Users\hvandenwijngaerden\AppData\Roaming\NuGet\NuGet.Config
C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config
Feeds used:
C:\Users\hvandenwijngaerden\.nuget\packages\
https://gitlab.com/api/v4/projects/22097589/packages/nuget/index.json
Output of checks
Bug happens on self-managed and GitLab.com
Results of GitLab environment info
Results of GitLab application Check
Possible fixes
I think the issues comes from the version string matching being case sensitive. When requesting the package, nuget.exe changes the version to all lowercase characters. In the file app\finders\packages\nuget\package_finder.rb
it tries to match the version with the function with_version
and this fails to find a matching version. If I add a function in the file app\models\packages\package.rb
like scope :with_version_like, -> (version) {where(arel_table[:version].matches(version)) }
. And then in the package_finder.rb
file I use that function, then it will be able to find the packet and install it on the system.