question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dotnet new -i templates --nuget-source does not support --interactive auth

See original GitHub issue

Hi,

dotnet sdk version 3.1.100

Attempting to install dotnet CLI templates from a secured Azure Artifacts NuGet repository does not seem to be working. The command correctly outputs that an --interactive authentication flow may be required. However, the dotnet new -i command does not actually support the --interactive flag.

Using the same repository, csproj dependencies can be restored via the CLI. See below for command output.

dotnet new -i Test.Templates --nuget-source https://privatesource.pkgs.visualstudio.com/_packaging/Test/nuget/v3/index.json

C:\Program Files\dotnet\sdk\3.1.100\NuGet.targets(123,5): warning : The plugin credential provider could not acquire credentials. Authentication may require manual action. Consider re-running the command with --interactive for `dotnet`, /p:NuGetInteractive="true" for MSBuild or removing the -NonInteractive switch for `NuGet` [C:\Users\Greg\.templateengine\dotnetcli\v3.1.100\scratch\restore.csproj]

C:\Program Files\dotnet\sdk\3.1.100\NuGet.targets(123,5): error : Unable to load the service index for source https://privatesource.pkgs.visualstudio.com/_packaging/Test/nuget/v3/index.json. [C:\Users\Greg\.templateengine\dotnetcli\v3.1.100\scratch\restore.csproj]

C:\Program Files\dotnet\sdk\3.1.100\NuGet.targets(123,5): error :   Response status code does not indicate success: 401 (Unauthorized). [C:\Users\Greg\.templateengine\dotnetcli\v3.1.100\scratch\restore.csproj]

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
viliketcommented, May 21, 2021

@vlada-shubina Thanks, installing the artifacts-credprovider with the command iex "& { $(irm https://aka.ms/install-artifacts-credprovider.ps1) }" followed by dotnet new -i <package name> --nuget-source <Azure Artifacts package source> --interactive works.

You may close the issue now.

0reactions
vlada-shubinacommented, May 20, 2021

@viliket

Until .NET 6 Preview 4 dotnet new was running dotnet restore to install the packages, that’s why #2276 mentions it. To use --interactive flag, you still need to install credential provider, as mentioned in #1747 (first 2 steps, without -netfx option)

I’ve tested it on 5.0.201, and it works for me - see below:

C:\Users\WDAGUtilityAccount> dotnet --list-sdks
5.0.201 [C:\Program Files\dotnet\sdk]


C:\Users\WDAGUtilityAccount> dotnet new --install Microsoft.DotNet.Web.Spa.ProjectTemplates.6.0::6.0.0-preview.3.21201.13 --nuget-source <my nuget feed>
  Determining projects to restore...
C:\Program Files\dotnet\sdk\5.0.201\NuGet.targets(131,5): warning : The plugin credential provider could not acquire credentials. Authentication may require manual action. Consider re-running the command with --interactive for `dotnet`, /p:NuGetInteractive="true" for MSBuild or removing the -NonInteractive switch for `NuGet` [C:\Users\WDAGUtilityAccount\.templateengine\dotnetcli\v5.0.201\scratch\restore.csproj]
C:\Program Files\dotnet\sdk\5.0.201\NuGet.targets(131,5): error : Unable to load the service index for source <my nuget feed>[C:\Users\WDAGUtilityAccount\.templateengine\dotnetcli\v5.0.201\scratch\restore.csproj]
C:\Program Files\dotnet\sdk\5.0.201\NuGet.targets(131,5): error :   Response status code does not indicate success: 401 (Unauthorized). [C:\Users\WDAGUtilityAccount\.templateengine\dotnetcli\v5.0.201\scratch\restore.csproj]
Templates                                     Short Name           Language    Tags
--------------------------------------------  -------------------  ----------  ----------------------
Console Application                           console              [C#],F#,VB  Common/Console
Class library                                 classlib             [C#],F#,VB  Common/Library
<output cut>

C:\Users\WDAGUtilityAccount> dotnet new --install Microsoft.DotNet.Web.Spa.ProjectTemplates.6.0::6.0.0-preview.3.21201.13 --nuget-source  <my nuget feed> --interactive
  Determining projects to restore...
      [CredentialProvider]DeviceFlow:  <my nuget feed> 
      [CredentialProvider]ATTENTION: User interaction required.

      **********************************************************************

      To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code <code> to authenticate.

      **********************************************************************

I need more information to see what might be wrong for your case. Could you please try to run dotnet restore <csproj> --source <your source> --packages .\ --interactive for the csproj file shim attached and check if it is successful? In csproj shim please replace placeholders with name and version of the package you are trying to install.

This will be exactly the same action dotnet new is running to install the packages, but might give more information on the errors, especially in verbose mode.

Thanks. shim.zip

(I will keep issue open to receive notifications)

Read more comments on GitHub >

github_iconTop Results From Across the Web

dotnet new install - .NET CLI
The dotnet new install command installs a template package. ... If --nuget-source is specified, the source will be added to the list of ......
Read more >
Installing dotnet new template not working from NuGet ...
I have a template which is packaged and deployed to an Azure Devops NuGet Feed. I can't install this template when I use...
Read more >
How to Create Your .NET Project Template
This article will focus on project templates, that is, templates that allow you to create a new project with specific features. While in...
Read more >
Dotnet restore vs nuget restore. Share. In my code repo, there
We tried upgrading the NuGet version but it did not help. exe to the windows path ... Running dotnet restore --interactive should prompt...
Read more >
How to send .Net Core NuGet packages to Azure Artifacts
Without this parameter, the command won't work. dotnet nuget push .\bin\Debug\NugetPackage.1.0.0.nupkg --source "MeuFeed" --api-key teste --interactive.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found