Search code examples
powershellnugetcloudartifactory

Nuget restore command line responds Package is not found on source - Artifactory cloud server


I know that the NuGet packages are there. I can list them on my Artifactory page. Why can't my nuget restore command see them?

I have a server at JFrog Artifactory. Let's say the URL is https://companyname.jfrog.io/artifactory.

I have a NuGet package repository at that location. The repository is called 'repo-name-local'.

My NuGet packages show up as they should at https://companyname.jfrog.io/ui/repos/tree/General/repo-name-local

... and they appear in the repository listing at https://companyname.jfrog.io/ui/repos/tree/General/repo-name-local

On that page, the "URL to file" is given as https://companyname.jfrog.io/artifactory/repo-name-local/.

I expect these three PowerShell commands to execute successfully:

# Start with a clean nuget.config
git checkout nuget.config
# Add package source, username, password
.\nuget.exe sources add -name "Artifactory" -source https://companyname.jfrog.io/artifactory/api/nuget/repo-name-local/ -username foo -password bar -configfile .\nuget.config
# Restore packages
.\nuget.exe restore -Source "https://companyname.jfrog.io/artifactory/api/nuget/repo-name-local/;https://www.nuget.org/api/v2" -ConfigFile .\nuget.config -Verbosity detailed .\Something\Something.sln

The first two commands execute successfully, but the third one gives this response:

WARNING: Unable to find version '31.3.0.1035' of package 'GemBox.Spreadsheet'.
  C:\Users\rdepew\.nuget\packages\: Package 'GemBox.Spreadsheet.31.3.0.1035' is not found on source 'C:\Users\rdepew\.nuget\packages\'.
  https://companyname.jfrog.io/artifactory/api/nuget/repo-name-local/: Package 'GemBox.Spreadsheet.31.3.0.1035' is not found on source 'https://companyname.jfrog.io/artifactory/api/nuget/repo-name-local/'.
  https://www.nuget.org/api/v2: Package 'GemBox.Spreadsheet.31.3.0.1035' is not found on source 'https://www.nuget.org/api/v2'.
  

I thought that the modified URL was required, but maybe it wasn't. So I change the commands a bit:

# Start with a clean nuget.config
git checkout nuget.config
# Add package source, username, password
.\nuget.exe sources add -name "Artifactory" -source https://companyname.jfrog.io/artifactory/repo-name-local/ -username foo -password bar -configfile .\nuget.config
# Restore packages
.\nuget.exe restore -Source "https://companyname.jfrog.io/artifactory/repo-name-local/;https://www.nuget.org/api/v2" -ConfigFile .\nuget.config -Verbosity detailed .\Something\Something.sln

The response is slightly different, but still not successful:

WARNING: Unable to find version '31.3.0.1035' of package 'GemBox.Spreadsheet'.
  C:\Users\rdepew\.nuget\packages\: Package 'GemBox.Spreadsheet.31.3.0.1035' is not found on source 'C:\Users\rdepew\.nuget\packages\'.
  https://companyname.jfrog.io/artifactory/repo-name-local/: Failed to fetch results from V2 feed at 'https://companyname.jfrog.io/artifactory/repo-name-local/FindPackagesById()?id='GemBox.Spreadsheet'&semVerLevel=2.0.0' with following message : Response status code does not indicate success: 404 (Not Found).
  Response status code does not indicate success: 404 (Not Found).
  https://www.nuget.org/api/v2: Package 'GemBox.Spreadsheet.31.3.0.1035' is not found on source 'https://www.nuget.org/api/v2'.

Why are both nuget restore commands failing? Why can't they see the repository contents?


Solution

  • I hit a similar issue. I resolved it by enabling the 'force authentication' option for the NuGet repository.

    NuGet Settings