An application built targeting .NET 6 is showing the following message when double-clicking the EXE in Windows Explorer:
To run this application, you must install .NET Desktop Runtime 6.0.3 (x86)
This runtime (6.0.3 x86) is installed on the machine though. I have confirmed this using the dotnet --info
command:
I also tried 6.0.4 runtimes but those didn't work either.
This happens on a Windows 10 machine but I also tested this on Windows 11:
- Downloaded the Windows 11 dev virtual machine in Hyper-V.
- Removed .NET 6 with Visual Studio Installer.
- Installed
windowsdesktop-runtime-6.0.3-win-x86
from Microsoft's Download .NET 6 page.
The same happens with the (Windows 10) MSIX Packaging Tool Environment machine you can download in Hyper-V. In this .NET 6 is not installed. Same result after installing windowsdesktop-runtime-6.0.3-win-x86
.
Setting the Target CPU option (in Project Properties > Compile) to Any CPU yields a similar result, asking for the .NET Desktop Runtime x64 version which I have also installed.
The Build process generates:
assembly_name.deps
assembly_name.pdb
assembly_name.runtimeconfig.json
I was able to launch the application by including the
runtimeconfig.json
file.With .NET Framework applications, it was possible to simply copy the EXE and DLLs but it seems like this is not possible with .NET Core applications.
A better approach is to use the Publish feature which can properly bundle all the necessary files into a single EXE for distribution.