-
Notifications
You must be signed in to change notification settings - Fork 985
Building for ARM64
Windows Forms does not officially support native ARM64 yet. Windows10 running on ARM64 includes x86 emulation, so x86 Windows Forms binaries will work on an ARM64 device. However, there have been requests for instructions on how to generate native ARM64 Windows Forms binaries, so here there are. 😄
We will be building an application called WinformsControlsTest, contained within in the repo.
- Clone the repo at https://github.com/dotnet/winforms (I only tested with the release/3.1 branch)
- Remove
.\src\System.Windows.Forms\tests\IntegrationTests\WinFormsControlsClassicTests\WinFormsControlsClassicTests.csproj
from WinForms.sln.- This project doesn't build right for arm64 and is just some old tests that are not required. Make sure to save the .sln.
- You can do this through Visual Studio by right clicking on the project in Solution Explorer and clicking on Remove
- You can also do this from the command line, see https://andrewlock.net/creating-and-editing-solution-files-with-the-net-cli/#removing-a-project-from-a-solution-file for details.
- NOTE: you have to install the sdk in step 3 below first
At this point, the instructions differ slightly depending on the architecture of the machine you are building on.
If you are building on an x64 machine, you can use the x64 .net core sdk:
-
Run
.\build
once in order to download/install the sdk specified in theglobal.json
-
Run
.\.dotnet\dotnet build -r win-arm64
- This will generate the winforms arm64 binaries. The folder we're interested in is at
.\artifacts\bin\WinformsControlsTest\Debug\netcoreapp3.1\win-arm64
- This will generate the winforms arm64 binaries. The folder we're interested in is at
-
Double click
WinformsControlsTest.exe
in the folder above. You should see a windows error that looks like this:This app can't run on your PC To find a version for your PC, check with the software publisher.
-
This means the exe is really built for arm! Copy the entire win-arm64 folder to an arm64 machine and double click on the exe. It should start up a form with buttons on it which you can click on to test the app.
If you are building on an arm64 machine, you must use the x86 .net core sdk:
- Install the x86 .net core SDK manually from https://dotnet.microsoft.com/download/dotnet-core/3.1.
- This is needed because the build scripts try to install the x64 one, which is wrong.
- You might also need to install the x86 sdk into the .dotnet folder, like this:
.\eng\common\dotnet-install.cmd -runtime "dotnet" -version "your.version.number" -architecture x86
- Change the versions in
global.json
to match the version you installed.- You should be changing tools.dotnet and sdk.version
- Run
.\.dotnet\x86\dotnet build -r win-arm64
- This will generate the winforms arm64 binaries. The folder we're interested in is at
.\artifacts\bin\WinformsControlsTest\Debug\netcoreapp3.1\win-arm64
- This will generate the winforms arm64 binaries. The folder we're interested in is at
- Double click
WinformsControlsTest.exe
in the folder above. It should start up a form with buttons on it which you can click on to test the app.
Note that the WinformsControlsTest is a self-contained app, meaning you don't need to install the .net core runtime for it to work. If you are developing a non-self-contained app, you will also need to install an appropriate runtime using something like this:
.\eng\common\dotnet-install.cmd -runtime "dotnet" -version "3.1.0-preview3.19551.4" -architecture arm64
Just replace version with the version of the runtime you want to install.
- Dependencies
- ARM64