Fixing Missing Windows App Runtime Environment Prompt for Unpackaged WinUI 3 Applications

this article will guide you on how to resolve the issue of a missing windows app runtime environment prompt when running non-packaged winui 3 applications on a customer's machine.

The prompt for a missing Windows App Runtime environment on the user's machine appears as follows:

Fixing Missing Windows App Runtime Environment Prompt for Unpackaged WinUI 3 Applications alt="Fixing Missing Windows App Runtime Environment Prompt for Unpackaged WinUI 3 Applications" />By clicking "Yes," you will be directed to the download page at https://www.php.cn/link/460eb45f1f9b67a58c96a73be551f37b.

To resolve this issue, you can download and install the Windows App Runtime installation package, known as WindowsAppRuntimeInstall.exe.

However, requiring users to install additional files like WindowsAppRuntimeInstall.exe is not ideal for an application. This article will explain how to configure WinUI 3 applications to function like traditional Win32 applications, allowing them to be simply copied and run on a user's machine.

Step 1: Ensure that the Microsoft.WindowsAppSDK NuGet package is at version 1.2 or later. As of June 15, 2023, the latest version available is 1.3.230602002. The WindowsAppSdkUndockedRegFreeWinRTInitialize feature, which helps avoid the aforementioned prompt, was introduced in version 1.2.

Step 2: Modify the csproj project file by setting WindowsAppSDKSelfContained to true and WindowsPackageType to None. When these settings are configured as such, the SDK automatically sets WindowsAppSdkUndockedRegFreeWinRTInitialize to true.

The updated csproj project file would look like this:

<project sdk="Microsoft.NET.Sdk">  <propertygroup>    <outputtype>WinExe</outputtype>    <targetframework>net6.0-windows10.0.19041</targetframework>    <nullable>enable</nullable>    <usewinui>true</usewinui>    <platforms>x86;x64;x86</platforms>    <runtimeidentifiers>win10-x86;win10-x64</runtimeidentifiers>    <windowsappsdkselfcontained>true</windowsappsdkselfcontained>    <windowspackagetype>None</windowspackagetype>  </propertygroup>  <itemgroup>    <packagereference include="Microsoft.WindowsAppSDK" version="1.3.230602002"></packagereference>    <packagereference include="Microsoft.Windows.SDK.BuildTools" version="10.0.22621.756"></packagereference>  </itemgroup></project>

登录后复制

文章来自互联网,不代表电脑知识网立场。发布者:,转载请注明出处:https://www.pcxun.com/n/649966.html

(0)
上一篇 2025-05-24 10:05
下一篇 2025-05-24 10:05

相关推荐