In this section, you will configure and run your OrchardCore application on both Arm and x86 architectures using .NET’s AnyCPU configuration. This architecture-agnostic approach simplifies deployment and ensures that your application runs smoothly on diverse hardware, including cloud VMs, local development boxes, and edge devices.
The AnyCPU feature has existed since .NET Framework 2.0, but its current behavior (particularly how it handles 32-bit vs. 64-bit execution) was defined in .NET Framework 4.5.
In .NET Core and .NET 5+, AnyCPU still lets the runtime decide which architecture to use, but keep in mind that your build must match the runtime environment’s bitness (32-bit vs. 64-bit). Since .NET 8 targets 64-bit by default, this Learning Path assumes 64-bit runtime environments on both Arm64 and x86_64.
To make your OrchardCore application architecture-agnostic, configure the project to use the AnyCPU platform target. This allows the .NET runtime to select the appropriate architecture at runtime.
Open your OrchardCore project MyOrchardCoreApp.csproj
in your IDE.
Add the <PlatformTarget>
element to your existing <PropertyGroup>
:
<PropertyGroup>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
.csproj
file.You can now build your application once and run it on either an x86_64 or Arm64 system.
Build the application:
dotnet build -c Release
Run the application:
dotnet run --urls http://0.0.0.0:8080
Your application should now be runnable on any architecture. All you have to do is copy the MyOrchardCoreApp
directory to any computer with the .NET 8 runtime installed and run the command shown from within the MyOrchardCoreApp
directory:
dotnet ./bin/Release/net8.0/MyOrchardCoreApp.dll --urls http://0.0.0.0:8080
Using the AnyCPU configuration offers several advantages:
This approach ensures that your OrchardCore application runs consistently on both Arm and x86 architectures.