Skip to content

win-arm64 native files in the nuget tree breaks builds from linux/mac #46635

Closed
@lilith

Description

@lilith

Describe the bug

dotnet restore has broken restore logic around packages that just contain win-arm64 native binaries. Specifically, those native files don't get copied, which later crashes the build even though they're not used in the end. On Windows (even x64), they DO get copied, but on linux-x64/linux-arm64/osx, they do not. The error message is no help:

"GenerateDepsFile" task failed unexpectedly [..] error MSB4018: System.IO.FileNotFoundException: /Users/runner/.nuget/packages/imageflow.nativeruntime.win-arm64/2.1.0-rc01/runtimes/win-arm64/native/imageflow.dll

I was able to narrow this down by listing all native binaries in /Users/runner/.nuget/packages/imageflow.nativeruntime.* before and after dotnet restore.

Here's the workflow run, showing the failures. Only those with (os,true, [rid]) attempted the test.
https://github.com/imazen/imageflow-dotnet/actions/runs/13194655584

To Reproduce

Checkout https://github.com/imazen/imageflow-dotnet/tree/win-arm64-breaks-others
Execute tests/Imageflow.TestWebAOT/test.ps1

Or, depend on https://www.nuget.org/packages/Imageflow.NativeRuntime.win-arm64/2.1.0-rc01 (transitively) and try to build on a non-windows platform.

https://github.com/imazen/imageflow-dotnet/blob/21ee14fd051323185fc83a75527f8d593548fda5/tests/Imageflow.TestWebAOT/test.ps1

Special notes

On precisely one OS+sdk combo, if dotnet restore is run from /src - rather than silently failing to do its job - it provided this helpful NU1202 error

/home/lilith/.nuget/packages/imageflow.nativeruntime.win-x86_64/2.1.0-rc01/runtimes/win-x64/native/imageflow.dll
    /home/lilith/work/imageflow-dotnet/src/Imageflow.AllPlatforms/Imageflow.AllPlatforms.csproj : error NU1202: Package Imageflow.NativeRuntime.win-arm64 2.1.0-rc01 is not compatible with net8.0 (.NETCoreApp,Version=v8.0). Package Imageflow.NativeRuntime.win-arm64 2.1.0-rc01 supports: netstandard1.0 (.NETStandard,Version=v1.0)
    /home/lilith/work/imageflow-dotnet/src/Imageflow.AllPlatforms/Imageflow.AllPlatforms.csproj : error NU1202: Package Imageflow.NativeRuntime.win-arm64 2.1.0-rc01 is not compatible with netstandard2.0 (.NETStandard,Version=v2.0). Package Imageflow.NativeRuntime.win-arm64 2.1.0-rc01 supports: netstandard1.0 (.NETStandard,Version=v1.0)
    /home/lilith/work/imageflow-dotnet/src/Imageflow.AllPlatforms/Imageflow.AllPlatforms.csproj : error NU1202: Package Imageflow.NativeRuntime.win-arm64 2.1.0-rc01 is not compatible with net8.0 (.NETCoreApp,Version=v8.0) / linux-x64. Package Imageflow.NativeRuntime.win-arm64 2.1.0-rc01 supports: netstandard1.0 (.NETStandard,Version=v1.0)
    /home/lilith/work/imageflow-dotnet/src/Imageflow.AllPlatforms/Imageflow.AllPlatforms.csproj : error NU1202: Package Imageflow.NativeRuntime.win-arm64 2.1.0-rc01 is not compatible with netstandard2.0 (.NETStandard,Version=v2.0) / linux-x64. Package Imageflow.NativeRuntime.win-arm64 2.1.0-rc01 supports: netstandard1.0 (.NETStandard,Version=v1.0)

However, this error is not thrown on windows, and stuff just works. And this also brings up the question of HOW netstandard1.0 isn't compatible with .net8.0 or netstandard2.0, and why this is only true for this package with a runtimes/win-arm64/native/imageflow.dll file in it, and also only true when the SDK isn't on windows.

BIZARRELY, right after dotnet restore throws something possibly useful, a subsequent execution of dotnet publish silently does the wrong thing and then crashes as always.

Exception

Restore complete (0.6s)
  Imageflow.Net net8.0 succeeded (0.1s) → Imageflow/bin/Release/net8.0/Imageflow.Net.dll
  Imageflow.AllPlatforms net8.0 failed with 1 error(s) (0.3s)
    /usr/share/dotnet/sdk/9.0.102/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(322,5): error MSB4018: 
      The "GenerateDepsFile" task failed unexpectedly.
      System.IO.FileNotFoundException: /home/lilith/.nuget/packages/imageflow.nativeruntime.win-arm64/2.1.0-rc01/runtimes/win-arm64/native/imageflow.dll
         at System.Diagnostics.FileVersionInfo.GetVersionInfo(String fileName)

Further technical details

PS /home/lilith/work/imageflow-dotnet/tests/Imageflow.TestWebAOT> dotnet --info
.NET SDK:
 Version:           9.0.102
 Commit:            cb83cd4923
 Workload version:  9.0.100-manifests.43af17c7
 MSBuild version:   17.12.18+ed8c6aec5

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  22.04
 OS Platform: Linux
 RID:         linux-x64
 Base Path:   /usr/share/dotnet/sdk/9.0.102/

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

Host:
  Version:      9.0.1
  Architecture: x64
  Commit:       c8acea2262

.NET SDKs installed:
  6.0.424 [/usr/share/dotnet/sdk]
  7.0.410 [/usr/share/dotnet/sdk]
  8.0.405 [/usr/share/dotnet/sdk]
  9.0.102 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.12 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 8.0.12 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  DOTNET_ROOT       [/usr/lib/dotnet]

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions