Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"dotnet restore --interactive" doesn't work with Azure Artifacts

I have a newly installed Windows 10 machine with the .NET Core SDK 3.0.100. I have a project with it's nuget.config file containing (among other reference) a reference to an Azure Artifacts nuget feed, and i'd like to access credentials to this feed interactively. It's worth to point out that i'd like to use command line to achieve this. My IDE of choice is Jetbrains Rider and not Visual Studio (for this particular question i'm not sure that matters though).

I have downloaded the Azure Artifacts Credential Provider by running a powershell command (Invoke-WebRequest...) and installed it - what seems - successfully. Now I have a nuget plugin on my computer that's supposed to help me retrieve credentials for azure artifact feeds.

What i do expect to work is that running dotnet restore --interactive should prompt me to enter credentials, but it doesnt. It doesnt prompt at all, and just complains that it cannot find the packages.

I've tried this other times too, both on MacOS and Windows with my colleagues, and it always seem to be some problems related to this. Any ideas what i'm doing wrong?

Thanks for your help!

like image 652
Jim Aho Avatar asked Oct 29 '19 09:10

Jim Aho


People also ask

What is the difference between NuGet restore and dotnet restore?

nuget restore will ensure all of your NuGet dependencies are downloaded and available to your project. Whereas dotnet restore is a complete restoration of all NuGet dependencies as well as references and project specific tools. Meaning that if you run nuget restore , you are only restoring NuGet packages.

Is dotnet restore necessary?

In most cases, you don't need to explicitly use the dotnet restore command, since a NuGet restore is run implicitly if necessary when you run the following commands: dotnet new. dotnet build. dotnet build-server.

How do I install Azure artifact credential provider?

Select Artifacts and then select your feed. Select Connect to feed. Select NuGet.exe from the left panel. If this is your first time using Azure Artifacts with NuGet.exe, select Get the tools in the top-right corner and follow the instructions to download and install NuGet and Azure Artifacts Credential Provider.

How to use DotNet with azure artifacts NuGet feeds?

To use dotnet with Azure Artifacts NuGet feeds, use the cross-platform Azure Artifacts Credential Provider. On build machines and in non-interactive scenarios. In Azure Pipelines, use the .NET Core step's restore command, which automatically handles authentication to Azure Artifacts feeds.

Is it possible to use--interactive with Azure DevOps artifacts?

However, since the decision was to not allow dotnet restore --interactive to prompt for credentials, it'd be helpful if Azure Devops Artifacts (and preferably dotnet.exe too) was a little more clear on the fact that the only way to use --interactive with ADO is to install this credential provider plugin.

Does DotNet restore--interactive work with code Auth?

Running dotnet restore --interactive should prompt for code auth, like it does on macOS. Alternatively, running dotnet restore should behave like nuget restore does, and prompt for credentials allowing you to enter a PAT.

How do I restore NuGet packages from Azure artifacts?

Restore packages with NuGet restore build task To build a solution that relies on NuGet packages from Azure Artifacts feeds, we will want to add the NuGet build task to our pipeline. Navigate to your build pipeline and select Edit. Under Tasks, Agent job, select the plus sign "+" to add a new task.


1 Answers

I'll answer my own question as it might help someone else.

When I tried dotnet restore --configfile .\.nuget\NuGet.Config --interactive it did prompt me. I could login in and everything worked!

I'm not sure why, but it seems that just running dotnet restore --interactive doesn't pick the correct nuget sources - or at least not the ones I have defined in .\.nuget\NuGet.Config in my local project. And therefore the credential provider (obviously) won't prompt me for anything. I haven't found any details on whether this is the expected behaviour or a bug.

like image 166
Jim Aho Avatar answered Sep 28 '22 04:09

Jim Aho