We have a private NuGet
feed. It has been working well with Visual Studio
. Our developers connect through their Azure
account with the private feed. I'd like to keep this same functionality when moving to vs code.
Using the documentation found here I added a nuget.config to my solution folder. The config looks exactly like the documentation except it has our private feed there.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<!-- remove any machine-wide sources with <clear/> -->
<clear />
<!-- add an Azure Artifacts feed -->
<add key="PrivateFeed" value="https://pkgs.dev.azure.com/redacted/_packaging/redacted/nuget/v3/index.json" />
<!-- also get packages from the NuGet Gallery -->
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
</packageSources>
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
</configuration>
With Visual Studio
you simply have to log in and you can connect to the feed. Where is this option for vs code? I'm currently receiving the error messages below which is a good thing because obviously I'm not authenticated. I was expecting some kind of dialog to pop up or having to enter my credentials somewhere. The dotnet restore command also does not have any way of providing credentials as far as I'm aware.
C:\Program Files\dotnet\sdk\2.1.500\NuGet.targets(114,5): error : Unable to load the service index for source https://pkgs.dev.azure.com/redacted/_packaging/redacted/nuget/v3/index.json. [redacted]
C:\Program Files\dotnet\sdk\2.1.500\NuGet.targets(114,5): error : Response status code does not indicate success: 401 (Unauthorized). [redacted]
Some documentation also mentions putting credentials in the nuget.config
file but I find this very strange as this was never necessary with Visual Studio
and I also don't have a user I can just enter here. Surely creating a service account just for a private NuGet
is a step too far?
<packageSourceCredentials>
<Contoso>
<add key="Username" value="[email protected]" />
<add key="ClearTextPassword" value="33f!!lloppa" />
</Contoso>
</packageSourceCredentials>
How can I connect to a private NuGet
feed on Azure Devops
with vs code without saving credentials in a file?
Consume your private NuGet Feed Just copy your package source URL, go to Visual Studio, open the NuGet Package Manager, go to its settings and add a new source. Choose a fancy name, insert the source URL. Done.
We ended up using https://github.com/Microsoft/artifacts-credprovider for VS Code. It works really well. Just follow the steps to install the Microsoft.NuGet.CredentialProvider. Afterwards you should be able to restore the packages with the command "dotnet restore --interactive".
How can I connect to a private NuGet feed on Azure Devops with vs code without saving credentials in a file?
I am afraid you have to save the credentials in nuget.config
file at this moment.
When you log in Visual Studio and connect to the feed with credentials, Visual Studio will verify the credential and save it in the Visual Studio with login credentials:
But there is no such sign option for Visual Studio code. So, we have to put credentials in the nuget.config
file.
Besides, there is a user voice about it, you can vote and add your comments for this feedback. When there are enough communities vote and add comments for this feedback, the product team member will take this feedback seriously.:
Be able to use VSTS Package Manager with Visual Studio Code (VS Code)
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With