登录
首页 >  文章 >  软件教程

修复WinUI3应用缺失WindowsApp运行时环境提示

时间:2025-05-15 20:28:17 288浏览 收藏

本文详细介绍了如何解决在客户机器上运行非打包的WinUI 3应用程序时,缺少Windows App运行时环境提示的问题。通过确保使用Microsoft.WindowsAppSDK NuGet包的最新版本,并修改csproj项目文件中的特定设置,可以使WinUI 3应用程序像传统的Win32应用程序一样运行,无需用户额外安装Windows App运行时环境。文章提供了具体的步骤和配置示例,帮助开发者轻松实现这一目标。

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 ApplicationsBy clicking "Yes," you will be directed to the download page at https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/downloads.

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:


  
    WinExe
    net6.0-windows10.0.19041
    enable
    true
    x86;x64;x86
    win10-x86;win10-x64
    true
    None
  
  
    
    
  

After applying these modifications, you can publish the application independently, eliminating the need for users to install the Windows App Runtime environment. The application can be run by simply double-clicking it.

Due to the limited official documentation available on WindowsAppSdkUndockedRegFreeWinRTInitialize and UndockedRegFreeWinRT, I am not well-versed in their specifics. If you're interested in learning more, I recommend further exploration on your own.

终于介绍完啦!小伙伴们,这篇关于《修复WinUI3应用缺失WindowsApp运行时环境提示》的介绍应该让你收获多多了吧!欢迎大家收藏或分享给更多需要学习的朋友吧~golang学习网公众号也会发布文章相关知识,快来关注吧!

相关阅读
更多>
最新阅读
更多>
课程推荐
更多>