了解安装程序Know your installer

本文列出了在将现有的安装程序转换为 .MSIX 之前需要了解的知识。This article lists the things you need to know before you convert your existing installer into an MSIX. 你可能无需执行任何操作即可为打包过程准备好应用程序,但如果以下任何项适用于你的应用程序,则需要在打包之前解决。You might not have to do much to get your application ready for the packaging process, but if any of the items below applies to your application, you need to address it before packaging.

  • 应用程序具有服务Your application has a service. 我们支持 使用服务转换应用程序,但务必要记住转换服务的 限制We support converting applications with services, but its important to keep in mind the limitations to converting a service. 转换后,需要管理员提升才能安装包含服务的 .MSIX。After conversion, you will need admin elevation in order to install the MSIX that contains a service. 可以从 .MSIX 打包工具版本1.2019.1220.0 开始,使用服务转换应用程序,并且可以在 Windows 10 春季2020发行版中从部署 .MSIX。You can convert an application with services beginning in version 1.2019.1220.0 of the MSIX Packaging Tool, and you can deploy the MSIX with services beginning in the spring 2020 release of Windows 10.

  • 安装程序需要重新启动Your installer requires a restart. 如果安装程序需要 重新启动,则从版本1.2019.701.0 开始,.Msix 打包工具支持此项。If your installer requires a restart, this is supported in the MSIX Packaging Tool beginning in version 1.2019.701.0. 如果安装程序返回一个不常见的退出代码以指示它需要重新启动,则应将其添加到 .MSIX 打包工具设置的 重新启动退出代码 部分。If your installer returns an uncommon exit code to indicate it needs a restart, you should add it to the restart exit codes section of the MSIX Packaging Tool settings.

  • 你的 .net 应用程序需要 .NET Framework 早于4.6.2 的版本Your .NET application requires a version of the .NET Framework earlier than 4.6.2. 如果正在打包 .NET 应用程序,我们建议将应用程序目标 .NET Framework 4.6.2 或更高版本。If you are packaging a .NET application, we recommend that your application target .NET Framework 4.6.2 or later. 安装和运行打包的桌面应用程序的功能在 Windows 10 中首次引入,版本 1607 (也称为周年更新) ,此 OS 版本在默认情况下包括 .NET Framework 4.6.2。The ability to install and run packaged desktop applications was first introduced in Windows 10, version 1607 (also called the Anniversary Update), and this OS version includes the .NET Framework 4.6.2 by default. 更高版本的操作系统包括 .NET Framework 的更高版本。Later OS versions include later versions of the .NET Framework. 有关更高版本的 Windows 10 中包含的 .NET 版本的完整列表,请参阅 此文For a full list of what versions of .NET are included in later versions of Windows 10, see this article.

    在大多数情况下,适用于打包桌面应用程序中4.6.2 之前的 .NET Framework 的目标版本应能正常工作。Targeting versions of the .NET Framework earlier than 4.6.2 in packaged desktop applications is expected to work in most cases. 但是,如果面向的是比4.6.2 更早的版本,则应在将打包的桌面应用程序分发给用户之前对其进行完整的测试。However, if you target an earlier version than 4.6.2, you should fully test your packaged desktop application before distributing it to users.

    • 4.0-4.6.1:面向这些版本的 .NET Framework 的应用程序应在4.6.2 或更高版本上运行,而不会出现任何问题。4.0 - 4.6.1: Applications that target these versions of the .NET Framework are expected to run without issues on 4.6.2 or later. 因此,这些应用程序应在 Windows 10 版本1607或更高版本上安装和运行,并附带操作系统附带的 .NET Framework 版本。Therefore, these applications should install and run without changes on Windows 10, version 1607 or later with the version of the .NET Framework that is included with the OS.

    • 2.0 和3.5:在我们的测试中,以这些版本的 .NET Framework 为目标的打包桌面应用程序通常可以运行,但在某些情况下可能会出现性能问题。2.0 and 3.5: In our testing, packaged desktop applications that target these versions of the .NET Framework generally work but may exhibit performance issues in some scenarios. 为了安装和运行这些打包的应用程序,必须在目标计算机上安装 .NET Framework 3.5 功能 (此功能还包括 .NET Framework 2.0 和 3.0) 。In order for these packaged applications to install and run, the .NET Framework 3.5 feature must be installed on the target machine (this feature also includes .NET Framework 2.0 and 3.0). 打包后,还应彻底测试这些应用程序。You should also test these applications thoroughly after you package them.

  • 应用程序需要驱动程序Your application requires a driver. .MSIX 不支持驱动程序。MSIX does not support drivers.

  • 应用程序将数据写入 AppData 文件夹或注册表,目的是与另一个应用程序共享数据Your application writes to the AppData folder or to the registry with the intention of sharing data with another app. 转换后,AppData 将重定向到本地应用数据存储,每个应用都是专用存储。After conversion, AppData is redirected to the local app data store, which is a private store for each app.

    应用程序写入 HKEY_LOCAL_MACHINE 注册表配置单元的所有项都将重定向到一个独立的二进制文件,并且应用程序写入 HKEY_CURRENT_USER 注册表配置单元的所有项都将放置到专用的每个用户、每个应用的位置。All entries that your application writes to the HKEY_LOCAL_MACHINE registry hive are redirected to an isolated binary file and any entries that your application writes to the HKEY_CURRENT_USER registry hive are placed into a private per-user, per-app location. 有关文件和注册表重定向的更多详细信息,请参阅在桌面桥幕后For more details about file and registry redirection, see Behind the scenes of the Desktop Bridge.

  • 您的应用程序将写入您的应用程序的安装目录Your application writes to the install directory for your app. 例如,你的应用程序将写入日志文件,并将其放入你的 exe 所在的同一目录中。For example, your application writes to a log file that you put in the same directory as your exe. 这不受支持,因为文件夹受到保护。This isn't supported because the folder is protected. 建议写入到其他位置,例如本地应用数据存储。We recommend writing to another location like the local app data store. 我们添加了一项功能,该功能允许在1809和更高版本中使用。We have added a capability that allows this in 1809 and later.

  • 应用程序使用当前工作目录Your application uses the current working directory. 在运行时,打包的桌面应用程序将不会获得你先前在桌面中指定的工作目录。.LNK 快捷方式。At runtime, your packaged desktop application won't get the same working directory that you previously specified in your desktop .LNK shortcut. 如果要使应用程序正常运行,则需要在运行时更改 CWD。You need to change your CWD at runtime if having the correct directory is important for your application to function correctly.

  • 应用程序从 Windows 并行文件夹中安装和加载程序集Your application installs and loads assemblies from the Windows side-by-side folder. 例如,你的应用程序使用 C 运行时库 VC8 或 VC9,并从 Windows 并行文件夹动态链接它们,这意味着你的代码将使用共享文件夹中的常用 DLL 文件,例如 C:\Windows\WinSxS.。For example, your application uses C runtime libraries VC8 or VC9 and is dynamically linking them from Windows side-by-side folder, meaning your code is using the common DLL files from a shared folder, such as C:\Windows\WinSxS. 此操作不受支持。This is not supported. 你将需要静态链接它们,方法是将可再发行库文件直接链接到你的代码中。You will need to statically link them by linking to the redistributable library files directly into your code.

    备注

    如果你的应用程序需要写入安装目录或使用当前工作目录,则还可以考虑使用包 支持框架 将运行时链接添加到包。If your app needs to write to the installation directory or use the current working directory, you can also consider adding a runtime fixup using the Package Support Framework to your package. 有关详细信息,请参阅本文For more details, see this article.