包使用 Desktop App Converter 的桌面应用程序Package a desktop application using the Desktop App Converter

获取桌面应用转换器Get the Desktop App Converter

Desktop App Converter (DAC) 创建包的桌面应用程序为与最新的 Windows 功能,包括分发和维护服务通过 Microsoft Store。The Desktop App Converter (DAC) creates packages for desktop applications to integrate with the latest Windows features, including distribution and servicing via the Microsoft Store. 这包括 Win32 应用和使用 .NET 4.6.1 创建的应用。This includes Win32 apps and apps that you've created by using .NET 4.6.1.

DAC 图标

尽管此工具名称中出现了“Converter”一词,但它实际上并不转换你的应用。While the term "Converter" appears in the name of this tool, it doesn't actually convert your app. 你的应用程序保持不变。Your application remains unchanged. 但是,此工具会生成一个带有应用包标识并能够调用各种 WinRT API 的 Windows 应用包。However, this tool generates a Windows app package with a package identity and the ability to call a vast range of WinRT APIs.

可以通过使用 Add-AppxPackage PowerShell cmdlet 在开发计算机上安装该程序包。You can install that package by using the Add-AppxPackage PowerShell cmdlet on your development machine.

转换器使用作为转换器下载的一部分提供的干净的基础映像在隔离的 Windows 环境中运行桌面安装程序。The converter runs the desktop installer in an isolated Windows environment by using a clean base image provided as part of the converter download. 它捕获桌面安装程序进行的任何注册表和文件系统 I/O,并将其作为输出的一部分打包。It captures any registry and file system I/O made by the desktop installer and packages it as part of the output.

重要

在 Windows 10,版本 1607,引入的功能来创建 Windows 应用程序包为桌面应用程序 (也称为桌面桥) 且不能仅用在面向 Windows 10 周年更新 (10.0; 项目Build 14393) 或更高版本在 Visual Studio 中的。The ability to create a Windows app package for your desktop application (otherwise known as the Desktop Bridge) was introduced in Windows 10, version 1607, and it can only be used in projects that target Windows 10 Anniversary Update (10.0; Build 14393) or a later release in Visual Studio.

备注

请观看 Microsoft Virtual Academy 发布的这一系列的视频短片。Checkout this series of short videos published by the Microsoft Virtual Academy. 这些视频演示了使用 Desktop App Converter 的一些常见方法。These videos walk you through some common ways to use the Desktop App Converter.

DAC 不仅能为你生成一个包The DAC does more than just generate a package for you

以下是它可以为你执行的其他一些操作。Here's a few extra things it can do for you.

Windows 10 创意者更新Windows 10 Creators Update

:heavy_check_mark:自动注册预览控件、缩略图处理程序、属性处理程序、防火墙规则、URL 标志。:heavy_check_mark: Automatically register your preview handlers, thumbnail handlers, property handlers, firewall rules, URL flags.

:heavy_check_mark:自动注册使用户能够使用“文件资源管理器”中的种类列对文件进行分组的文件类型映射。:heavy_check_mark: Automatically register file type mappings that enable users to group files by using the Kind column in File Explorer.

:heavy_check_mark:注册你的公共 COM 服务器。:heavy_check_mark: Register your public COM servers.

Windows 10 周年更新或更高版本Windows 10 Anniversary Update or later

:heavy_check_mark:自动对程序包进行签名,使你能够测试你的应用。:heavy_check_mark: Automatically sign your package so that you can test your app.

:heavy_check_mark:验证针对打包的应用和 Microsoft Store 要求应用程序。:heavy_check_mark: Validate your application against packaged app and Microsoft Store requirements.

若要查找完整的选项列表,请参阅本指南的参数部分。To find a complete list of options, see the Parameters section of this guide.

如果你已准备好创建应用包,那我们开始吧。If you're ready to create your package, let's start.

首先,准备应用程序First, prepare your application

在开始创建你的应用程序的包之前,请查看本指南:准备将桌面应用程序打包Review this guide before you begin creating a package for your application: Prepare to package a desktop application.

请确保你的系统可以运行转换器Make sure that your system can run the converter

请确保你的系统满足以下要求:Make sure that your system meets the following requirements:

启动 Desktop App ConverterStart the Desktop App Converter

  1. 下载并安装 Desktop App ConverterDownload and install the Desktop App Converter.

  2. 以管理员身份运行 Desktop App Converter。Run the Desktop App Converter as an administrator.

    以管理员身份运行 DAC

    会出现一个控制台窗口。A console window appears. 你需要使用该控制台窗口运行命令。You'll use that console window to run commands.

进行一些设置(仅限具有安装程序的应用)Set a few things up (apps with installers only)

你可以跳到下一部分如果你的应用程序不具有安装程序。You can skip ahead to the next section if your application doesn't have an installer.

  1. 识别操作系统的版本号。Identify the version number of your operating system.

    若要执行该操作,请在运行对话框中键入 winver,然后选择确定按钮。To do that, type winver in the Run dialog box, and then choose the OK button.

    winver

    你可以在关于 Windows 对话框中找到你的 Windows 版本。You'll find the version of your Windows build in the About Windows dialog box.

    Windows 10 版本

  2. 下载相应的 Desktop App Converter 基础映像Download the appropriate Desktop app Converter base image.

    确保文件名中显示的版本号与 Windows 内部版本的版本号相匹配。Make sure that the version number that appears in the name of the file matches the version number of your Windows build.

    重要

    如果使用的内部版本号15063,并且该生成的次版本等于或大于 .483 (例如:15063.540),请确保下载BaseImage 15063 UPDATE.wim文件。If you're using build number 15063, and the minor version of that build is equal to or greater than .483 (For example: 15063.540), make sure to download the BaseImage-15063-UPDATE.wim file. 如果该版本的次要版本小于 .483,请下载 BaseImage-15063.wim 文件。If the minor version of that build is less than .483, download the BaseImage-15063.wim file. 如果已设置此基文件的不兼容版本,则可以解决此问题。If you've already setup an incompatible version of this base file, you can fix it. 这篇博客文章介绍了如何解决此问题。This blog post explains how to do that.

  3. 将下载的文件放置在你稍后可在计算机上找到它的任意位置。Place the downloaded file anywhere on your computer where you'll be able to find it later.

  4. 在启动 Desktop App Converter 时出现的控制台窗口中,运行此命令:Set-ExecutionPolicy bypassIn the console window that appeared when you started the Desktop App Converter, run this command: Set-ExecutionPolicy bypass.

  5. 通过运行此命令设置转换器:DesktopAppConverter.exe -Setup -BaseImage .\BaseImage-1XXXX.wim -VerboseSet up the converter by running this command: DesktopAppConverter.exe -Setup -BaseImage .\BaseImage-1XXXX.wim -Verbose.

  6. 如果系统提示你重启计算机,请执行此操作。Restart your computer if you're prompted to do so.

    当转换器展开基础映像时,控制台窗口中会显示状态消息。Status messages appear in the console window as the converter expands the base image. 如果未看到任何状态消息,请按任意键。If you don't see any status messages, press any key. 此操作可以刷新控制台窗口的内容。This can cause the contents of the console window to refresh.

    控制台窗口中的状态消息

    当基础映像完全展开后,请转至下一部分。When the base image is fully expanded, move to the next section.

将应用打包Package an app

若要将应用打包,请在启动 Desktop App Converter 时打开的控制台窗口中运行 DesktopAppConverter.exe 命令。To Package your app, run the DesktopAppConverter.exe command in the console window that opened when you started the Desktop App Converter.

将使用参数来指定应用程序的包名称、 发布者和版本数。You'll specify the package name, publisher and version number of the application by using parameters.

备注

如果你已保留应用名称在 Microsoft Store 中的,你可以通过使用获取的包和发布服务器名称合作伙伴中心If you've reserved your app name in the Microsoft Store, you can obtain the package and publisher names by using Partner Center. 如果你打算将应用旁加载到其他系统上,只要选择的发布者名称与用于对应用进行签名的证书上的名称相匹配,就可以提供自己的名称。If you plan to sideload your app onto other systems, you can provide your own names for these as long as the publisher name that you choose matches the name on the certificate you use to sign your app.

命令参数概览A quick look at command parameters

以下是所需参数。Here are the required parameters.

DesktopAppConverter.exe
-Installer <String>
-Destination <String>
-PackageName <String>
-Publisher <String>
-Version <Version>

可以在此处阅读有关每个参数的信息。You can read about each one here.

示例Examples

以下是将应用打包的一些常见方法。Here's a few common ways to package your app.

包的应用程序的安装程序 (.msi) 文件Package an application that has an installer (.msi) file

使用 Installer 参数指向安装程序文件。Point to the installer file by using the Installer parameter.

DesktopAppConverter.exe -Installer C:\Installer\MyAppSetup.msi -Destination C:\Output\MyApp -PackageName "MyApp" -Publisher "CN=MyPublisher" -Version 0.0.0.1

重要

以下是在执行此操作时要记住的两个重要事项。There are two important things to keep in mind here. 首先,请确保安装程序位于独立文件夹中,并确保只有与该安装程序相关的文件位于同一文件夹中。First, make sure that your installer is located in an independent folder and that only files related to that installer are in the same folder. 转换器将该文件夹的所有内容复制到隔离的 Windows 环境中。The converter copies all of the contents of that folder to the isolated Windows environment.
其次,如果合作伙伴中心将标识分配给您以数字开头的软件包,请确保还传递中-AppId参数,以及如何使用字符串后缀将 (之后的时间段分隔符) 作为该参数的值。Secondly, if Partner Center assigns an identity to your package that begins with a number, make sure that you also pass in the -AppId parameter, and use only the string suffix (after the period separator) as the value of that parameter.

视频Video

如果你的安装程序包括相关库或框架的安装程序,则组织内容的方式可能略有不同。If your installer includes installers for dependent libraries or frameworks, you might have to organize things a bit a differently. 请参阅用桌面桥链连多个安装程序See Chaining multiple installers with the Desktop Bridge.

包具有一个安装程序可执行文件的应用程序Package an application that has a setup executable file

使用 Installer 参数指向安装程序可执行文件。Point to the setup executable by using the Installer parameter.

DesktopAppConverter.exe -Installer C:\Installer\MyAppSetup.exe -InstallerArguments "/S" -Destination C:\Output\MyApp -PackageName "MyApp" -Publisher "CN=MyPublisher" -Version 0.0.0.1

重要

如果合作伙伴中心将标识分配给您以数字开头的软件包,请确保还传递中-AppId参数,以及如何使用字符串后缀将 (之后的时间段分隔符) 作为该参数的值。If Partner Center assigns an identity to your package that begins with a number, make sure that you also pass in the -AppId parameter, and use only the string suffix (after the period separator) as the value of that parameter.

InstallerArguments 参数是可选参数。The InstallerArguments parameter is an optional parameter. 但是,由于 Desktop App Converter 需要安装程序,以在无人参与模式下运行,您可能需要使用它,如果应用程序需要无提示要以无提示方式运行的标志。However, because the Desktop App Converter needs your installer to run in unattended mode, you might have to use it if your application needs silent flags to run silently. /S 标志是十分常见的无提示标志,但你使用的标志可能有所不同,具体取决于用于创建安装程序文件的安装程序技术。The /S flag is a very common silent flag, but the flag that you use might be different depending on which installer technology you used to create the setup file.

视频Video

包不具有安装程序的应用程序Package an application that doesn't have an installer

在此示例中,使用Installer参数以指向你的应用程序文件的根文件夹。In this example, use the Installer parameter to point to the root folder of your application files.

使用 AppExecutable 参数指向应用可执行文件。Use the AppExecutable parameter to point to your apps executable file.

DesktopAppConverter.exe -Installer C:\Installer\MyApp\ -AppExecutable MyApp.exe -Destination C:\Output\MyApp -PackageName "MyApp" -Publisher "CN=MyPublisher" -Version 0.0.0.1

重要

如果合作伙伴中心将标识分配给您以数字开头的软件包,请确保还传递中-AppId参数,以及如何使用字符串后缀将 (之后的时间段分隔符) 作为该参数的值。If Partner Center assigns an identity to your package that begins with a number, make sure that you also pass in the -AppId parameter, and use only the string suffix (after the period separator) as the value of that parameter.

视频Video

将应用打包、对应用进行签名并对应用包运行验证检查Package an app, sign the app, and run validation checks on the package

此示例中是类似于第一个,但它显示的是如何进行本地测试应用程序进行签名,然后验证针对打包的应用和 Microsoft Store 要求应用程序。This example is similar to first one except it shows how you can sign your application for local testing, and then validate your application against packaged app and Microsoft Store requirements.

DesktopAppConverter.exe -Installer C:\Installer\MyAppSetup.exe -InstallerArguments "/S" -Destination C:\Output\MyApp -PackageName "MyApp" -Publisher "CN=MyPublisher" -Version 0.0.0.1 -MakeAppx -Sign -Verbose -Verify

重要

如果合作伙伴中心将标识分配给您以数字开头的软件包,请确保还传递中-AppId参数,以及如何使用字符串后缀将 (之后的时间段分隔符) 作为该参数的值。If Partner Center assigns an identity to your package that begins with a number, make sure that you also pass in the -AppId parameter, and use only the string suffix (after the period separator) as the value of that parameter.

Sign参数会生成一个证书,然后对其应用程序进行签名。The Sign parameter generates a certificate and then signs your application with it. 若要运行应用,你需要安装生成的证书。To run your app, you'll have to install that generated certificate. 若要了解如何操作,请参阅本指南的运行已打包的应用部分。To learn how, see the Run the packaged app section of this guide.

您可以通过使用验证你应用程序Verify参数。You can validate you application by using the Verify parameter.

可选参数概览A quick look at optional parameters

SignVerify 参数是可选参数。The Sign and Verify parameters are optional. 还有更多的可选参数。There are many more optional parameters. 以下是一些更常用的可选参数。Here are some of the more commonly used optional parameters.

[-ExpandedBaseImage <String>]
[-AppExecutable <String>]
[-AppFileTypes <String>]
[-AppId <String>]
[-AppDisplayName <String>]
[-AppDescription <String>]
[-PackageDisplayName <String>]
[-PackagePublisherDisplayName <String>]
[-MakeAppx]
[-LogFile <String>]
[<CommonParameters>]

可以在下一部分中阅读有关所有参数的信息。You can read about all of them in the next section.

参数引用Parameter Reference

以下是运行 Desktop App Converter 时可使用的参数的完整列表(按类别列出)。Here's the complete list of parameters (organized by category) that you can use when you run the Desktop App Converter.

还可以通过在应用控制台窗口中运行 Get-Help 命令来查看整个列表。You can also view the entire list by running the Get-Help command in the app console window.

安装程序参数 Setup parameters
-Setup [<SwitchParameter>]-Setup [<SwitchParameter>] 必需Required 在设置模式下运行 DesktopAppConverter。Runs DesktopAppConverter in setup mode. 设置模式支持扩展所提供的基本映像。Setup mode supports expanding a provided base image.
-BaseImage <String>-BaseImage <String> 必需Required 未扩展的基本映像的完整路径。Full path to an unexpanded base image. 如果指定 -Setup,则需要此参数。This parameter is required if -Setup is specified.
-LogFile <String>-LogFile <String> 可选Optional 指定日志文件。Specifies a log file. 如果省略,将创建一个日志文件临时位置。If omitted, a log file temporary location will be created.
-NatSubnetPrefix <String>-NatSubnetPrefix <String> 可选Optional 用于 Nat 实例的前缀值。Prefix value to be used for the Nat instance. 通常,仅在主机连接到与转换器的 NetNat 相同的子网范围时,你会希望更改此值。Typically, you would want to change this only if your host machine is attached to the same subnet range as the converter's NetNat. 你可以通过使用 Get-NetNat cmdlet 查询当前转换器 NetNat 配置。You can query the current converter NetNat config by using the Get-NetNat cmdlet.
-NoRestart [<SwitchParameter>]-NoRestart [<SwitchParameter>] 必需Required 在运行设置时不要提示重启(需要重启才能启用容器功能)。Don't prompt for reboot when running setup (reboot is required to enable the container feature).
转换参数 Conversion parameters
-AppInstallPath <String>-AppInstallPath <String> 可选Optional 应用程序针对已安装文件(如果已安装)的根文件夹的完整路径(例如“C:\Program Files (x86)\MyApp”)。The full path to your application's root folder for the installed files if it were installed (e.g., "C:\Program Files (x86)\MyApp").
-Destination <String>-Destination <String> 必需Required 如果转换器的 appx 输出的所需目标尚未存在,DesktopAppConverter 可以创建此位置。The desired destination for the converter's appx output - DesktopAppConverter can create this location if it doesn't already exist.
-Installer <String>-Installer <String> 必需Required 适用于应用程序的安装程序的路径 - 必须能够在无人参与/静默的情况下运行。The path to the installer for your application - must be able to run unattended/silently. 否-安装程序转换,这是为应用程序文件的根目录的路径。No-installer conversion, this is the path to the root directory of your application files.
-InstallerArguments <String>-InstallerArguments <String> 可选Optional 用于强制安装程序在无人参与/无提示的情况下运行的参数的逗号分隔列表或字符串。A comma-separated list or string of arguments to force your installer to run unattended/silently. 如果安装程序是 msi,则此参数为可选参数。This parameter is optional if your installer is an msi. 若要从安装程序中获取日志,请在此处为安装程序提供日志记录参数,并使用路径 <log_folder>,该路径是转换器使用相应路径所替换的标记。To get a log from your installer, supply the logging argument for the installer here and use the path <log_folder>, which is a token that the converter replaces with the appropriate path.

注意:无人参与/无提示标志和日志参数将在安装程序技术之间变化。NOTE: The unattended/silent flags and log arguments will vary between installer technologies.

此参数的用法示例:-InstallerArguments"/silent /log <log_folder>\install.log"不会生成一个日志文件的另一个示例可能如下所示:-InstallerArguments "/quiet", "/norestart" 同样,必须按原义定向到的令牌的路径的任何日志<log_folder>如果你想要捕获它并将其放在最后一个日志文件夹中的转换器。An example usage for this parameter: -InstallerArguments "/silent /log <log_folder>\install.log" Another example that doesn't produce a log file may look like: -InstallerArguments "/quiet", "/norestart" Again, you must literally direct any logs to the token path <log_folder> if you want the converter to capture it and put it in the final log folder.
-InstallerValidExitCodes <Int32>-InstallerValidExitCodes <Int32> 可选Optional 已成功运行的退出代码,以指示您的安装程序以逗号分隔列表 (例如:0、 1234、 5678)。A comma-separated list of exit codes that indicate your installer ran successfully (for example: 0, 1234, 5678). 默认情况下,对于非 msi,它为 0,对于 msi,它为 0, 1641, 3010。By default this is 0 for non-msi, and 0, 1641, 3010 for msi.
-MakeAppx [<SwitchParameter>]-MakeAppx [<SwitchParameter>] 可选Optional 一个告知此脚本对输出调用 MakeAppx 的开关(当存在时)。A switch that, when present, tells this script to call MakeAppx on the output.
-MakeMSIX [<SwitchParameter>]-MakeMSIX [<SwitchParameter>] 可选Optional 开关指示,当存在时,此脚本以打包形式 MSIX 包的输出。A switch that, when present, tells this script to package the output as an MSIX Package.
包标识参数Package identity parameters
-PackageName <String>-PackageName <String> 必需Required 通用 Windows 应用包的名称。The name of your Universal Windows App package. 如果合作伙伴中心将标识分配给您以数字开头的软件包,请确保还传递中-AppId参数,以及如何使用字符串后缀将 (之后的时间段分隔符) 作为该参数的值。If Partner Center assigns an identity to your package that begins with a number, make sure that you also pass in the -AppId parameter, and use only the string suffix (after the period separator) as the value of that parameter.
-Publisher <String>-Publisher <String> 必需Required 通用 Windows 应用程序包的发布者The publisher of your Universal Windows App package
-Version <Version>-Version <Version> 必需Required 通用 Windows 应用程序包的版本号The version number for your Universal Windows App package
包清单参数Package manifest parameters
-AppExecutable <String>-AppExecutable <String> 可选Optional 你的应用程序的主可执行文件的名称(“MyApp.exe”)。The name of your application's main executable (eg "MyApp.exe"). 无安装程序的转换需要使用此参数。This parameter is required for a no-installer conversion.
-AppFileTypes <String>-AppFileTypes <String> 可选Optional 应用程序将与其关联的文件类型的以逗号分隔的列表。A comma-separated list of file types which the application will be associated with. 用法示例:-AppFileTypes "'.md', '.markdown'"。Example usage: -AppFileTypes "'.md', '.markdown'".
-AppId <String>-AppId <String> 可选Optional 在 Windows 应用程序包清单中指定要将应用程序 ID 设置为的值。Specifies a value to set Application Id to in the Windows app package manifest. 如果未指定,则将其设置为 PackageName 传入的值。If it is not specified, it will be set to the value passed in for PackageName. 在许多情况下,使用 PackageName 很合适。In many cases, using the PackageName is fine. 但是,如果合作伙伴中心将标识分配给您以数字开头的软件包,请确保还传递中-AppId参数,以及如何使用字符串后缀将 (之后的时间段分隔符) 作为该参数的值。However, if Partner Center assigns an identity to your package that begins with a number, make sure that you also pass in the -AppId parameter, and use only the string suffix (after the period separator) as the value of that parameter.
-AppDisplayName <String>-AppDisplayName <String> 可选Optional 在 Windows 应用程序包清单中指定要将应用程序显示名称设置为的值。Specifies a value to set Application Display Name to in the Windows app package manifest. 如果未指定,则将其设置为 PackageName 传入的值。If it is not specified, it will be set to the value passed in for PackageName.
-AppDescription <String>-AppDescription <String> 可选Optional 在 Windows 应用程序包清单中指定要将应用程序描述设置为的值。Specifies a value to set Application Description to in the Windows app package manifest. 如果未指定,则将其设置为 PackageName 传入的值。If it is not specified, it will be set to the value passed in for PackageName.
-PackageDisplayName <String>-PackageDisplayName <String> 可选Optional 在 Windows 应用程序包清单中指定要将程序包显示名称设置为的值。Specifies a value to set Package Display Name to in the Windows app package manifest. 如果未指定,则将其设置为 PackageName 传入的值。If it is not specified, it will be set to the value passed in for PackageName.
-PackagePublisherDisplayName <String>-PackagePublisherDisplayName <String> 可选Optional 在 Windows 应用程序包清单中指定要将程序包发布者显示名称设置为的值。Specifies a value to set Package Publisher Display Name to in the Windows app package manifest. 如果未指定,则将其设置为 Publisher 传入的值。If it is not specified, it will be set to the value passed in for Publisher.
清除参数Cleanup parameters
-Cleanup [<Option>]-Cleanup [<Option>] 必需Required 为 DesktopAppConverter 项目运行清除。Runs cleanup for the DesktopAppConverter artifacts. 清除模式有 3 个有效的选项。There are 3 valid options for the Cleanup mode.
-Cleanup All-Cleanup All 删除所有已扩展的基本映像、删除任何临时转换器文件、删除容器网络并禁用可选的 Windows 功能,即容器。Deletes all expanded base images, removes any temporary converter files, removes the container network, and disables the optional Windows feature, Containers.
-Cleanup WorkDirectory-Cleanup WorkDirectory 必需Required 删除所有临时转换器文件。Removes all the temporary converter files.
-Cleanup ExpandedImage-Cleanup ExpandedImage 必需Required 删除安装在主机上的所有已扩展的基本映像。Deletes all the expanded base images installed on your host machine.
包体系结构参数Package architecture parameters
-PackageArch <String>-PackageArch <String> 必需Required 生成指定了体系结构的程序包。Generates a package with the specified architecture. 有效选项为“x86”或“x64”,例如 -PackageArch x86。Valid options are 'x86' or 'x64'; for example, -PackageArch x86. 该参数为可选参数。This parameter is optional. 如果未指定,DesktopAppConverter 将尝试自动检测程序包体系结构。If unspecified, the DesktopAppConverter will try to auto-detect package architecture. 如果自动检测失败,它将默认为 x64 程序包。If auto-detection fails, it will default to x64 package.
其他参数Miscellaneous parameters
-ExpandedBaseImage <String>-ExpandedBaseImage <String> 可选Optional 已扩展的基本映像的完整路径。Full path to an already expanded base image.
-LogFile <String>-LogFile <String> 可选Optional 指定日志文件。Specifies a log file. 如果省略,将创建一个日志文件临时位置。If omitted, a log file temporary location will be created.
-Sign [<SwitchParameter>]-Sign [<SwitchParameter>] 可选Optional 出于测试目的,告知此脚本使用生成的证书对输出 Windows 应用包进行签名。Tells this script to sign the output Windows app package by using a generated certificate for testing purposes. 此开关应该位于开关 -MakeAppx 旁边。This switch should be present alongside the switch -MakeAppx.
<通用参数><Common parameters> 必需Required 此 cmdlet 支持通用参数:详细调试ErrorActionErrorVariableWarningActionWarningVariableoutBufferPipelineVariable,并且OutVariableThis cmdlet supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer, PipelineVariable, and OutVariable. 有关详细信息,请参阅 about_CommonParametersFor more info, see about_CommonParameters.
-Verify [<SwitchParameter>]-Verify [<SwitchParameter>] 可选Optional 一个开关,当存在时,指示要验证针对打包的应用和 Microsoft Store 要求的应用包的 DAC。A switch that, when present, tells the DAC to validate the app package against packaged app and Microsoft Store requirements. 结果是一个“VerifyReport.xml”验证报告,该报告在浏览器中能够以最佳方式显示。The result is a validation report "VerifyReport.xml", which is best visualized in a browser. 此开关应该位于开关 -MakeAppx 旁边。This switch should be present alongside the switch -MakeAppx.
-PublishComRegistrations-PublishComRegistrations 可选Optional 扫描你的安装程序进行的所有公共 COM 注册,并发布你的清单中有效的注册。Scans all public COM registrations made by your installer and publishes the valid ones in your manifest. 仅当想使这些注册可供其他应用程序使用时才使用此标志。Use this flag only if you want to make these registrations available to other applications. 如果这些注册将仅由你的应用程序使用,则无需使用此标志。You don't need to use this flag if these registrations will be used only by your application.

请查看本文以确保在你将应用打包后,COM 注册会按预期工作。Review this article to make sure that your COM registrations behave as you expect after you package your app.

运行打包的应用Run the packaged app

可通过两种方法运行应用。There's two ways to run your app.

一种方法是打开 PowerShell 命令提示符,然后键入此命令:Add-AppxPackage –Register AppxManifest.xmlOne way is to open a PowerShell command prompt, and then type this command: Add-AppxPackage –Register AppxManifest.xml. 它可能是最简单的方法来运行应用程序,因为无需对其进行签名。It's probably the easiest way to run your application because you don't have to sign it.

另一种方法是应用程序使用证书进行签名。Another way is to sign your application with a certificate. 如果使用sign参数,Desktop App Converter 将生成一个,然后与其应用程序进行签名。If you use the sign parameter, the Desktop App Converter will generate one for you, and then sign your application with it. 该文件名为 auto-generated.cer,你可以在已打包应用的根文件夹中找到它。That file is named auto-generated.cer, and you can find it in the root folder of your packaged app.

请按照以下步骤安装生成的证书,然后运行应用。Follow these steps to install the generated certificate, and then run your app.

  1. 双击 auto-generated.cer 文件安装证书。Double-click the auto-generated.cer file to install the certificate.

    生成的证书文件

    备注

    如果系统提示你输入密码,请使用默认密码“123456”。If you're prompted for a password, use the default password "123456".

  2. 证书对话框中,选择安装证书按钮。In the Certificate dialog box, choose the Install Certificate button.

  3. 证书导入向导中,将证书安装到本地计算机上,并将证书放在受信任人证书存储区中。In the Certificate Import Wizard, install the certificate onto the Local Machine, and place the certificate into the Trusted People certificate store.

    “受信任人”存储区

  4. 在已打包应用的根文件夹中,双击 Windows 应用包文件。In root folder of your packaged app, double click the Windows app package file.

    Windows 应用包文件

  5. 选择安装按钮以安装应用。Install the app, by choosing the Install button.

    “安装”按钮

修改已打包的应用Modify the packaged app

您可能会对打包的应用程序处理 bug、 添加视觉对象资产,或增强应用程序的现代化体验,例如动态磁贴进行更改。You'll likely make changes to your packaged application to address bugs, add visual assets, or enhance your application with modern experiences such as live tiles.

进行更改之后,无需再次运行转换器。After you make your changes, you don't need to run the converter again. 在大多数情况下,您可以只使用重新打包你的应用程序 MakeAppx 工具并 appxmanifest.xml 文件 DAC 生成为你的应用。In most cases, you can just repackage your application by using the MakeAppx tool and the appxmanifest.xml file the DAC generates for your app. 请参阅生成 Windows 应用包See Generate a Windows app package.

备注

如果你对安装程序进行的注册表设置做出了更改,则需要再次运行 Desktop App Converter 以应用这些更改。If you make changes to registry settings that your installer makes, you will have to run the Desktop App Converter again to pick up those changes.

视频Videos

修改并重新打包输出Modify and repackage output 演示:修改并重新打包输出Demo: Modify and repackage output

以下两个部分介绍几种封装的应用程序可能要考虑到的可选链接地址。The following two sections describe a couple of optional fix-ups to the packaged application that you might consider.

删除不必要的文件和注册表项Delete unnecessary files and registry keys

Desktop App Converter 采用非常保守的方法来筛选掉容器中的文件和系统干扰。The desktop App Converter takes a very conservative approach to filtering out files and system noise in the container.

如有需要,可以查看 VFS 文件夹并删除安装程序不需要的任何文件。If you want, you can review the VFS folder and delete any files that your installer doesn't need. 还可以查看 Reg.dat 的内容并删除应用未安装/不需要的任何项。You can also review the contents of Reg.dat and delete any keys that are not installed/needed by the app.

修复损坏的 PE 头Fix corrupted PE headers

在转换过程中,DesktopAppConverter 将自动运行 PEHeaderCertFixTool 以修复任何损坏的 PE 头。During the conversion process, the DesktopAppConverter automatically runs the PEHeaderCertFixTool to fixup any corrupted PE headers. 但是,还可以在 UWP Windows 应用包、松散文件或特定的二进制文件上运行 PEHeaderCertFixTool。However, you can also run the PEHeaderCertFixTool on a UWP Windows app package, loose files, or a specific binary. 下面提供了一个示例。Here's an example.

PEHeaderCertFixTool.exe <binary file>|<.appx package>|<folder> [/c] [/v]
 /c   -- check for corrupted certificate but do not fix (optional)
 /v   -- verbose (optional)
example1: PEHeaderCertFixTool app.exe
example2: PEHeaderCertFixTool c:\package.appx /c
example3: PEHeaderCertFixTool c:\myapp /c /v

来自 Desktop App Converter 的遥测Telemetry from Desktop App Converter

Desktop App Converter 可以收集关于你和你使用该软件的情况的信息,并将此信息发送给 Microsoft。Desktop App Converter may collect information about you and your use of the software and send this info to Microsoft. 你可以在产品文档和 Microsoft 隐私声明中了解有关 Microsoft 的数据收集和使用的详细信息。You can learn more about Microsoft's data collection and use in the product documentation and in the Microsoft Privacy Statement. 你同意遵守《Microsoft 隐私声明》的所有适用条款。You agree to comply with all applicable provisions of the Microsoft Privacy Statement.

默认情况下,将为 Desktop App Converter 启用遥测。By default, telemetry will be enabled for the Desktop App Converter. 添加以下注册表项以将遥测配置为所需设置:Add the following registry key to configure telemetry to a desired setting:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DesktopAppConverter
  • 通过使用设置为 1 的 DWORD 来添加或编辑 DisableTelemetry 值。Add or edit the DisableTelemetry value by using a DWORD set to 1.
  • 若要启用遥测,请删除该项或将值设置为 0。To enable telemetry, remove the key or set the value to 0.

语言支持Language support

Desktop App Converter 不支持 Unicode;因此,没有用于该工具的任何中文字符或非 ASCII 字符。The Desktop App Converter does not support Unicode; thus, no Chinese characters or non-ASCII characters can be used with the tool.

后续步骤Next steps

查找问题的答案Find answers to your questions

有问题?Have questions? 请在 Stack Overflow 上向我们提问。Ask us on Stack Overflow. 我们的团队会监视这些标记Our team monitors these tags. 你还可以在此处提问。You can also ask us here.

你还可以参考已知问题列表。You can also refer to this list of known issues.

提供反馈或提出功能建议Give feedback or make feature suggestions

请参阅 UserVoiceSee UserVoice.

运行应用程序 / 查找并修复问题Run your application / find and fix issues

请参阅运行、 调试和测试打包桌面应用程序See Run, debug, and test a packaged desktop application

将应用分发Distribute your app

请参阅分发打包桌面应用程序See Distribute a packaged desktop application