简体   繁体   中英

Visual Studio 2019 can not get nuget packages

I wonder is there a way to make VS 2019 work with nuget repositories? Usually it works fine, but sometimes occurs the following. I pushed a package into my nexus enterprise repository, waited a while (package is already in repo), than opened a.csproj file and entered pushed version. VS cannot load a package with error

Failed to retrieve information about '%packagename' from remote source 'https://nexus****/repository/nuget-group/FindPackagesById()?id='%packagename'&semVerLevel=2.0.0'.

Of course, if a copy the link to browser, it opens ok. I do have access to both nexus and nuget.org, but VS cannot get any package from them - neither through.csproj nor Nuget Manager UI is VS!

Restart machine doesn't matters. dotnet restore also produces the error. The only thing helpful is to install VS update through the VS Installer. Today I already installed an update, so I can't do this now.

Is there any way to make this work?

You could try to use nuget.exe to register the source in your machine.

nuget.exe sources Add -Name "source" -Source {Path to the package(s) source}

Then re-start your visual studio.

I looked at Package Manager Output and saw that sometimes a message appeared. The message was someting like 'cannot connect to host because it reject or already has a connection error at xxx.xxx.xxx.xxx'. (My dirty translate from Russian)

But the point is: this IP is neither nexus host nor any intermediate host. I found that is was our old enterprise proxy (because the new one had no access to nuget.org), which is obsolete and unsupported. So, I just deleted proxy section from %APPDATA%/Roaming/Nuget/Nuget.config and at least local nexus became always available for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM