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

Unable to restore NuGet packages from a private source over the CLI. #654

Open
jbvirt opened this issue Jun 7, 2024 · 2 comments
Open

Comments

@jbvirt
Copy link

jbvirt commented Jun 7, 2024

Description

We have added our private GitHub Enterprise repository and its ApiKey to Assets/NuGet.config.
We have no issues restoring from a private repository in Unity itself.
However, when we try to restore the package using the CLI we get the following error:

Unable to retrieve package from http://www.nuget.org/api/v2/Packages(Id='Private.Package',Version='1.0.0')
System.Net.WebException: The remote server returned an error: (404) Not Found.
   at System.Net.HttpWebRequest.GetResponse()
   at NugetForUnity.Helper.WebRequestHelper.RequestUrl(String url, String userName, String password, Nullable`1 timeOut) in /_/src/NuGetForUnity/Editor/Helper/WebRequestHelper.cs:line 57
   at NugetForUnity.PackageSource.NugetPackageSourceV2.GetPackagesFromUrl(String url) in /_/src/NuGetForUnity/Editor/PackageSource/NugetPackageSourceV2.cs:line 465
   at NugetForUnity.PackageSource.NugetPackageSourceV2.GetSpecificPackage(INugetPackageIdentifier package) in /_/src/NuGetForUnity/Editor/PackageSource/NugetPackageSourceV2.cs:line 187

This seems to indicate that it is trying to use the default source, and is not looking at the NuGet.config.

  • NuGet Package: It's private. Assume 'Private.Package'
  • NuGetForUnity Version: A recent git hash: 12574c32f658fa23c194357141abc3fc157ea362 CLI version 4.1.1
  • Unity Version: 2022.3.2.f1
  • Operating System: mcr.microsoft.com/dotnet/sdk:8.0 container. So Ubuntu.

Also, there is a typo in your issue template. (enabeling when it should be enabling)

@JoC0de
Copy link
Collaborator

JoC0de commented Jun 16, 2024

Hi @jbvirt
Thanks for creating the issue.
Seems strange, are you running the Command from the correct location or specified the correct project path. The error shows that it uses the V2 API witch is not the default, so there need to be a NuGet.config file that is used instead of the one with your own config.
If could also relate to not using the latest version of the CLI.

@jbvirt
Copy link
Author

jbvirt commented Jun 17, 2024

We use the command nugetforunity restore ".".
This command worked perfectly fine before we added the private NuGet package.
The CLI version is the latest, version 4.1.1.

However, updating to the V3 API solved the issue.
Feel free to close this issue, or leave it open and investigate the V2 API behavior.

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

No branches or pull requests

2 participants