dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.65k stars 1.05k forks source link

.NET 8 RC2 does not honor ignore-failed-sources flag when running dotnet tool install #36473

Open aaronwjha opened 10 months ago

aaronwjha commented 10 months ago

When installing dotnet tools with a configured nuget source that fails to load, the --ignore-failed-sources flag is not honored.

Description

PS C:\Users\***\source\repos\jhld_reporting_templates> dotnet tool install JackHenry.Report.Fake --add-source "c:\Users\***\downloads" --global --ignore-failed-sources --verbosity diag 
[NuGet Manager] [Info]   GET https://api.nuget.org/v3/registration5-gz-semver2/jackhenry.report.fake/index.json
[NuGet Manager] [Info]   NotFound https://api.nuget.org/v3/registration5-gz-semver2/jackhenry.report.fake/index.json 61ms
[NuGet Manager] [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`
[NuGet Manager] [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`
[NuGet Manager] [Info]   GET https://***.com/artifactory/api/nuget/v3/nuget/FindPackagesById()?id='jackhenry.report.fake'&semVerLevel=2.0.0
[NuGet Manager] [Info]   Unauthorized https://***.com/artifactory/api/nuget/v3/nuget/FindPackagesById()?id='jackhenry.report.fake'&semVerLevel=2.0.0 107ms
Unhandled exception: NuGet.Protocol.Core.Types.FatalProtocolException: Unable to load the service index for source https://pkgs.dev.azure.com/*****/nuget/v3/index.json.
 ---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 401 (Unauthorized).
   at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
   at NuGet.Protocol.HttpSource.<>c__DisplayClass15_0`1.<<GetAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at NuGet.Common.ConcurrencyUtilities.ExecuteWithFileLockedAsync[T](String filePath, Func`2 action, CancellationToken token)
   at NuGet.Common.ConcurrencyUtilities.ExecuteWithFileLockedAsync[T](String filePath, Func`2 action, CancellationToken token)
   at NuGet.Protocol.HttpSource.GetAsync[T](HttpSourceCachedRequest request, Func`2 processAsync, ILogger log, CancellationToken token)     
   at NuGet.Protocol.ServiceIndexResourceV3Provider.GetServiceIndexResourceV3(SourceRepository source, DateTime utcNow, ILogger log, CancellationToken token)
   --- End of inner exception stack trace ---
   at NuGet.Protocol.ServiceIndexResourceV3Provider.GetServiceIndexResourceV3(SourceRepository source, DateTime utcNow, ILogger log, CancellationToken token)
   at NuGet.Protocol.ServiceIndexResourceV3Provider.TryCreate(SourceRepository source, CancellationToken token)
   at NuGet.Protocol.Core.Types.SourceRepository.GetResourceAsync[T](CancellationToken token)
   at NuGet.Protocol.PackageMetadataResourceV3Provider.TryCreate(SourceRepository source, CancellationToken token)
   at NuGet.Protocol.Core.Types.SourceRepository.GetResourceAsync[T](CancellationToken token)
   at Microsoft.DotNet.Cli.NuGetPackageDownloader.NuGetPackageDownloader.GetPackageMetadataAsync(PackageSource source, String packageIdentifier, Boolean includePrerelease, CancellationToken cancellationToken)
   at Microsoft.DotNet.Cli.NuGetPackageDownloader.NuGetPackageDownloader.GetMatchingVersionInternalAsync(String packageIdentifier, IEnumerable`1 packageSources, VersionRange versionRange, CancellationToken cancellationToken)
   at Microsoft.DotNet.Cli.NuGetPackageDownloader.NuGetPackageDownloader.GetBestPackageVersionAsync(PackageId packageId, VersionRange versionRange, PackageSourceLocation packageSourceLocation)
   at Microsoft.DotNet.Cli.ToolPackage.ToolPackageDownloader.<>c__DisplayClass8_0.<InstallPackage>b__0()
   at Microsoft.DotNet.Cli.TransactionalAction.Run[T](Func`1 action, Action commit, Action rollback)
   at Microsoft.DotNet.Tools.Tool.Install.ToolInstallGlobalOrToolPathCommand.Execute()
   at System.CommandLine.Invocation.InvocationPipeline.Invoke(ParseResult parseResult)
   at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, TimeSpan startupTime, ITelemetry telemetryClient)

Configuration

.NET 8 RC2 Windows 10 Ent, x64

Regression?

This works properly with .NET 7

michaelgsharp commented 10 months ago

@dsplaisted

dsplaisted commented 10 months ago

@JL03-Yue This is probably because the RestoreActionConfig isn't being created correctly based on the command line options. I think we recently looked at another similar bug with the NoCache option.

frederikstonge commented 9 months ago

Still an issue with 8.0.100 release.

ricardoMTC commented 9 months ago

I normally would use the --ignore-failed-sources but I'm also getting some errors upon using it. Also using 8.0.100

image

ChristoWolf commented 9 months ago

Hi!

Chiming in to say that I am also observing the same issue.

PaulVrugt commented 9 months ago

same here, any workaround?

This issue is breaking our build pipeline, so we are unable to migrate to .net 8 SDK

ChristoWolf commented 9 months ago

@PaulVrugt: I think a work-around would be to create a basic Nuget.Config file only containing the nuget.org feed and to pass this then to the command.

PaulVrugt commented 9 months ago

@ChristoWolf yes thank you, I found a similar workaround

ChristoWolf commented 9 months ago

I also had time now to try out this work-around, works fine. Still, it would be great if this issue would be resolved as soon as possible.

marci4 commented 9 months ago

Any update on this issue?

Is there a way on how we can speed up the process here?

hannahbellelee commented 9 months ago

I tend to think this is an issue unrelated to .NET8 as a whole. I have been getting failures on dotnet tool install before I installed .NET8.. It first started showing up in Visual Studio Code in my powershell terminal, so I thought it was something specifically related to VSCode, but when I opened a terminal or a powershell window outside of VSCode Id get the same thing....And always with the telerik nuget package....And what I am installing has nothing to do with the telerik nuget package. image

I have been using a small workaround for months, because I thought this would get fixed eventually. So what I have to do is open:

C:\Users\dev007\AppData\Roaming\NuGet\NuGet.Config

And comment out the telerik key( I have 9 other keys in there and none of them cause an error except the telerik one):

<!-- <add key="Telerik NuGet" value="https://nuget.telerik.com/v3/index.json" /> -->

Save the file, then rerun

[dev007]$ dotnet tool install -g SOME_PACKAGE_TO_INSTALL

The install worked perfectly: image

but now the Nuget Source is not available in Visual Studio, so I have to open the file back up and uncomment it then save the file again...

ChristoWolf commented 9 months ago

@hannahbellelee: I think your problem is a bit different from the reported one here, correct me if I'm wrong.

The issue here is specifically caused by the newest .NET SDK.

ChristoWolf commented 8 months ago

Hi @JL03-Yue!

Has there been any progress? We have to use the work-around in quite a few places currently.

marci4 commented 7 months ago

Just wanna confirm that this is still an issue with 8.0.101

ricardomomm commented 7 months ago

Still an issue :(

frederikstonge commented 7 months ago

Here's my workaround. Create a nuget-tools.config :

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <!--To
    inherit the global NuGet package sources remove the <clear/> line below -->
    <clear />
    <add key="nuget" value="https://api.nuget.org/v3/index.json" />
  </packageSources>
</configuration>

Then use this :

dotnet tool install --global <package-name> --configfile nuget-tools.config
wexman commented 7 months ago

I'm kind of losing hope that this will be fixed, as it is still not working today. If you're going at it, how about fixing --interactive as well?

mcallaghan-geotab commented 7 months ago

If you're going at it, how about fixing --interactive as well?

^ that isn't how software works :) - ADDING scope makes it less likely to get fixed :)

baronfel commented 7 months ago

Just as a status update, this is one of a number of auth/feed related issues that we'll be looking at in the near term, but after the team finishes landing a few of their already-in-flight work items.

jabaker88 commented 6 months ago

Also experiencing this issue

hannahbellelee commented 6 months ago

@hannahbellelee: I think your problem is a bit different from the reported one here, correct me if I'm wrong.

The issue here is specifically caused by the newest .NET SDK.

No this was not specific to a new version. The same thing was happening before the update... But once I noticed it wasnt fixed with the update, i posted it...There are workarounds, but there really shouldnt have to be...

hannahbellelee commented 6 months ago

I went in to my Control Panel , into credential manager for windows, and updated any credentials for any nuget packages...then from an admin powershell reinstalled nuget...and nuget cli and after that things seemed to work which is very odd, but in any case... I will let you know if i get a chance to test again later.

byronbayer commented 6 months ago

yep this is still happening on our pipelines when trying to install ReportGenerator tool in the pipeline. Our workaround is to add the following to the nuget.config file

<disabledPackageSources>
        <add key="my-org-package-location" value="true" />
</disabledPackageSources>
hannahbellesheart commented 6 months ago

Everytime I ran into this, it always seemed to be related to the telerik feed AUTHENTICATION. I never get an error on the devexpress feed, which also requires authentication. or any other feed. So the only thing that has fixed this for me is the following...And when I say fixed, i mean I have not had a single error since running this. Of course replace the username and password with your own....

Open the Package Manager Console in VS2022. At the PM> prompt, use the following command. PM>NuGet Sources Update -Name 'Telerik NuGet' -Source 'https://nuget.telerik.com/v3/index.json' -UserName 'YURTLRK@EMAILADDY.COM' -Password 'YUR_TELERIK_PW'

epenet commented 5 months ago

For those who have this issue on CI / Azure Pipeline, and are looking for a workaround, I have found that it is possible to add a preliminary job in the configuration to force NuGet to authenticate against the Azure private feeds :

jobs:
  - job: Build
    steps:
      (...)

      # NuGet authenticate
      - task: NuGetAuthenticate@1

      # Install report generator
      - script: 'dotnet tool install -g dotnet-reportgenerator-globaltool --verbosity detailed --ignore-failed-sources'

With this workaround in place, the private feeds no longer fail, and --ignore-failed-sources becomes redundant.

Note: this was the previous error:

Generating script.
Script contents: shell
dotnet tool install -g dotnet-reportgenerator-globaltool --verbosity detailed --ignore-failed-sources
========================== Starting Command Output ===========================
"C:\Windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "D:\a\_temp\2cdd5da9-bb28-47ff-98de-70feab461169.cmd""
[NuGet Manager] [Info]   GET https://api.nuget.org/v3/registration5-gz-semver2/dotnet-reportgenerator-globaltool/index.json
[NuGet Manager] [Info]   GET https://pkgs.dev.azure.com/xxxxxxxxx/nuget/v3/registrations2-semver2/dotnet-reportgenerator-globaltool/index.json
[NuGet Manager] [Info]   Unauthorized https://pkgs.dev.azure.com/xxxxxxxxx/nuget/v3/registrations2-semver2/dotnet-reportgenerator-globaltool/index.json 53ms
[NuGet Manager] [Info]   OK https://api.nuget.org/v3/registration5-gz-semver2/dotnet-reportgenerator-globaltool/index.json 134ms
[NuGet Manager] [Info]   GET https://api.nuget.org/v3/registration5-gz-semver2/dotnet-reportgenerator-globaltool/page/4.0.0-alpha10/4.2.16.json
[NuGet Manager] [Info]   OK https://api.nuget.org/v3/registration5-gz-semver2/dotnet-reportgenerator-globaltool/page/4.0.0-alpha10/4.2.16.json 104ms
[NuGet Manager] [Info]   GET https://api.nuget.org/v3/registration5-gz-semver2/dotnet-reportgenerator-globaltool/page/4.2.17/5.1.1.json
[NuGet Manager] [Info]   OK https://api.nuget.org/v3/registration5-gz-semver2/dotnet-reportgenerator-globaltool/page/4.2.17/5.1.1.json 104ms
[NuGet Manager] [Info]   GET https://api.nuget.org/v3/registration5-gz-semver2/dotnet-reportgenerator-globaltool/page/5.1.2/5.2.4.json
[NuGet Manager] [Info]   OK https://api.nuget.org/v3/registration5-gz-semver2/dotnet-reportgenerator-globaltool/page/5.1.2/5.2.4.json 103ms
Unhandled exception: System.Net.Http.HttpRequestException: Response status code does not indicate success: 401 (Unauthorized).
   at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
   at NuGet.Protocol.HttpSource.<>c__DisplayClass15_0`1.<<GetAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at NuGet.Common.ConcurrencyUtilities.ExecuteWithFileLockedAsync[T](String filePath, Func`2 action, CancellationToken token)
   at NuGet.Common.ConcurrencyUtilities.ExecuteWithFileLockedAsync[T](String filePath, Func`2 action, CancellationToken token)
   at NuGet.Protocol.HttpSource.GetAsync[T](HttpSourceCachedRequest request, Func`2 processAsync, ILogger log, CancellationToken token)
   at NuGet.Protocol.PackageMetadataResourceV3.LoadRegistrationIndexAsync(HttpSource httpSource, Uri registrationUri, String packageId, SourceCacheContext cacheContext, Func`2 processAsync, ILogger log, CancellationToken token)
   at NuGet.Protocol.PackageMetadataResourceV3.GetMetadataAsync(String packageId, Boolean includePrerelease, Boolean includeUnlisted, VersionRange range, SourceCacheContext sourceCacheContext, ILogger log, CancellationToken token)
   at NuGet.Protocol.PackageMetadataResourceV3.GetMetadataAsync(String packageId, Boolean includePrerelease, Boolean includeUnlisted, SourceCacheContext sourceCacheContext, ILogger log, CancellationToken token)
   at Microsoft.DotNet.Cli.NuGetPackageDownloader.NuGetPackageDownloader.GetPackageMetadataAsync(PackageSource source, String packageIdentifier, Boolean includePrerelease, Boolean includeUnlisted, CancellationToken cancellationToken)
   at Microsoft.DotNet.Cli.NuGetPackageDownloader.NuGetPackageDownloader.GetMatchingVersionInternalAsync(String packageIdentifier, IEnumerable`1 packageSources, VersionRange versionRange, CancellationToken cancellationToken)
   at Microsoft.DotNet.Cli.NuGetPackageDownloader.NuGetPackageDownloader.GetBestPackageVersionAsync(PackageId packageId, VersionRange versionRange, PackageSourceLocation packageSourceLocation)
   at Microsoft.DotNet.Cli.ToolPackage.ToolPackageDownloader.<>c__DisplayClass8_0.<InstallPackage>b__0()
   at Microsoft.DotNet.Cli.TransactionalAction.Run[T](Func`1 action, Action commit, Action rollback)
   at Microsoft.DotNet.Tools.Tool.Install.ToolInstallGlobalOrToolPathCommand.<>c__DisplayClass19_0.<Execute>b__1()
   at Microsoft.DotNet.Tools.Tool.Install.ToolInstallGlobalOrToolPathCommand.RunWithHandlingInstallError(Action installAction)
   at Microsoft.DotNet.Tools.Tool.Install.ToolInstallGlobalOrToolPathCommand.Execute()
   at System.CommandLine.Invocation.InvocationPipeline.Invoke(ParseResult parseResult)
   at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, TimeSpan startupTime, ITelemetry telemetryClient)
reijerh commented 5 months ago

Still bugged in SDK 8.0.203 afbeelding