4

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.

Étienne Laneville
  • 4,697
  • 5
  • 13
  • 29

3 Answers3

4

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.

Étienne Laneville
  • 4,697
  • 5
  • 13
  • 29
  • This works for my WinForms port! Just clarifying: the author does note that the .NET *Desktop* Runtime is needed, and also these files go to the same location as the EXE. – batpox Sep 05 '22 at 23:54
  • Ooh, are we saying copy the files from the dotnet folder into the application folder??? – Denis G. Labrecque May 03 '23 at 11:55
  • 1
    @DenisG.Labrecque this is what I ended up doing: [Single-file deployment](https://learn.microsoft.com/en-us/dotnet/core/deploying/single-file/overview?tabs=cli) – Étienne Laneville May 03 '23 at 14:20
1

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

0

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>
Ash K
  • 1,802
  • 17
  • 44