Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build failure: error NETSDK1004: Assets file '...' not found. Run a NuGet package restore to generate this file. #45755

Closed
tmds opened this issue Dec 8, 2020 · 60 comments · Fixed by #45858

Comments

@tmds
Copy link
Member

tmds commented Dec 8, 2020

When I build this repo using:

$ ./build.sh clr+libs -rc Release /p:NoPgoOptimize=true

My build fails with:

/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(324,5): error NETSDK1127: The targeting pack Microsoft.NETCore.App is not installed. Please restore and try again. [/home/tmds/repos/runtime/src/libraries/System.Security.Principal.Windows/ref/System.Security.Principal.Windows.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(324,5): error NETSDK1127: The targeting pack Microsoft.NETCore.App is not installed. Please restore and try again. [/home/tmds/repos/runtime/src/libraries/System.Security.Cryptography.Cng/ref/System.Security.Cryptography.Cng.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(324,5): error NETSDK1127: The targeting pack Microsoft.NETCore.App is not installed. Please restore and try again. [/home/tmds/repos/runtime/src/libraries/System.Security.Cryptography.OpenSsl/ref/System.Security.Cryptography.OpenSsl.csproj]

@ViktorHofer do you have an idea what may be causing this?

@ViktorHofer
Copy link
Member

Do you have the text log of what the initial build.sh command printed? Maybe you also have a binlog? Restore should have taken care of restoring the netcoreapp3.0 targeting pack. Is that error reproducible?

@ViktorHofer
Copy link
Member

I'm curious if this actually complains for netcoreapp3.0 or $(NetCoreAppCurrent).

@tmds
Copy link
Member Author

tmds commented Dec 8, 2020

master is always failing for me. This is the console output: cout.txt.

@tmds
Copy link
Member Author

tmds commented Dec 8, 2020

If you need it, I can provide you with a binlog if you tell me how to generate it and where I can find it.

I don't use them because they are not very usable on Linux.

@ViktorHofer
Copy link
Member

So yes, this is a restore issue:

  Retrying 'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/1a5f89f6-d8da-4080-b15f-242650c914a8/nuget/v3/flat2/nuget.dependencyresolver.core/index.json'.
  The SSL connection could not be established, see inner exception.
    Unable to read data from the transport connection: Connection reset by peer.
    Connection reset by peer
  Retrying 'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/c9f8ac11-6bd8-4926-8306-f075241547f7/nuget/v3/flat2/nuget.packaging.core/index.json'.
  The SSL connection could not be established, see inner exception.
    Unable to read data from the transport connection: Connection reset by peer.
    Connection reset by peer

We have been such cases from time to time where NuGet fails to restore certain package but doesn't fail the build.

cc @nkolev92 @jkotas

@ViktorHofer
Copy link
Member

If you need it, I can provide you with a binlog if you tell me how to generate it and where I can find it.

Sure, just add the /bl switch at the end of the command.

I don't use them because they are not very usable on Linux.

There's a webview available for it now: https://live.msbuildlog.com/ :)

@tmds
Copy link
Member Author

tmds commented Dec 8, 2020

We have been such cases from time to time where NuGet fails to restore certain package but doesn't fail the build.

I've run this 5-ish times. It's weird that it's always missing exactly the same packages.

There's a webview available for it now: https://live.msbuildlog.com/ :)

I don't feel it scales for the logs I throw at it.

Sure, just add the /bl switch at the end of the command.

Running ./build.sh --subset clr+libs+libs.tests -test -rc Release /p:NoPgoOptimize=true /bl.

gave me:

artifacts/log/
├── Debug
└── Release
    ├── GenNativeVersion_Linux.x64.Release.binlog
    └── MsbuildDebugLogs

Is this what you expect?

@ViktorHofer
Copy link
Member

ViktorHofer commented Dec 8, 2020

Is this what you expect?

The binlog should be located in the CWD.

I don't feel it scales for the logs I throw at it.

Fair.

I've run this 5-ish times. It's weird that it's always missing exactly the same packages.

I don't understand that either. I would recommend to wait a few hours and try it again and let us please know.

@ghost
Copy link

ghost commented Dec 8, 2020

Tagging subscribers to this area: @ViktorHofer
See info in area-owners.md if you want to be subscribed.

Issue Details

When I build this repo using:

$ ./build.sh clr+libs -rc Release /p:NoPgoOptimize=true

My build fails with:

/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(324,5): error NETSDK1127: The targeting pack Microsoft.NETCore.App is not installed. Please restore and try again. [/home/tmds/repos/runtime/src/libraries/System.Security.Principal.Windows/ref/System.Security.Principal.Windows.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(324,5): error NETSDK1127: The targeting pack Microsoft.NETCore.App is not installed. Please restore and try again. [/home/tmds/repos/runtime/src/libraries/System.Security.Cryptography.Cng/ref/System.Security.Cryptography.Cng.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(324,5): error NETSDK1127: The targeting pack Microsoft.NETCore.App is not installed. Please restore and try again. [/home/tmds/repos/runtime/src/libraries/System.Security.Cryptography.OpenSsl/ref/System.Security.Cryptography.OpenSsl.csproj]

@ViktorHofer do you have an idea what may be causing this?

Author: tmds
Assignees: -
Labels:

area-Infrastructure

Milestone: -

@safern
Copy link
Member

safern commented Dec 8, 2020

I just hit this when running build.cmd libs.ref on a fresh machine. I can repro minimally with: dotnet build src\libraries\System.Security.Principal.Windows\ref\System.Security.Principal.Windows.csproj /bl

I believe this is happening due to the 5.0.0 SDK update on global.json. The problem seems to be manifesting whenever you don't have 5.0.0-rc.1.20451.14 targeting pack. I believe this is caused by:

<KnownFrameworkReference Include="Microsoft.NETCore.App"
DefaultRuntimeFrameworkVersion="$(MicrosoftNETCoreAppVersion)"
IsTrimmable="true"
LatestRuntimeFrameworkVersion="$(MicrosoftNETCoreAppVersion)"
RuntimeFrameworkName="Microsoft.NETCore.App"
RuntimePackNamePatterns="Microsoft.NETCore.App.Runtime.**RID**"
RuntimePackRuntimeIdentifiers="linux-arm;linux-arm64;linux-musl-arm64;linux-musl-x64;linux-x64;osx-x64;rhel.6-x64;tizen.4.0.0-armel;tizen.5.0.0-armel;win-arm;win-arm64;win-x64;win-x86;ios-arm64;ios-arm;ios-x64;ios-x86;tvos-arm64;tvos-x64;android-arm64;android-arm;android-x64;android-x86;browser-wasm"
TargetFramework="$(NetCoreAppCurrent)"
TargetingPackName="Microsoft.NETCore.App.Ref"
TargetingPackVersion="$(MicrosoftNETCoreAppVersion)" />

Because MicrosoftNETCoreAppVersion is 5.0.0-rc.1.20451.14

image

I think we should update MicrosoftNETCoreAppVersion to 5.0.0?

@safern
Copy link
Member

safern commented Dec 8, 2020

Yeah I just confirmed that if I update MicrosoftNETCoreAppVersion to 5.0.0 I don't hit that issue.

❯ dotnet --info
.NET SDK (reflecting any global.json):
 Version:   5.0.100
 Commit:    5044b93829

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19042
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\5.0.100\

Host (useful for support):
  Version: 5.0.0
  Commit:  cf258a14b7

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

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

@safern
Copy link
Member

safern commented Dec 8, 2020

Actually, do we need this ref at all for our libraries projects? I believe we should remove this KnownFrameworkReference, we should be building against live references for NetCoreAppCurrent.

@safern
Copy link
Member

safern commented Dec 8, 2020

It looks like we disable it already but only for inbox libraries:

<DisableImplicitFrameworkReferences Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and
$([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '$(NETCoreAppCurrentVersion)')) and

Note that when building libraries src projects, i.e: Microsoft.Win32.SystemEvents the targeting pack is restored, but for the refs build it is not.

@nkolev92
Copy link
Contributor

nkolev92 commented Dec 8, 2020

From the logs, I see a bunch of different restores are running.

Determining projects to restore is printed once per run.
It's possible that some runs are failing but others succeed.

@ViktorHofer
Copy link
Member

Yes, we invoke restore three times:

  1. On arcade's Build.proj
  2. On the src\tasks\Tasks.proj which are required for restore of point 3
  3. On our dotnet/runtime specific Build.proj

Would that cause a problem? In the past we had 30+ restore invocations...

@ViktorHofer
Copy link
Member

Note that when building libraries src projects, i.e: Microsoft.Win32.SystemEvents the targeting pack is restored, but for the refs build it is not.

For which configuration? For $(NetCoreAppCurrent), the targeting pack should never be restored as we disable that for inbox libraries via the DisableImplicitFrameworkReferences property and for OOB ones via the EnableTargetingPackDownload property, here:

<EnableTargetingPackDownload>false</EnableTargetingPackDownload>

@ViktorHofer
Copy link
Member

ViktorHofer commented Dec 9, 2020

Microsoft.Win32.SystemEvents

I don't see a $(NetCoreAppCurrent) configuration in

<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
, hence the targeting packs should be restored in the ref build for netstandard2.0 and net461.

@tmds
Copy link
Member Author

tmds commented Dec 9, 2020

I believe this is happening due to the 5.0.0 SDK update on global.json. The problem seems to be manifesting whenever you don't have 5.0.0-rc.1.20451.14 targeting pack.

Is someone looking into this?

@ViktorHofer
Copy link
Member

I just replied to this thread 30min ago, so yes, we are looking into this :)

@safern
Copy link
Member

safern commented Dec 9, 2020

This will be fixed by: #45781

@tmds in the meantime you can pass down this property globally to workaround it: /p:GenerateErrorForMissingTargetingPacks=false

@nkolev92
Copy link
Contributor

nkolev92 commented Dec 9, 2020

Multiple invocations would not cause a problem, but it makes it difficult to understand which operation is actually failing.
My guess is a certain invocation swallows the failing exit code...narrowing it down to which restore operation is failing might help us figure it out.

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Dec 9, 2020
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Dec 9, 2020
@tmds
Copy link
Member Author

tmds commented Dec 10, 2020

I still can't build. I hit a different error, also restore related.

@safern @ViktorHofer does a build work on a fresh machine for you?

$ ./build.sh --subset clr+libs -rc Release  /p:NoPgoOptimize=true
...
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds/repos/runtime/artifacts/obj/Microsoft.VisualBasic/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds/repos/runtime/src/libraries/shims/generated/Microsoft.VisualBasic.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds/repos/runtime/artifacts/obj/mscorlib/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds/repos/runtime/src/libraries/shims/generated/mscorlib.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds/repos/runtime/artifacts/obj/netstandard/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds/repos/runtime/src/libraries/shims/generated/netstandard.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds/repos/runtime/artifacts/obj/System.ComponentModel.DataAnnotations/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds/repos/runtime/src/libraries/shims/generated/System.ComponentModel.DataAnnotations.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds/repos/runtime/artifacts/obj/System.Configuration/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds/repos/runtime/src/libraries/shims/generated/System.Configuration.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds/repos/runtime/artifacts/obj/System.Core/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds/repos/runtime/src/libraries/shims/generated/System.Core.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds/repos/runtime/artifacts/obj/System/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds/repos/runtime/src/libraries/shims/generated/System.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds/repos/runtime/artifacts/obj/System.Data/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds/repos/runtime/src/libraries/shims/generated/System.Data.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds/repos/runtime/artifacts/obj/System.Drawing/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds/repos/runtime/src/libraries/shims/generated/System.Drawing.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds/repos/runtime/artifacts/obj/System.IO.Compression.FileSystem/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds/repos/runtime/src/libraries/shims/generated/System.IO.Compression.FileSystem.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds/repos/runtime/artifacts/obj/System.Net/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds/repos/runtime/src/libraries/shims/generated/System.Net.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds/repos/runtime/artifacts/obj/System.Numerics/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds/repos/runtime/src/libraries/shims/generated/System.Numerics.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds/repos/runtime/artifacts/obj/System.Runtime.Serialization/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds/repos/runtime/src/libraries/shims/generated/System.Runtime.Serialization.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds/repos/runtime/artifacts/obj/System.Security/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds/repos/runtime/src/libraries/shims/generated/System.Security.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds/repos/runtime/artifacts/obj/System.ServiceModel.Web/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds/repos/runtime/src/libraries/shims/generated/System.ServiceModel.Web.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds/repos/runtime/artifacts/obj/System.ServiceProcess/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds/repos/runtime/src/libraries/shims/generated/System.ServiceProcess.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds/repos/runtime/artifacts/obj/System.Transactions/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds/repos/runtime/src/libraries/shims/generated/System.Transactions.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds/repos/runtime/artifacts/obj/System.Web/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds/repos/runtime/src/libraries/shims/generated/System.Web.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds/repos/runtime/artifacts/obj/System.Windows/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds/repos/runtime/src/libraries/shims/generated/System.Windows.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds/repos/runtime/artifacts/obj/System.Xml/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds/repos/runtime/src/libraries/shims/generated/System.Xml.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds/repos/runtime/artifacts/obj/System.Xml.Linq/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds/repos/runtime/src/libraries/shims/generated/System.Xml.Linq.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds/repos/runtime/artifacts/obj/System.Xml.Serialization/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds/repos/runtime/src/libraries/shims/generated/System.Xml.Serialization.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds/repos/runtime/artifacts/obj/WindowsBase/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds/repos/runtime/src/libraries/shims/generated/WindowsBase.csproj]

@ViktorHofer
Copy link
Member

Taking a closer look now.

@KirillOsenkov
Copy link
Member

I haven't seen this binlog corruption before, it fails immediately when trying to read the first buffer from the stream:
image

I don't have the expertise to dig deeper unfortunately. This is where the binlog creation logic lives in MSBuild:
https://source.dot.net/#Microsoft.Build/Logging/BinaryLogger/BinaryLogger.cs,139

@nkolev92
Copy link
Contributor

cc @nkolev92 @jeffkl (as we are using RestoreTaskEx). No projects were restored but the build still continued to run. Apparently the exit code was wrong in this case? In addition to that, my guess is that our InitialTarget which invokes a Task that logs the "Could not parse version for LatestPackage ..." message, fails and NuGet swallows the exception.

Looking at https://github.com/dotnet/arcade/blob/7d638bb082f374f7c8ddbada79f757662df4a246/src/Microsoft.DotNet.Build.Tasks.Packaging/src/GetLastStablePackage.cs#L139, the task doesn't log an error.

It's possible that restore is skipped, rather than failed. We just don't have enough logging right now to be able to confirm that.

Have you been able to narrow it down to a repro?
We can add more logging but that'll take some time to propagate.

@ViktorHofer
Copy link
Member

ViktorHofer commented Dec 16, 2020

Have you been able to narrow it down to a repro?

Unfortunately not yet. I'm trying to reproduce the error via #46134 but haven't hit the error yet... That PR includes generating the static graph restore evaluation binlog that would tell us more.

We can add more logging but that'll take some time to propagate.

I think we should definitely do that. It's not clear to me if the static graph restore nuget console app a) failed, b) succeeded but actually swallowed an exception and didn't do anything (my guess) or c) succeeded. I believe we can rule out the latter as the build later fails because of the missing project.assets.json and other nuget generated files.

It's possible that restore is skipped, rather than failed. We just don't have enough logging right now to be able to confirm that.

What would skipped mean? Even if nothing is restored, wouldn't I still see some of the logging when projects are evaluated and the graph is constructed that I see in other binlogs in incremental restore operations?

the task doesn't log an error.

Right. It's unclear to me if something inside that task failed. That message is only an informational logging.

@nkolev92
Copy link
Contributor

nkolev92 commented Dec 16, 2020

not clear to me if the static graph restore nuget console app a) failed, b) succeeded but actually swallowed an exception and didn't do anything (my guess) or c) succeeded.

What would skipped mean? Even if nothing is restored, wouldn't I still see some of the logging when projects are evaluated and the graph is constructed that I see in other binlogs in incremental restore operations?

Not every project type supports restore, so when run on a solution, NuGet might skip some projects. That's a good behavior in many cases.

Recently we investigated an issue where restore was skipped NuGet/Home#10363.
We don't have as much logging in static graph scenarios (because so much of the msbuild logic was re-written).

I'm making this guess because we have not had issues with restore swallowing exceptions before, but skipping projects has happened in both static and non-static graph restores.

@ViktorHofer
Copy link
Member

Wouldn't static graph restore skipping projects indicate a deterministic behavior? What I was seeing in CI was a one-off failure. The issue that @tmds reported originally in this issue is a timeout and probably a different cause (you responded offline).

@nkolev92
Copy link
Contributor

Wouldn't static graph restore skipping projects indicate a deterministic behavior

One would hope :)

We can add some extra logs in static graph restore, but I'm not sure how quickly that propagates.

@KirillOsenkov
Copy link
Member

@nkolev92 would you mind filing a bug to add better logging to RestoreTaskEx?

@nkolev92
Copy link
Contributor

I added a comment to expand NuGet/Home#10363.

@tmds
Copy link
Member Author

tmds commented Jan 5, 2021

I still can't build the runtime repo. I'm still seeing errors from #45755 (comment). I sent you a mail with logs.

It's weird no one else is seeing this. I created a new user on my system to rule out something in my HOME causes the problem. Also for this user, I get the same errors.

/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds2/runtime/artifacts/obj/Microsoft.VisualBasic/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds2/runtime/src/libraries/shims/generated/Microsoft.VisualBasic.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds2/runtime/artifacts/obj/mscorlib/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds2/runtime/src/libraries/shims/generated/mscorlib.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds2/runtime/artifacts/obj/netstandard/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds2/runtime/src/libraries/shims/generated/netstandard.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds2/runtime/artifacts/obj/System.ComponentModel.DataAnnotations/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds2/runtime/src/libraries/shims/generated/System.ComponentModel.DataAnnotations.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds2/runtime/artifacts/obj/System.Configuration/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds2/runtime/src/libraries/shims/generated/System.Configuration.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds2/runtime/artifacts/obj/System.Core/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds2/runtime/src/libraries/shims/generated/System.Core.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds2/runtime/artifacts/obj/System/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds2/runtime/src/libraries/shims/generated/System.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds2/runtime/artifacts/obj/System.Data/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds2/runtime/src/libraries/shims/generated/System.Data.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds2/runtime/artifacts/obj/System.Drawing/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds2/runtime/src/libraries/shims/generated/System.Drawing.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds2/runtime/artifacts/obj/System.IO.Compression.FileSystem/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds2/runtime/src/libraries/shims/generated/System.IO.Compression.FileSystem.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds2/runtime/artifacts/obj/System.Net/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds2/runtime/src/libraries/shims/generated/System.Net.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds2/runtime/artifacts/obj/System.Numerics/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds2/runtime/src/libraries/shims/generated/System.Numerics.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds2/runtime/artifacts/obj/System.Runtime.Serialization/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds2/runtime/src/libraries/shims/generated/System.Runtime.Serialization.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds2/runtime/artifacts/obj/System.Security/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds2/runtime/src/libraries/shims/generated/System.Security.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds2/runtime/artifacts/obj/System.ServiceModel.Web/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds2/runtime/src/libraries/shims/generated/System.ServiceModel.Web.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds2/runtime/artifacts/obj/System.ServiceProcess/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds2/runtime/src/libraries/shims/generated/System.ServiceProcess.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds2/runtime/artifacts/obj/System.Transactions/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds2/runtime/src/libraries/shims/generated/System.Transactions.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds2/runtime/artifacts/obj/System.Web/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds2/runtime/src/libraries/shims/generated/System.Web.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds2/runtime/artifacts/obj/System.Windows/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds2/runtime/src/libraries/shims/generated/System.Windows.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds2/runtime/artifacts/obj/System.Xml/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds2/runtime/src/libraries/shims/generated/System.Xml.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds2/runtime/artifacts/obj/System.Xml.Linq/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds2/runtime/src/libraries/shims/generated/System.Xml.Linq.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds2/runtime/artifacts/obj/System.Xml.Serialization/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds2/runtime/src/libraries/shims/generated/System.Xml.Serialization.csproj]
/usr/lib64/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1004: Assets file '/home/tmds2/runtime/artifacts/obj/WindowsBase/project.assets.json' not found. Run a NuGet package restore to generate this file. [/home/tmds2/runtime/src/libraries/shims/generated/WindowsBase.csproj]
    0 Warning(s)
    23 Error(s)

@tmds tmds changed the title build failure: error NETSDK1127: The targeting pack Microsoft.NETCore.App is not installed. build failure: error NETSDK1004: Assets file '...' not found. Run a NuGet package restore to generate this file. Jan 6, 2021
@tmds
Copy link
Member Author

tmds commented Jan 6, 2021

I created a new user on my system to rule out something in my HOME causes the problem. Also for this user, I get the same errors.

I thought about what still might be specific about my machine, so ran sudo dnf remove 'dotnet*' which removed all .NET versions I had installed from Fedora repos, and now I can build master. 🎉

I have then added back the versions I had installed: sudo dnf install dotnet-sdk-5.0 dotnet-sdk-2.2 dotnet-sdk-3.1 . And ran a new build, and again I get the error NETSDK1004.

So, the issue I have gets caused by the dotnet packages that are installed on my system.

@ViktorHofer can we change the build script so it prefers dotnet that gets fetched as part of the build, over the one that is installed on the system?

cc @omajid

@tmds
Copy link
Member Author

tmds commented Jan 14, 2021

@ViktorHofer can we change the build script so it prefers dotnet that gets fetched as part of the build, over the one that is installed on the system?

@ViktorHofer is this an appropriate change? I can look into making it.

@safern
Copy link
Member

safern commented Jan 14, 2021

@ViktorHofer is this an appropriate change? I can look into making it.

I believe this was designed that way so that builds were faster if we found a compatible SDK installed machine-wide to the version we specify in global.json.

@ViktorHofer
Copy link
Member

Hey Tom, sorry for getting back to you so late. We intentionally allow globally installed sdks to avoid the unnecessary download which can be quite big.

I think we should diagnose why this is happening with mixed globally installed sdks as this could also happen in any other customer project...

@KirillOsenkov
Copy link
Member

Also show we show the binlogs sent by Tom to an expert in compression to understand why a small binlog is fine, but large binlogs don't extract properly?

@safern
Copy link
Member

safern commented Jan 14, 2021

cc: @carlossanlop for the compression question.

@danmoseley
Copy link
Member

When I go to @tmds links above, I just get the RedHat logo. It sounds like we need a bug opened with an example of the file that was created with .NET, but cannot be opened by .NET (but can be opened by gzip)

@KirillOsenkov
Copy link
Member

@danmosemsft I have the binlogs locally, I'll open a bug and provide a link to internal-only binlog downloads

@KirillOsenkov
Copy link
Member

I've filed #47024

@tmds
Copy link
Member Author

tmds commented Jan 15, 2021

I believe this was designed that way so that builds were faster if we found a compatible SDK installed machine-wide to the version we specify in global.json.

Is there something that verifies the build works if you meet the requirement in global.json? I have 5.0.100 which meets what is required in global.json and is the latest available version through source-build. Though you probably have 5.0.102 installed because it is available from Microsoft builds.

Hey Tom, sorry for getting back to you so late. We intentionally allow globally installed sdks to avoid the unnecessary download which can be quite big.

Is there an option to not use globally installed sdks? If not, can we add one?

@ViktorHofer
Copy link
Member

ViktorHofer commented Jan 15, 2021

Is there something that verifies the build works if you meet the requirement in global.json? I have 5.0.100 which meets what is required in global.json and is the latest available version through source-build. Though you probably have 5.0.102 installed because it is available from Microsoft builds.

It's currently a direct match. If the installed SDK matches the specified version in global.json, it's a match. There's no support for patch/minor/major roll forward: dotnet/arcade#6636.

This means that the SDK is fetched ie if you have a 5.0.102 installed. The corresponding logic can be found here: https://github.com/dotnet/arcade/blob/8ca877b54001e682f9642d8995f2a01616ac3fd4/eng/common/tools.sh#L153.

Though you probably have 5.0.102 installed because it is available from Microsoft builds.

Me and many others still have 5.0.100 installed (which on Windows is the case if you don't update your VS installation often or Windows Update isn't triggered) and it works fine. Based on what you described earlier this seems to be connected to have multiple SDKs installed which interfere with each other somehow.

I thought about what still might be specific about my machine, so ran sudo dnf remove 'dotnet*' which removed all .NET versions I had installed from Fedora repos, and now I can build master. 🎉
I have then added back the versions I had installed: sudo dnf install dotnet-sdk-5.0 dotnet-sdk-2.2 dotnet-sdk-3.1 . And ran a new build, and again I get the error NETSDK1004.

@marcpopMSFT @vitek-karas @dsplaisted have we heard of such issues in the past where installing previous shipped SDKs change the behavior of the latest one installed and causes the discussed restore issues?

Is there an option to not use globally installed sdks? If not, can we add one?

Yes, that's possible but we won't be able to check the code in as with that we would loose the optimization. Here's how you would do it: https://github.com/dotnet/coreclr/blob/9fb9458bed5f812b88a69a02f795b738a5a8f167/eng/configure-toolset.sh#L1-L5. You need that file in the eng folder containing the first 5 lines.

@tmds
Copy link
Member Author

tmds commented Feb 5, 2021

My system sdk is now 5.0.102 and no longer the same version as required by dotnet/runtime.
As expected, this builds fine.

When I change:

diff --git a/global.json b/global.json
index f271ad70ec6..a5dba62247e 100644
--- a/global.json
+++ b/global.json
@@ -1,11 +1,11 @@
 {
   "sdk": {
-    "version": "5.0.100",
+    "version": "5.0.102",
     "allowPrerelease": true,
     "rollForward": "major"
   },
   "tools": {
-    "dotnet": "5.0.100"
+    "dotnet": "5.0.102"
   },
   "native-tools": {
     "cmake": "3.16.4",

the build also works.

I won't try to reproduce and investigate further.

@tmds tmds closed this as completed Feb 5, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Mar 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants
@KirillOsenkov @tmds @nkolev92 @danmoseley @jkotas @ViktorHofer @safern and others