Publishing .net core app on Raspberry PI5 - Stack Overflow

admin2025-04-17  2

I am this document to setup and deploy my first core application onto Raspberry Pi 5 Model B 16GB model.

I am using the dotnet publish --runtime linux-arm64 --self-contained command to publish as per documentation. I was able to successfully deploy binaries on to PI device using scp -r /C:/data/learning/pi/dotnet-core-pi5-deploy/bin/Release/net9.0/linux-arm64/publish/* hemant@backyard:/home/hemant/pi/dotnet-core-pi5-deploy

However, when I tried to execute ./dotnet-core-pi5-deploy.dll on PI device I was greeted with message:

-bash: ./dotnet-core-pi5-deploy.dll: cannot execute binary file: Exec format error

PI OS details:

cat /etc/os-release

  • PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
  • NAME="Debian GNU/Linux"
  • VERSION_ID="12"
  • VERSION="12 (bookworm)"
  • VERSION_CODENAME=bookworm
  • ID=debian
  • HOME_URL="/"
  • SUPPORT_URL=";
  • BUG_REPORT_URL="/"

**

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:     debian
 OS Version:  12
 OS Platform: Linux
 RID:         linux-arm64
 Base Path:   /home/hemant/.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: arm64
  Commit:       c8acea2262

.NET SDKs installed:
  9.0.102 [/home/hemant/.dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 9.0.1 [/home/hemant/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 9.0.1 [/home/hemant/.dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  DOTNET_ROOT       [/home/hemant/.dotnet]

global.json file:
  Not found

Learn more:
  

Download .NET:
  

Note: I was able to create/build and execute programs directly onto PI using core CLI.

  • dotnet new console
  • dotnet build
  • dotnet run

I am facing this issue only when deploying binaries from my DEV machine to PI.

Any pointers?

I am this document to setup and deploy my first .net core application onto Raspberry Pi 5 Model B 16GB model.

I am using the dotnet publish --runtime linux-arm64 --self-contained command to publish as per documentation. I was able to successfully deploy binaries on to PI device using scp -r /C:/data/learning/pi/dotnet-core-pi5-deploy/bin/Release/net9.0/linux-arm64/publish/* hemant@backyard:/home/hemant/pi/dotnet-core-pi5-deploy

However, when I tried to execute ./dotnet-core-pi5-deploy.dll on PI device I was greeted with message:

-bash: ./dotnet-core-pi5-deploy.dll: cannot execute binary file: Exec format error

PI OS details:

cat /etc/os-release

  • PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
  • NAME="Debian GNU/Linux"
  • VERSION_ID="12"
  • VERSION="12 (bookworm)"
  • VERSION_CODENAME=bookworm
  • ID=debian
  • HOME_URL="https://www.debian.org/"
  • SUPPORT_URL="https://www.debian.org/support"
  • BUG_REPORT_URL="https://bugs.debian.org/"

**

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:     debian
 OS Version:  12
 OS Platform: Linux
 RID:         linux-arm64
 Base Path:   /home/hemant/.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: arm64
  Commit:       c8acea2262

.NET SDKs installed:
  9.0.102 [/home/hemant/.dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 9.0.1 [/home/hemant/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 9.0.1 [/home/hemant/.dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  DOTNET_ROOT       [/home/hemant/.dotnet]

global.json file:
  Not found

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

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

Note: I was able to create/build and execute programs directly onto PI using .net core CLI.

  • dotnet new console
  • dotnet build
  • dotnet run

I am facing this issue only when deploying binaries from my DEV machine to PI.

Any pointers?

Share Improve this question asked Jan 31 at 6:46 user2243747user2243747 2,9778 gold badges46 silver badges66 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 1

Your command dotnet publish --runtime linux-arm64 creates several files in the output directory, among them the main application dll (dotnet-core-pi5-deploy.dll in your case) and a binary stub loader to execute the library (dotnet-core-pi5-deploy without extension). The later is the equivalent to the exe file that would be generated on windows (by convention, executable files have no extension on linux). That stub loader is actually a patched version of the dotnet binary.

To execute the program, you can thus run ./dotnet-core-pi5-deploy or call dotnet dotnet-core-pi5-deploy.dll. Both do exactly the same. Note that when you copy the output folder from windows to the Raspberry Pi, you need to set the executable bit, so before running ./dotnet-core-pi5-deploy call chmod +x dotnet-core-pi5-deploy once.

I was able to run this using dotnet dotnet-core-pi5-deploy.dll command. Not sure how create native executable for PI device.

转载请注明原文地址:http://anycun.com/QandA/1744877610a88893.html