Skip to content

[source mapping] Having a duplicate source breaks msbuild sdks restore #13471

Open
@jeromelaban

Description

@jeromelaban

NuGet Product Used

dotnet.exe, Visual Studio Package Management UI

Product Version

8.0.300

Worked before?

unknown

Impact

Other

Repro Steps & Context

  1. Clear all caches: dotnet nuget locals all -c
  2. Create a library: dotnet new classlib -o test01
  3. Change the test01.csproj sdk to be Sdk="MSTest.Sdk/3.3.1"
  4. In %appdata%\NuGet\NuGet.Config. add the following mapping:
<packageSource key="nuget.org">
        <package pattern="System.*" />
</packageSource>
  1. In the test01 folder, create a nuget.config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <packageSources>
        <add key="NuGet official package source" value="https://api.nuget.org/v3/index.json" />
    </packageSources>
</configuration>
  1. In classlib01, run dotnet restore

Notice that if the custom nuget.config file added in the project folder is removed or the duplicate nuget.org source is removed, the restore succeeds.

Verbose Logs

D:\temp\test01\test01.csproj : error : Could not resolve SDK "MSTest.Sdk". 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.
D:\temp\test01\test01.csproj : error :   SDK resolver "Microsoft.DotNet.MSBuildWorkloadSdkResolver" returned null.
D:\temp\test01\test01.csproj : error :   Unable to resolve 'MSTest.Sdk (= 3.3.1)' for '.NETStandard,Version=v0.0'. PackageSourceMapping is enabled, the following source(s) were not considered: Microsoft Visual Studio Offline Packages, NuGet official package source.
D:\temp\test01\test01.csproj : error MSB4236: The SDK 'MSTest.Sdk' specified could not be found.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions