How to authenticate to GitLab package repository in Visual Studio

We have a self-hosted GitLab instance. I’ve created a project with a package registry and I’m successfully deploying packages to the registrying using CI/CD and deploy tokens.

However, I want to be able to add the package registry as a NuGet package source in Visual Studio 2022. Using the VS GUI I’ve added the source, and when I save it I’m prompted for my credentials. When I enter the same username and password as I use to login to out GitLab instance I get a 401: Unauthorised response. I’ve tried every variation of my username and our domain name that I can think of, but nothing works.

How do I authenticate to the package registry in Visual Studio using my username and password?

You need to use Token (any kind) instead of password. More details can be found in docs

1 Like

Thank you. I’d tried a token but I couldn’t work out what username to use. Using my own username worked as expected. I’d also read that documentation but, as I often find with GitLab documentation, it seems to be spread across multiple articles and it’s to get lost in it all!