Getting "You must install .NET Desktop Runtime 6.0.3 (x86)" with correct runtime installed

18.4k views Asked by At

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)

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:

dotnet --info output

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:

  1. Downloaded the Windows 11 dev virtual machine in Hyper-V.
  2. Removed .NET 6 with Visual Studio Installer.
  3. 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.

3

There are 3 answers

3
Étienne Laneville On BEST ANSWER

The Build process generates:

  1. assembly_name.deps
  2. assembly_name.pdb
  3. 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.

0
Kavoos Boushehri On

Also make sure to install ".NET Desktop Runtime" instead of ".NET Runtime" for WPF you can get it here for .NET 6

0
Ash K On

I ended up doing single-file deployment for my console app.

I modified my ProjectName.csproj like so:

<PropertyGroup>
  <TargetFramework>net6.0</TargetFramework>
  <!-- WinExe will hide the console window from appearing, so people won't close the app with X button. -->
  <OutputType>WinExe</OutputType>
  <!-- Prevent the app to publish files for languages other than english -->
  <SatelliteResourceLanguages>en</SatelliteResourceLanguages>
  <!-- Publish as single file -->
  <PublishSingleFile>true</PublishSingleFile>
  <SelfContained>true</SelfContained>
  <RuntimeIdentifier>win-x64</RuntimeIdentifier>
  <!-- To embed native binaries of the core runtime that are separate files into the single file. -->
  <IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
</PropertyGroup>

<!-- To remove .pdb files from the release build. -->
<PropertyGroup Condition="'$(Configuration)'=='Release'">
  <DebugSymbols>False</DebugSymbols>
  <DebugType>None</DebugType>
</PropertyGroup>