templating icon indicating copy to clipboard operation
templating copied to clipboard

Support --interactive for templates behind private nuget feed

Open wli3 opened this issue 7 years ago • 21 comments

  1. For dotnet new -i. To use install a template behind private nuget feed the user cannot specify nuget feed in the command line . The user need to set the nuget feed in the global nuget config.

  2. After adding a private nuget feed, if the feed need auth. The user will see the following error

/Users/williamli/Documents/cli/artifacts/tmp/Debug/dotnet/sdk/3.0.100-preview-009752/NuGet.targets(114,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` [/Users/williamli/.templateengine/dotnetcli/v3.0.100-preview-009752/scratch/restore.csproj]

However, --interactive command is not available for dotnet new

To repro add my private feed to ~/.nuget/NuGet/NuGet.Config

<add key="testingnugetauth" value="https://williamleewul.pkgs.visualstudio.com/_packaging/testingnugetauth/nuget/v3/index.json" />

And run dotnet new -i wul.DotNet.Common.ItemTemplates

  1. If the template uses a private package in another feed. The restore will fail due to no --interactive is passed to subsequence restore.

related to https://github.com/dotnet/templating/issues/1545 but now we have --interactive

wli3 avatar Jan 24 '19 01:01 wli3

@wli3 if no auth is needed, the --nuget-source allows you to specify an alternate feed to use

mlorbetske avatar Jan 24 '19 23:01 mlorbetske

@mlorbetske your answer clears up #1.

For #2 and 3, we've done work in the CLI to improve the authentication experience for NuGet private feeds. We'd like to see this added to dotnet new as well. The interactive switch is needed both to access the feed with the template (#2) and the restore if it uses any packages that come from a different feed and that feed needs authentication #3

KathleenDollard avatar Jan 25 '19 01:01 KathleenDollard

@KathleenDollard understood, I was only commenting with regard to the first item. We'll schedule the work to pass the --interactive switch in the internal calls to restore

mlorbetske avatar Jan 28 '19 17:01 mlorbetske

Is there any documentation on this new --interactive flag or can anyone clear up for me if this will help with #1545 ?

panmona avatar Feb 19 '19 22:02 panmona

Any update on this issue?

wli3 avatar Apr 01 '19 22:04 wli3

No update at this point.

seancpeters avatar Apr 01 '19 23:04 seancpeters

Any update on this issue?

allysonjoses avatar Oct 04 '19 19:10 allysonjoses

Any update? This prevents using custom templates in DevOps artifacts feeds.

anderly avatar Apr 08 '20 18:04 anderly

@anderly meanwhile you could run any other command that supports --interactive first to the authorized

wli3 avatar Apr 08 '20 18:04 wli3

@wli3 which command can I run that supports --interactive if I'm running in a directory that has no sln or project?

anderly avatar Apr 08 '20 18:04 anderly

@nkolev92 I remember there is a command just to get authorized

wli3 avatar Apr 08 '20 18:04 wli3

Unfortunately we don't have any commands that will just authorize. You have add something like restore/add package that absolutely requires a remote feed.

nkolev92 avatar Apr 08 '20 18:04 nkolev92

@nkolev92 @wli3 ok. gonna try to publish the templates package to a file-shared based nuget source instead until this is supported.

anderly avatar Apr 08 '20 18:04 anderly

@grinrag greetings. Based on recent traffic we should move up the priority list. Please bring it up in the next triage.

donJoseLuis avatar Apr 15 '20 09:04 donJoseLuis

I don't know if this will help anyone, but I ended up on this page after searching for a way to install dotnet new templates from a nuget package in a feed that requires user credentials. I found the way to do that without requiring an --interactive switch. First add the nuget source with your credentials nuget source Add -Name "<name>" -Source "<your nuget source>" -UserName <your username> -Password <your password> And then templates can be installed from that source dotnet new -i <your template package name> --nuget-source <your nuget source>

If this is not what everyone else is trying to do, sorry for the misunderstanding.

npuc85 avatar Apr 20 '20 14:04 npuc85

@npuc85 was this for on-prem or cloud devops? I can't seem to get it to work with cloud devops.

anderly avatar Apr 22 '20 15:04 anderly

Something like that works for us:

  1. Download the Credentials Provider installation script - link

  2. Open the PowerShell console and run the installation script with the -AddNetfx switch

    .\installcredprovider.ps1 -AddNetfx
    
  3. Navigate to %userprofile%\.nuget\plugins\netfx\CredentialProvider.Microsoft and open Command Prompt there.

  4. Run the following command:

    CredentialProvider.Microsoft.exe -U <your nuget source>
    
  5. Follow the instructions printed to the console window: Open microsoft.com/devicelogin, enter the code and login to the account.

  6. Run the following command to install the template to your dotnet cli templates:

    dotnet new -i <template name> --nuget-source <your nuget source>
    

Hope this will help :)

Boruc04 avatar Apr 23 '20 17:04 Boruc04

@Boruc04 thanks for the steps! That works!

anderly avatar Apr 27 '20 16:04 anderly

@Boruc04 thanks for this, we were having trouble with this via our Azure DevOps feed.

Shmew avatar May 02 '20 14:05 Shmew

I don't know if this will help anyone, but I ended up on this page after searching for a way to install dotnet new templates from a nuget package in a feed that requires user credentials. I found the way to do that without requiring an --interactive switch. First add the nuget source with your credentials nuget source Add -Name "<name>" -Source "<your nuget source>" -UserName <your username> -Password <your password> And then templates can be installed from that source dotnet new -i <your template package name> --nuget-source <your nuget source>

If this is not what everyone else is trying to do, sorry for the misunderstanding.

Thanks, I created a PAT and this worked for me. I hope this --interactive option will be available soon, so we don't have to create PATs

albertocorrales avatar Aug 02 '20 08:08 albertocorrales