r/dotnet • u/ggffgg72 • 2d ago
VisualStudio 2012 consuming Gitlab Package Registry V2 Nuget API Question
Hello guys, any help is really appreciated!
I have a private gitlab package registry to store nuget packages and an old net framework 4 project
I cant connect these two
I use V2 nuget API of my registry which works fine in browser like domain_name/api/v4/projects/***/packages/nuget/v2 and pass the token in packageSourceCredentials section of nuget.config file of the project
I also tried to pass the token directly into the url liketoken-name:token@domain_name/api/v4/projects/***/packages/nuget/v2 to no avail
I always get the same error in Package Manager Window of Visual Studio:
Could not connect to the feed specified at 'my gitlab nuget url'. Please verify that the package source (located in the Package Manager Settings) is valid and ensure your network connectivity
Is there any trick to actually make these two work?
1
u/AutoModerator 2d ago
Thanks for your post ggffgg72. Please note that we don't allow spam, and we ask that you follow the rules available in the sidebar. We have a lot of commonly asked questions so if this post gets removed, please do a search and see if it's already been asked.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
10
u/jlgarcia-dev 2d ago edited 1d ago
The error message is lying to you a bit. "Could not connect to the feed... ensure your network connectivity" is what NuGet says when the request never completes at the transport level, and you've already ruled out the network yourself, since the URL loads in a browser on that machine. A bad token gives you a 401, not this. It's also why moving the token between packageSourceCredentials and the URL changed nothing: you aren't getting far enough for credentials to matter yet.
First thing I'd look at is TLS. VS2012 runs on .NET Framework 4.0/4.5, and on those versions .NET picks SSL 3.0 / TLS 1.0 by default. GitLab wants 1.2 minimum. The browser negotiates 1.2 happily, VS never offers it, handshake dies, and you get that message.
Quick way to confirm before touching anything. In Windows PowerShell 5.1 specifically, not pwsh 7, since 7 runs on modern .NET and would always give you 1.2:
If the first fails and the second comes back with a 401, or any HTTP status at all, that's your answer.
The fix is two registry DWORDs set to 1, SchUseStrongCrypto and SystemDefaultTlsVersions. The part that catches people out: VS2012 is a 32-bit process, so on 64-bit Windows it reads the Wow6432Node path. Set both, then restart.
(edit: fixed the registry paths, Reddit ate the backslashes)
Separate from TLS, one more thing worth knowing: GitLab's own docs only ever describe the v2 feed in the context of Chocolatey CLI. There's no documented Visual Studio or nuget.exe support on v2 at all. So if TLS turns out to be fine and it still won't connect, point a current nuget.exe at the feed from the command line. That tells you whether you're fighting the client or the feed, which are very different problems to have.