sdk: dotnet run fails on ARM64

dotnet run doesn’t work for me on Linux ARM64.

/cc @livarcocc @RussKeldorph

rich@live-pc:~/testapp$ uname -a
Linux live-pc 3.10.105-bsp-1.2 dotnet/sdk#4284 SMP PREEMPT Sat Oct 27 19:24:05 IST 2018 aarch64 aarch64 aarch64 GNU/Linux
rich@live-pc:~/testapp$ lsb_release -a
No LSB modules are available.
Distributor ID: neon
Description:    KDE neon User Edition 5.14
Release:        18.04
Codename:       bionic
rich@live-pc:~$ time dotnet new console -o testapp
The template "Console Application" was created successfully.

Processing post-creation actions...
Running 'dotnet restore' on testapp/testapp.csproj...
  Restoring packages for /home/rich/testapp/testapp.csproj...
  Generating MSBuild file /home/rich/testapp/obj/testapp.csproj.nuget.g.props.
  Generating MSBuild file /home/rich/testapp/obj/testapp.csproj.nuget.g.targets.
  Restore completed in 2 sec for /home/rich/testapp/testapp.csproj.

Restore succeeded.


real    0m17.732s
user    0m23.360s
sys     0m1.910s
rich@live-pc:~$ cd testapp/
rich@live-pc:~/testapp$ time dotnet build
Microsoft (R) Build Engine version 15.9.8-preview+g0a5001fc4d for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 342.77 ms for /home/rich/testapp/testapp.csproj.
/usr/share/dotnet/sdk/3.0.100-alpha1-009697/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.RuntimeIdentifierInference.targets(142,5): message NETSDK1057: You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview [/home/rich/testapp/testapp.csproj]
  testapp -> /home/rich/testapp/bin/Debug/netcoreapp3.0/testapp.dll

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

Time Elapsed 00:00:21.04

real    0m25.204s
user    0m25.080s
sys     0m2.180s
rich@live-pc:~/testapp$ time dotnet run
System.ComponentModel.Win32Exception (8): Exec format error
   at Interop.Sys.ForkAndExecProcess(String filename, String[] argv, String[] envp, String cwd, Boolean redirectStdin, Boolean redirectStdout, Boolean redirectStderr, Boolean setUser, UInt32 userId, UInt32 groupId, Int32& lpChildPid, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean shouldThrow) 
   at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at Microsoft.DotNet.Cli.Utils.Command.Execute()
   at Microsoft.DotNet.Tools.Run.RunCommand.Execute()
   at Microsoft.DotNet.Tools.Run.RunCommand.Run(String[] args)
   at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient)
   at Microsoft.DotNet.Cli.Program.Main(String[] args)

real    0m17.997s
user    0m23.190s
sys     0m2.150s
rich@live-pc:~/testapp$ time dotnet bin/Debug/netcoreapp3.0/testapp.dll
Hello World!

real    0m0.682s
user    0m0.570s
sys     0m0.060s
rich@live-pc:~/testapp$

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 25 (22 by maintainers)

Commits related to this issue

Most upvoted comments

I validated that this bug is now fixed, with 3.0.100-preview-009762.

This should now be fixed in 3.0.100-preview-009738. I don’t have an ARM device at the ready to test, but I did verify that the RID was correct in the bundled versions props file for arm tar.gz.

fyi, mine:

.NET Core SDK (reflecting any global.json):
 Version:   3.0.100-preview-009736
 Commit:    d273cdc5af

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  16.04
 OS Platform: Linux
 RID:         ubuntu.16.04-arm64
 Base Path:   /home/robox/brucefo/2/sdk/3.0.100-preview-009736/

Host (useful for support):
  Version: 3.0.0-preview-27106-02
  Commit:  410cba8501

.NET Core SDKs installed:
  3.0.100-preview-009736 [/home/robox/brucefo/2/sdk]

.NET Core runtimes installed:
  Microsoft.NETCore.App 3.0.0-preview-27106-02 [/home/robox/brucefo/2/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

I have one now, thanks!

The problem is that dotnet build is using NETCoreSdkRuntimeIdentifier to determine which apphost to use by default, which was incorrectly set to the host RID when building the .NET Core SDK for arm64 (thus ubuntu.16.04-x64 instead of linux-arm64 due to cross-building). dotnet run sees that an apphost was created by the build, so it attempts to exec it, resulting in the format error since this is x86-64 and not arm64.

This is a packaging issue for the .NET Core SDK, which is where NETCoreSdkRuntimeIdentifier is being set.

I’ll try to sync up with John and get the fix into dotnet/core-sdk.

The current theory is that the CLI/SDK have packaged an incorrect (probably x64) binary at some point.