NuGet / Home

Repo for NuGet Client issues
Other
1.49k stars 250 forks source link

Random error: Failed to resolve SDK 'package/version'. Package restore was successful but a package with the ID of "package" was not installed. #10935

Open rolfbjarne opened 3 years ago

rolfbjarne commented 3 years ago

Details about Problem

NuGet product used (NuGet.exe | Visual Studio | MSBuild.exe | dotnet.exe): dotnet

Product version: 6.0.100-preview.6.21280.2

Worked before? Don't know, this logic that runs into this problem is fairly new for us.

Repro steps and/or sample project

There are no repro steps, because it's random.

We see it somewhat frequently on CI, and trying again usually helps (but not always). It breaks our builds whenever it happens, so it's quite visible 😐

It might be related to running multiple dotnet processes in parallel. In fact some of these processes (they all do basically the same thing, just slightly different input) succeed, some fail.

Verbose Logs

This is a collection of binlogs (of all the dotnet processes that ran in parallel):

nupkgs.zip

The larger ones succeeded, the smaller ones didn't:

$ unzip -l *.zip
Archive:  nupkgs.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  06-10-2021 21:47   nupkgs/
   339955  06-10-2021 19:47   nupkgs/Microsoft.iOS.Windows.Sdk.14.5.100-ci.pr.gh11893.1002+sha.ab99eec6b.nupkg.binlog
    36209  06-10-2021 19:47   nupkgs/Microsoft.iOS.Runtime.ios-arm.14.5.100-ci.pr.gh11893.1002+sha.ab99eec6b.nupkg.binlog
   339489  06-10-2021 19:47   nupkgs/Microsoft.iOS.Runtime.ios-arm64.14.5.100-ci.pr.gh11893.1002+sha.ab99eec6b.nupkg.binlog
    36218  06-10-2021 19:47   nupkgs/Microsoft.iOS.Runtime.iossimulator-x86.14.5.100-ci.pr.gh11893.1002+sha.ab99eec6b.nupkg.binlog
   339409  06-10-2021 19:47   nupkgs/Microsoft.tvOS.Runtime.tvossimulator-x64.14.5.100-ci.pr.gh11893.1002+sha.ab99eec6b.nupkg.binlog
    36194  06-10-2021 19:47   nupkgs/Microsoft.iOS.Runtime.iossimulator-x64.14.5.100-ci.pr.gh11893.1002+sha.ab99eec6b.nupkg.binlog
    36192  06-10-2021 19:47   nupkgs/Microsoft.tvOS.Runtime.tvos-arm64.14.5.100-ci.pr.gh11893.1002+sha.ab99eec6b.nupkg.binlog
---------                     -------
  1163666                     8 files

Example output from one of the failed ones:

$ dotnet build /v:diag Microsoft.iOS.Runtime.ios-arm.14.5.100-ci.pr.gh11893.1002+sha.ab99eec6b.nupkg.binlog
[...]
                   Resolving SDK 'Microsoft.DotNet.SharedFramework.Sdk/6.0.0-beta.21212.6'...
                   Running restore with 12 concurrent jobs.
                   Reading project file /var/folders/fk/l5v9vv0j6rggmfsjkz3cx6qw0000gn/T/NuGetScratch/e57bdd7b09cc43f9bb34ca63ce9071a5/d209b53f765847c49af9dcffc2e71103.proj.
                   Restoring packages for /var/folders/fk/l5v9vv0j6rggmfsjkz3cx6qw0000gn/T/NuGetScratch/e57bdd7b09cc43f9bb34ca63ce9071a5/d209b53f765847c49af9dcffc2e71103.proj...
                   Restoring packages for .NETStandard,Version=v0.0...
                   Resolving conflicts for .NETStandard,Version=v0.0...
                   Checking compatibility of packages on .NETStandard,Version=v0.0.
                   Checking compatibility for d209b53f765847c49af9dcffc2e71103 1.0.0 with .NETStandard,Version=v0.0.
                   Checking compatibility for Microsoft.DotNet.SharedFramework.Sdk 6.0.0-beta.21212.6 with .NETStandard,Version=v0.0.
                   All packages and projects are compatible with .NETStandard,Version=v0.0.
15:07:26.328     0>/Users/builder/azdo/_work/1/s/xamarin-macios/dotnet/package/common.csproj(52,3): error : Failed to resolve SDK 'Microsoft.DotNet.SharedFramework.Sdk/6.0.0-beta.21212.6'. Package restore was successful but a package with the ID of "Microsoft.DotNet.SharedFramework.Sdk" was not installed.

it looks like the succeeding ones took a different code path:

$ dotnet build /v:diag Microsoft.iOS.Runtime.ios-arm64.14.5.100-ci.pr.gh11893.1002+sha.ab99eec6b.nupkg.binlog
[...]
                   Resolving SDK 'Microsoft.DotNet.SharedFramework.Sdk/6.0.0-beta.21212.6'...
                   Importing project "/Users/builder/.nuget/packages/microsoft.dotnet.sharedframework.sdk/6.0.0-beta.21212.6/Sdk/Sdk.props" into project "/Users/builder/azdo/_work/1/s/xamarin-macios/dotnet/package/common.csproj" at (52,3).
                   Importing project "/Users/builder/.nuget/packages/microsoft.dotnet.sharedframework.sdk/6.0.0-beta.21212.6/targets/Microsoft.DotNet.SharedFramework.Sdk.props" into project "/Users/builder/.nuget/packages/microsoft.dotnet.sharedframework.sdk/6.0.0-beta.21212.6/Sdk/Sdk.props" at (24,3).
                   Importing project "/Users/builder/.nuget/packages/microsoft.dotnet.sharedframework.sdk/6.0.0-beta.21212.6/targets/sharedfx.props" into project "/Users/builder/.nuget/packages/microsoft.dotnet.sharedframework.sdk/6.0.0-beta.21212.6/targets/Microsoft.DotNet.SharedFramework.Sdk.props" at (2,3).
                   Property reassignment: $(NoWarn)="1701;1702;NU5105;NU5128;NU5131;NU5128;NU5131" (previous value: "1701;1702;NU5105;NU5128;NU5131") at /Users/builder/.nuget/packages/microsoft.dotnet.sharedframework.sdk/6.0.0-beta.21212.6/targets/sharedfx.props (13,5)
                   Importing project "/Users/builder/azdo/_work/1/s/xamarin-macios/builds/downloads/dotnet-sdk-6.0.100-preview.6.21280.2-osx-x64/sdk/6.0.100-preview.6.21280.2/Sdks/Microsoft.NET.Sdk/Sdk/Sdk.targets" into project "/Users/builder/azdo/_work/1/s/xamarin-macios/dotnet/package/Microsoft.iOS.Runtime.ios-arm64/package.csproj" at (0,0).
                   Project "$(MSBuildThisFileDirectory)../targets/Microsoft.NET.Sdk.BeforeCommonCrossTargeting.targets" was not imported by "/Users/builder/azdo/_work/1/s/xamarin-macios/builds/downloads/dotnet-sdk-6.0.100-preview.6.21280.2-osx-x64/sdk/6.0.100-preview.6.21280.2/Sdks/Microsoft.NET.Sdk/Sdk/Sdk.targets" at (19,3), due to false condition; ('$(IsCrossTargetingBuild)' == 'true') was evaluated as ('' == 'true').
nkolev92 commented 3 years ago

Hey @rolfbjarne

We have had issues like this in the past, https://github.com/NuGet/Home/issues/7817, but it seems like they were supposed to fixed.

cc @jeffkl

jeffkl commented 3 years ago

@nkolev92 the output is very different in the success case versus the failure case.

Failure

image

Success

image

It does look like the restores are all happening at the same time and the locking is keeping them from all restoring the same package. But once the lock is released the package isn't there?

@rolfbjarne what's the repository this is happening in? I'd like to look at the customized logic in use.

rolfbjarne commented 3 years ago

@jeffkl

We have some make logic here that executes 'dotnet pack' in parallel: https://github.com/xamarin/xamarin-macios/blob/0029ffa29d8396c35175befa8e414675b41774c9/dotnet/Makefile#L150.

This is executed once for every package.csproj in every subdirectory here: https://github.com/xamarin/xamarin-macios/tree/0029ffa29d8396c35175befa8e414675b41774c9/dotnet/package.

The reference that causes problems is this one: https://github.com/xamarin/xamarin-macios/blob/0029ffa29d8396c35175befa8e414675b41774c9/dotnet/package/common.csproj#L52