Reputation: 2967
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
**
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.
I am facing this issue only when deploying binaries from my DEV machine to PI.
Any pointers?
Upvotes: 1
Views: 94
Reputation: 17288
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.
Upvotes: 1
Reputation: 2967
I was able to run this using dotnet dotnet-core-pi5-deploy.dll
command. Not sure how create native executable for PI device.
Upvotes: 0