Skip to content

dotnet restore will treat all sources as local if the first source is local #14624

@smaglio81

Description

@smaglio81

NuGet Product Used

dotnet.exe

Product Version

9.0.306

Worked before?

No response

Impact

It's more difficult to complete my work

Repro Steps & Context

Describe the bug

dotnet restore will treat all sources passed in using the -s parameter as local if the first source is local.

dotnet restore dotnetrestoretest.csproj -s "C:\Program Files (x86)\Microsoft SDKs\NuGetPackages" -s https://api.nuget.org/v3/index.json

To Reproduce

There is a repository which can reproduce the error.

The project intentionally references a non-existant nuget package version (Microsoft.Extensions.DependencyInjection 8.2.00001), because that forces dotnet to search the sources for the package.

This is what the issue looks like

Image

Exceptions (if any)

error NU1301: The local source 'D:\workspace\dotnetrestorelocal\dotnetrestoretest\https:\api.nuget.org\v3\index.json' doesn't exist.

Further technical details

details of dotnet --info

.NET SDK: Version: 9.0.306 Commit: cc9947ca66 Workload version: 9.0.300-manifests.abe91478 MSBuild version: 17.14.28+09c1be848

Runtime Environment:
OS Name: Windows
OS Version: 10.0.22631
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\9.0.306\

.NET workloads installed:
There are no installed workloads to display.
Configured to use loose manifests when installing new manifests.

Host:
Version: 9.0.10
Architecture: x64
Commit: e1f19886fe

.NET SDKs installed:
9.0.306 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 8.0.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.21 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.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

VS Code details

Version: 1.102.0 (user setup) Commit: cb0c47c0cfaad0757385834bd89d410c78a856c0 Date: 2025-07-09T22:10:34.600Z Electron: 35.6.0 ElectronBuildId: 11847422 Chromium: 134.0.6998.205 Node.js: 22.15.1 V8: 13.4.114.21-electron.0 OS: Windows_NT x64 10.0.22631

Previously submitted as dotnet/sdk#51514

Verbose Logs

PS D:\workspace\dotnetrestorelocal\dotnetrestoretest> dotnet restore dotnetrestoretest.csproj -s "C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\\" -s https://api.nuget.org/v3/index.json --verbosity diag
C:\Program Files\dotnet\sdk\9.0.306\MSBuild.dll -nologo -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,C:\Program Files\dotnet\sdk\9.0.306\dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,C:\Program Files\dotnet\sdk\9.0.306\dotnet.dll -maxcpucount -property:RestoreSources=C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\%3Bhttps:%2F%2Fapi.nuget.org/v3/index.json -target:Restore -tlp:default=auto -verbosity:m -verbosity:diag dotnetrestoretest.csproj
    Determining projects to restore...
    D:\workspace\dotnetrestorelocal\dotnetrestoretest\dotnetrestoretest.csproj : error NU1301: The local source 'D:\workspace\dotnetrestorelocal\dotnetrestoretest\https:\api.nuget.org\v3\index.json' doesn't exist.
    Failed to restore D:\workspace\dotnetrestorelocal\dotnetrestoretest\dotnetrestoretest.csproj (in 69 ms).
                                                                                                                                                                                         
Restore failed with 1 error(s) in 0.3s

Metadata

Metadata

Assignees

No one assigned

    Labels

    Category:Quality WeekIssues that should be considered for quality weekPriority:2Issues for the current backlog.Type:Bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions