sdk icon indicating copy to clipboard operation
sdk copied to clipboard

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

Open aaronwjha opened this issue 1 year ago • 24 comments

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

aaronwjha avatar Oct 23 '23 16:10 aaronwjha

@dsplaisted

michaelgsharp avatar Oct 25 '23 20:10 michaelgsharp

@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.

dsplaisted avatar Oct 25 '23 20:10 dsplaisted

Still an issue with 8.0.100 release.

frederikstonge avatar Nov 14 '23 21:11 frederikstonge

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

image

ricardoMTC avatar Nov 15 '23 17:11 ricardoMTC

Hi!

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

ChristoWolf avatar Nov 16 '23 07:11 ChristoWolf

same here, any workaround?

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

PaulVrugt avatar Nov 16 '23 08:11 PaulVrugt

@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.

ChristoWolf avatar Nov 16 '23 21:11 ChristoWolf

@ChristoWolf yes thank you, I found a similar workaround

PaulVrugt avatar Nov 17 '23 07:11 PaulVrugt

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.

ChristoWolf avatar Nov 17 '23 09:11 ChristoWolf

Any update on this issue?

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

marci4 avatar Nov 28 '23 06:11 marci4

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...

hannahbellelee avatar Nov 28 '23 18:11 hannahbellelee

@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 avatar Nov 28 '23 18:11 ChristoWolf

Hi @JL03-Yue!

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

ChristoWolf avatar Dec 15 '23 09:12 ChristoWolf

Just wanna confirm that this is still an issue with 8.0.101

marci4 avatar Jan 10 '24 07:01 marci4

Still an issue :(

ricardomomm avatar Jan 11 '24 17:01 ricardomomm

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

frederikstonge avatar Jan 11 '24 17:01 frederikstonge

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?

wexman avatar Jan 24 '24 14:01 wexman

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 :)

mcallaghan-geotab avatar Jan 24 '24 14:01 mcallaghan-geotab

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.

baronfel avatar Jan 24 '24 14:01 baronfel

Also experiencing this issue

jabaker88 avatar Feb 15 '24 00:02 jabaker88

@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 avatar Feb 15 '24 20:02 hannahbellelee

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.

hannahbellelee avatar Feb 15 '24 20:02 hannahbellelee

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>

byronbayer avatar Feb 22 '24 22:02 byronbayer

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 '[email protected]' -Password 'YUR_TELERIK_PW'

hannahbellesheart avatar Mar 05 '24 15:03 hannahbellesheart

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)

epenet avatar Mar 26 '24 13:03 epenet

Still bugged in SDK 8.0.203 afbeelding

reijerh avatar Apr 03 '24 14:04 reijerh