How to build WinDirStat for Windows 10 on ARM

WinDirStat is a 32-bit x86 app, so it can already run through emulation on Windows 10 on ARM. However, it is surprisingly easy to build an ARM-native version of the app. I thought it'd be fun to try, so here's what worked for me.

First, you'll need to install Visual Studio. I used Visual Studio 2022 Preview 1.1 for this, but things should work in Visual Studio 2019 as well. Importantly, within Visual Studio Installer, you need to select the Desktop Development with C++ workload, and in the optional components you need to select MFC, specifically for ARM. You can find it by searching for ARM MFC in the Individual components screen. You should install MFC for x86 as well to verify that you can build WinDirStat in its default configuration.

Once you have Visual Studio installed, you need to download the WinDirStat source code. When I did it, it was hosted on OSDN as a mercurial repository, so I installed mercurial and cloned the repository. With the source code in hand, all I had to do was open the Visual Studio solution file.

First things first, change the dropdowns at the top to Release and Win32 and then choose Build -> Build Solution. This should succeed as a baseline to confirm that you installed Visual Studio correctly. If you get errors, you may have missed certain components such as MFC - close Visual Studio and run Visual Studio Installer and Modify the install to add the missing components.

Now comes the the big part - porting this complicated x86 app to ARM. Get ready...
  1. Go to Build -> Configuration Manager
  2. At the top right, click in the Active Solution Configuration dropdown and click <New...>
  3. Make sure ARM is selected as well as "Create new project platforms" and click OK
  4. Click the Close button in the dialog from Step 2.
  5. Right click on the WinDirStat project in the Solution Explorer and choose Properties
  6. Make sure the dropdowns at the top say "All Configurations" and "ARM", then navigate to Linker -> General and change Link Library Dependencies to No, then click OK
  7. Now, in the Solution Explorer, expand the WinDirStat project -> Source Files -> Lua -> Right click on WDS_Lua_C.c and choose Properties
  8. Make sure the dropdowns at the top say "All Configurations" and "ARM", then in the General section, change "Excluded From Build" to Yes, then click OK
Congratulations, you have just ported WinDirStat to ARM! You can choose Build -> Build Solution and you will end up with a wds32.exe file in the Release subdirectory of the ARM directory. You will also get a lot of build errors from the Lua projects, but don't worry, they aren't necessary.
And that's that! Porting complex apps to ARM really is that simple in many cases. I tested the resulting executable on my Lenovo Miix 630 - the only Windows 10 on ARM device I own currently - and it worked fine. Though, apparently the latest WinDirStat source code I checked out had some minor bugs even in the x86 version. Still, this is cool!