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.71k stars 1.07k forks source link

Run 'dotnet restore --interactive' against project with custom SDK from private nuget feed won't start authentication process #36824

Open yhvicey opened 12 months ago

yhvicey commented 12 months ago

Describe the bug

Run dotnet restore --interactive will not trigger authentication process when restoring projects with custom SDK from private NuGet feed.

To Reproduce

  1. Create a project with custom SDK (version specified in global.json):
    <Project Sdk="Microsoft.Build.Traversal"><!-- ... --></Project>
  2. Setup NuGet.config with private NuGet feed for project:
    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <packageSources>
        <clear />
        <add key="PrivateSource" value="PRIVATE_SOURCE_LINK" />
      </packageSources>
    </configuration>
  3. Run dotnet restore --interactive against this project

Exceptions (if any)

Retrying 'FindPackagesByIdAsync' for source '<PRIVATE_SOURCE_LINK>/nuget/v3/flat2/microsoft.build.traversal/index.json'.
Response status code does not indicate success: 401 (Unauthorized).
(Omit retry message)
<PROJECT_PATH> : error : Could not resolve SDK "Microsoft.Build.Traversal". Exactly one of the probing messages below indicates why we could not resolve the SDK. Investigate and resolve that message to correctly specify
 the SDK.
<PROJECT_PATH> : error :   SDK resolver "Microsoft.DotNet.MSBuildWorkloadSdkResolver" returned null.
<PROJECT_PATH> : error :   Unable to find package Microsoft.Build.Traversal. No packages exist with this id in source(s): PrivateSource
<PROJECT_PATH> : error :   MSB4276: The default SDK resolver failed to resolve SDK "Microsoft.Build.
Traversal" because directory "C:\Program Files\dotnet\sdk\8.0.100-rc.2.23502.2\Sdks\Microsoft.Build.Traversal\Sdk" did not exist.
<PROJECT_PATH> : warning : Failed to retrieve information about 'Microsoft.Build.Traversal' from remote source '<PRIVATE_SOURCE_LINK>/nuget/v3/flat2/microsoft.build.traversal/index.json'.
<PROJECT_PATH> : warning : Failed to retrieve information about 'Microsoft.Build.Traversal' from remote source '<PRIVATE_SOURCE_LINK>/nuget/v3/flat2/microsoft.build.traversal/index.json'.
<PROJECT_PATH> : error MSB4236: The SDK 'Microsoft.Build.Traversal' specified could not be found.

Further technical details

dotnet --info .NET SDK: Version: 8.0.100-rc.2.23502.2 Commit: 0abacfc2b6 Runtime Environment: OS Name: Windows OS Version: 10.0.22631 OS Platform: Windows RID: win-x64 Base Path: C:\Program Files\dotnet\sdk\8.0.100-rc.2.23502.2\ .NET workloads installed: [maui-windows] Installation Source: VS 17.7.34221.43, VS 17.8.34302.71 Manifest Version: 8.0.0-rc.2.9530/8.0.100-rc.2 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100-rc.2\microsoft.net.sdk.maui\8.0.0-rc.2.9530\WorkloadManifest.json Install Type: Msi [maui-maccatalyst] Installation Source: VS 17.7.34221.43 Manifest Version: 8.0.0-rc.2.9530/8.0.100-rc.2 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100-rc.2\microsoft.net.sdk.maui\8.0.0-rc.2.9530\WorkloadManifest.json Install Type: Msi [maccatalyst] Installation Source: VS 17.7.34221.43, VS 17.8.34302.71 Manifest Version: 17.0.8477-net8-rc2.2/8.0.100-rc.2 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100-rc.2\microsoft.net.sdk.maccatalyst\17.0.8477-net8-rc2.2\WorkloadManifest.json Install Type: Msi [maui-ios] Installation Source: VS 17.7.34221.43 Manifest Version: 8.0.0-rc.2.9530/8.0.100-rc.2 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100-rc.2\microsoft.net.sdk.maui\8.0.0-rc.2.9530\WorkloadManifest.json Install Type: Msi [ios] Installation Source: VS 17.7.34221.43, VS 17.8.34302.71 Manifest Version: 17.0.8477-net8-rc2.2/8.0.100-rc.2 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100-rc.2\microsoft.net.sdk.ios\17.0.8477-net8-rc2.2\WorkloadManifest.json Install Type: Msi [maui-android] Installation Source: VS 17.7.34221.43 Manifest Version: 8.0.0-rc.2.9530/8.0.100-rc.2 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100-rc.2\microsoft.net.sdk.maui\8.0.0-rc.2.9530\WorkloadManifest.json Install Type: Msi [android] Installation Source: VS 17.7.34221.43, VS 17.8.34302.71 Manifest Version: 34.0.0-rc.2.479/8.0.100-rc.2 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100-rc.2\microsoft.net.sdk.android\34.0.0-rc.2.479\WorkloadManifest.json Install Type: Msi Host: Version: 8.0.0-rc.2.23479.6 Architecture: x64 Commit: 0b25e38ad3 .NET SDKs installed: 6.0.416 [C:\Program Files\dotnet\sdk] 7.0.403 [C:\Program Files\dotnet\sdk] 8.0.100-rc.2.23502.2 [C:\Program Files\dotnet\sdk] .NET runtimes installed: Microsoft.AspNetCore.App 6.0.24 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 8.0.0-rc.2.23480.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.24 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 8.0.0-rc.2.23479.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 6.0.24 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 8.0.0-rc.2.23479.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Other architectures found: x86 [C:\Program Files (x86)\dotnet] registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation] Environment variables: Not set global.json file: Not found Learn more: https://aka.ms/dotnet/info Download .NET: https://aka.ms/dotnet/download
kleepMan commented 11 months ago

I had the same problem. Our project is done with .NET 7 and it has a private Nuget feed. I updated my VS to the latest version and didn't notice that it removed the .NET 7 SDK and only used .NET 8. When running dotnet restore --interactive I also got the Response status code does not indicate success: 401 (Unauthorized). error.

Started working when I explicitly used .NET 7 SDK to run that command. Also pipelines started working after adding the UseDotNet@2 task with the 7.x.

taspeotis commented 11 months ago

Was helping a colleague with this problem after upgrading to the .NET 8 SDK. Re-installing the credential provider made it work.

https://github.com/microsoft/artifacts-credprovider#setup