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

Race condition in build chain (probably restore step) causing intermittant build failures #11603

Open joshudson opened 4 years ago

joshudson commented 4 years ago

Builds will sometimes fail with strange error messages requesting insane restores, but the next build has a chance of going through with no other changes. I've ran this dozens of times, and the failure rate appears to be about one in three.

This is a regression from SDK version 2.0.

Code that's failing to build (link goes to exact commit hash on github): https://github.com/joshudson/Emet/commit/a9656904e4ca04669f73409ee4ca2d0a4c659aad

Demonstration output:

joshua@nova:~/netcore/Emet/FileSystems$ dotnet build Emet.FileSystems.csproj 
Microsoft (R) Build Engine version 16.5.0+d4cbfca49 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 36.08 ms for /home/joshua/netcore/Emet/FileSystems/Emet.FileSystems.ref.csproj.
/usr/share/dotnet/sdk/3.1.201/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error NETSDK1047: Assets file '/home/joshua/netcore/Emet/FileSystems/obj/project.assets.json' doesn't have a target for '.NETStandard,Version=v2.0/win'. Ensure that restore has run and that you have included 'netstandard2.0' in the TargetFrameworks for your project. You may also need to include 'win' in your project's RuntimeIdentifiers. [/home/joshua/netcore/Emet/FileSystems/Emet.FileSystems.csproj]
/usr/share/dotnet/sdk/3.1.201/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error NETSDK1047: Assets file '/home/joshua/netcore/Emet/FileSystems/obj/project.assets.json' doesn't have a target for '.NETStandard,Version=v2.0/osx-x64'. Ensure that restore has run and that you have included 'netstandard2.0' in the TargetFrameworks for your project. You may also need to include 'osx-x64' in your project's RuntimeIdentifiers. [/home/joshua/netcore/Emet/FileSystems/Emet.FileSystems.csproj]
/usr/share/dotnet/sdk/3.1.201/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error NETSDK1047: Assets file '/home/joshua/netcore/Emet/FileSystems/obj/project.assets.json' doesn't have a target for '.NETStandard,Version=v2.0/linux-x64'. Ensure that restore has run and that you have included 'netstandard2.0' in the TargetFrameworks for your project. You may also need to include 'linux-x64' in your project's RuntimeIdentifiers. [/home/joshua/netcore/Emet/FileSystems/Emet.FileSystems.csproj]

Build FAILED.

/usr/share/dotnet/sdk/3.1.201/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error NETSDK1047: Assets file '/home/joshua/netcore/Emet/FileSystems/obj/project.assets.json' doesn't have a target for '.NETStandard,Version=v2.0/win'. Ensure that restore has run and that you have included 'netstandard2.0' in the TargetFrameworks for your project. You may also need to include 'win' in your project's RuntimeIdentifiers. [/home/joshua/netcore/Emet/FileSystems/Emet.FileSystems.csproj]
/usr/share/dotnet/sdk/3.1.201/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error NETSDK1047: Assets file '/home/joshua/netcore/Emet/FileSystems/obj/project.assets.json' doesn't have a target for '.NETStandard,Version=v2.0/osx-x64'. Ensure that restore has run and that you have included 'netstandard2.0' in the TargetFrameworks for your project. You may also need to include 'osx-x64' in your project's RuntimeIdentifiers. [/home/joshua/netcore/Emet/FileSystems/Emet.FileSystems.csproj]
/usr/share/dotnet/sdk/3.1.201/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(234,5): error NETSDK1047: Assets file '/home/joshua/netcore/Emet/FileSystems/obj/project.assets.json' doesn't have a target for '.NETStandard,Version=v2.0/linux-x64'. Ensure that restore has run and that you have included 'netstandard2.0' in the TargetFrameworks for your project. You may also need to include 'linux-x64' in your project's RuntimeIdentifiers. [/home/joshua/netcore/Emet/FileSystems/Emet.FileSystems.csproj]
    0 Warning(s)
    3 Error(s)

Time Elapsed 00:00:00.86
joshua@nova:~/netcore/Emet/FileSystems$ dotnet build Emet.FileSystems.csproj 
Microsoft (R) Build Engine version 16.5.0+d4cbfca49 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 272.13 ms for /home/joshua/netcore/Emet/FileSystems/Emet.FileSystems.csproj.
  Emet.FileSystems -> /home/joshua/netcore/Emet/FileSystems/bin/Debug/netstandard2.0/win/Emet.FileSystems.dll
  Emet.FileSystems -> /home/joshua/netcore/Emet/FileSystems/bin/Debug/netstandard2.0/osx-x64/Emet.FileSystems.dll
  Emet.FileSystems -> /home/joshua/netcore/Emet/FileSystems/bin/Debug/netstandard2.0/linux-x64/Emet.FileSystems.dll
  Emet.FileSystems.ref -> /home/joshua/netcore/Emet/FileSystems/bin/Debug/netstandard2.0/Emet.FileSystems.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:02.22
joshua@nova:~/netcore/Emet/FileSystems$
joshudson commented 2 years ago

I got a line on this. --disable-parallel almost fixes the problem. Something doesn't honor --disable-parallel.