DISM 应用包(.appx 或 .appxbundle)服务命令行选项DISM App Package (.appx or .appxbundle) Servicing Command-Line Options

你可以使用应用程序包服务命令在 Windows 映像中添加、删除和列出预配的应用程序包(.appx 或 .appxbundle)。You can use app package-servicing commands to add, remove, and list provisioned app packages (.appx or .appxbundle) in a Windows image. 用于 Windows 10 的一个 .appxbundle 是一系列应用程序和资源包,它们一起用于丰富应用程序体验,同时最大限度地减少了给定 PC 上的磁盘占用量。An .appxbundle, new for Windows 10, is a collection of app and resource packages used together to enrich the app experience, while minimizing the disk footprint on a given PC. 有关 .appxbundle 包和 Microsoft Store 管道的详细文档,请参阅应用打包For detailed documentation about .appxbundle packages and the Microsoft Store pipeline, see App packaging. 使用 DISM 预配捆绑时,只能将一个 .appxbundle 中的包子集添加到映像。Only a subset of the packages within an .appxbundle might be added to the image when a bundle is provisioned using DISM. 有关详细信息,请参阅了解 DISM 如何将 .Appxbundle 资源包添加到映像For more information, see Understanding How DISM Adds .appxbundle Resource Packages to an Image.

预配的应用程序包将添加到 Windows 映像,并在下次用户登录时为每个新的或现有的用户配置文件进行安装。Provisioned app packages are added to a Windows image and are then installed for every new or existing user profile the next time the user logs on. 有关详细信息,包括应用程序包预配的要求,请参阅旁加载 Apps WITH DISMFor more information, including requirements for app package provisioning, see Sideload Apps with DISM.

你还可以使用 PowerShell 在 Windows 安装中添加、删除和列出每个映像或每个用户的应用程序包(.appx 或 .appxbundle)。You can also use PowerShell to add, remove, and list app packages (.appx or .appxbundle) per image or per user in a Windows installation. 有关详细信息,请参阅 windows powershell 中的部署映像服务管理(DISM) cmdletwindows Powershell 中的应用安装 cmdletFor more information, see Deployment Imaging Servicing Management (DISM) Cmdlets in Windows PowerShell and App Installation Cmdlets in Windows PowerShell.

使用 DISM 为 Windows 映像提供服务的基本语法是:The base syntax for servicing a Windows image using DISM is:

Dism.exe {/image: < * _ 指向 _ 图像 _ 目录的路径* > | /online} [ DISM _ 全局 _ 选项 ] {维护 _ 选项} [ < 服务 _ 参数>]DISM.exe {/Image:<path_to_image_directory> | /Online} [dism_global_options] {servicing_option} [<servicing_argument>]

以下应用包(.appx 或 .appxbundle)服务选项可用于脱机映像。The following app package (.appx or .appxbundle) servicing options are available for an offline image.

Dism.exe/image: <* _ _ 映像文件 _ 的路径* > [ /Get-ProvisionedAppxPackages | /Add-ProvisionedAppxPackage | /Remove-ProvisionedAppxPackage | /Set-ProvisionedAppxDataFile | /StubPackageOption]DISM.exe /Image:<path_to_image_directory> [/Get-ProvisionedAppxPackages | /Add-ProvisionedAppxPackage | /Remove-ProvisionedAppxPackage | /Set-ProvisionedAppxDataFile | /StubPackageOption]

以下应用包(.appx 或 .appxbundle)服务选项可用于正在运行的操作系统。The following app package (.appx or .appxbundle) servicing options are available for a running operating system.

Dism.exe/online [/Get-ProvisionedAppxPackages | /Add-ProvisionedAppxPackage | /Remove-ProvisionedAppxPackage | /Set-ProvisionedAppxDataFile | /StubPackageOption]DISM.exe /Online [/Get-ProvisionedAppxPackages | /Add-ProvisionedAppxPackage | /Remove-ProvisionedAppxPackage | /Set-ProvisionedAppxDataFile | /StubPackageOption]

应用包服务选项App package servicing options

下表介绍了如何使用每个应用服务选项。This table describes how you can use each app servicing option. 这些选项不区分大小写。These options are not case sensitive.

服务选项Servicing option 说明Description 示例Example
/Get-Help /?/Get-Help /? 在应用程序包服务命令行选项后立即使用时,将显示有关该选项和参数的信息。When used immediately after an app package servicing command-line option, information about the option and the arguments is displayed. 指定映像后,其他主题可能会变得可用。Additional topics might become available when an image is specified. Dism /image:C:\test\offline /Add-ProvisionedAppxPackage /?

Dism /online /Get-ProvisionedAppxPackages /?
/Get-ProvisionedAppxPackages/Get-ProvisionedAppxPackages 显示有关映像中应用程序包(.appx 或 .appxbundle)的信息,这些包设置为为每个新用户安装。Displays information about app packages (.appx or .appxbundle), in an image, that are set to install for each new user. Dism /Image:C:\test\offline /Get-ProvisionedAppxPackages
/Add-ProvisionedAppxPackage/Add-ProvisionedAppxPackage 将一个或多个应用程序包添加到映像。Adds one or more app packages to the image.

此应用将添加到 Windows 映像,并在下次用户登录时为每个现有的或新的用户配置文件进行注册。The app will be added to the Windows image and registered for each existing or new user profile the next time the user logs in. 如果将应用添加到联机映像,则在用户下次登录之前,将不会为当前用户注册应用。If the app is added to an online image, the app will not be registered for the current user until the next time the user logs in.

建议在审核模式下的联机操作系统中预配应用程序,以便可以为包含完全相同的文件的应用创建适当的硬链接(以最大程度地减少磁盘空间使用情况),同时确保没有应用运行成功安装。It is recommended to provision apps in an online operating system in audit mode so that appropriate hard links can be created for apps that contain the exact same files (to minimize disk space usage) while also ensuring no apps are running for a successful installation.

语法:dism.exe /Add-ProvisionedAppxPackage {/FolderPath:<App_folder_path> [/SkipLicense\] [/CustomDataPath:<custom_file_path>] /PackagePath:<main_package_path> [/DependencyPackagePath:<dependency_package_path>] {[/LicenseFile:<license_file_path>] [/SkipLicense\]} [/CustomDataPath:<custom_file_path>]} [/Region:<region>]Syntax: dism.exe /Add-ProvisionedAppxPackage {/FolderPath:<App_folder_path> [/SkipLicense\] [/CustomDataPath:<custom_file_path>] /PackagePath:<main_package_path> [/DependencyPackagePath:<dependency_package_path>] {[/LicenseFile:<license_file_path>] [/SkipLicense\]} [/CustomDataPath:<custom_file_path>]} [/Region:<region>]

使用 /FolderPath指定包含主包、任何依赖项包和许可证文件的解包应用程序文件的文件夹。Use /FolderPath to specify a folder of unpacked app files containing a main package, any dependency packages, and the license file. 只有解包的应用包才支持这种情况。This is only supported for an unpacked app package.

使用 /packagepath指定应用包(.appx 或 .appxbundle)。Use /PackagePath to specify an app package (.appx or .appxbundle). 在联机预配业务线应用时,可以使用 /packagepathYou can use /PackagePath when provisioning a line-of-business app online.

重要提示:使用 /packagepath参数设置 .appxbundle 包。Important: Use the /PackagePath parameter to provision .appxbundle packages. 此外,不能使用 /packagepath设置依赖项包,必须使用应用程序的 /DependencyPackagePath参数对它们进行设置。Also, dependency packages cannot be provisioned with /PackagePath, they must be provisioned with the /DependencyPackagePath parameter for an app.

运行 Windows 预安装环境(WinPE)4.0、Windows Server 2008 R2 或更早版本的 Windows 的主机不支持 /packagepath/PackagePath is not supported from a host PC that is running Windows Preinstallation Environment (WinPE) 4.0, Windows Server 2008 R2, or an earlier version of Windows.

使用 /Region指定必须在其中预配应用包(.appx 或 .appxbundle)的区域。Use /Region to specify what regions an app package (.appx or .appxbundle) must be provisioned in. 区域参数可以为 "全部",指示应为所有区域设置应用,也可以是以分号分隔的区域列表。The region argument can either be “all”, indicating that the app should be provisioned for all regions, or it can be a semi-colon delimited list of regions. 区域将采用ISO 3166-1 alpha-2 或 iso 3166-1 3 号格式。The regions will be in the form of ISO 3166-1 Alpha-2 or ISO 3166-1 Alpha-3 codes. 例如,可以将美国指定为 "US" 或 "USA" (不区分大小写)。For example, the United States can be specified as either "US" or "USA" (case-insensitive). 如果未指定区域列表,则只有在将包固定到 "开始布局" 时,才会对其进行设置。When a list of regions is not specified, the package will be provisioned only if it is pinned to start layout.

使用 /DependencyPackagePath指定要设置的应用所需的每个 depencency 包。Use /DependencyPackagePath to specify each depencency package needed for the app to be provisioned. 可以通过查看 应用的 .appx 包的根目录中的 appxmanifest.xml 元素来查找应用的必要依赖项包。The necessary dependency packages of an app can be found by looking at the elements in the AppxManifest.xml in the root of the .appx package of the app. 如果多个应用共用相同的依赖项,则应安装依赖项包的每个主版本的最新次要版本。If multiple apps all share the same dependency, the latest minor version of each major version of the dependency package should be installed. 例如,App1、App2 和 App3 都具有对的依赖关系。For example, App1, App2, and App3 all have a dependency on Microsoft.NET.Native.Framework. App1 指定具有次要版本25512.0 的 App3,App2 指定带有次要版本25513.0 的,而指定具有次要版本24202.0 的指定的指定的 .net. framework。App1 specifies Microsoft.NET.Native.Framework.1.6 with minor version 25512.0, App2 specifies Microsoft.NET.Native.Framework.1.6 with minor version 25513.0, and App3 specifies Microsoft.NET.Native.Framework.1.3 with minor version 24202.0. 由于 App1 和 App2 都指定相同的主要版本,因此应仅安装最新的次要版本25513.0,而 App3 指定依赖项包的不同主要版本,因此还必须安装它。Because both App1 and App2 both specify the same major version of the dependency package, only the latest minor version 25513.0 should be installed, while App3 specifies a different major version of the dependency package, so it must also be installed. 因此,应安装的依赖项包为带有次要版本25513.0 的 Microsoft .NET. 1.6 版,并且具有次要版本24202.0。So the dependency packages that should be installed are Microsoft.NET.Native.Framework.1.6 with minor version 25513.0 and Microsoft.NET.Native.Framework.1.3 with minor version 24202.0.

如果包具有特定于体系结构的依赖项,则必须在目标映像上安装依赖关系的所有适用体系结构。If the package has dependencies that are architecture-specific, you must install all of the applicable architectures for the dependency on the target image. 例如,在 x64 目标映像上,同时包含 x86 和 x64 依赖项包的路径,或将它们同时包含在解压缩的应用文件的文件夹中。For example, on an x64 target image, include a path to both the x86 and x64 dependency packages or include them both in the folder of unpacked app files. 如果同时指定或包含 ARM 依赖项包,DISM 将忽略该依赖项包,因为它不适用于目标 x64 映像。If the ARM dependency package is also specified or included, DISM will ignore it since it does not apply to the target x64 image.

计算机体系结构Computer Architecture要安装的依赖项:Dependencies to install:
X64x64x64 和 x86x64 and x86
ARMARM仅适用于 Windows RT (ARM)Windows RT (ARM) only

使用 /CustomDataPath指定应用程序的可选自定义数据文件。Use /CustomDataPath to specify an optional custom data file for an app. 您可以指定任何文件名。You can specify any file name. 将文件添加到映像后,该文件将重命名为 "Custom"。The file will be renamed to Custom.dat when it is added to the image.

使用带有 /packagepath选项的 /LicensePath指定包含应用程序许可证的 .xml 文件的位置。Use /LicensePath with the /PackagePath option to specify the location of the .xml file containing your application license.

仅将 /SkipLicense用于不需要启用旁加载的计算机上的许可证的应用。Only use /SkipLicense with apps that do not require a license on a sideloading-enabled computer. 在其他情况下使用 /SkipLicense可能会破坏映像。Using /SkipLicense in other scenarios can compromise an image.
Dism /Image:C:\test\offline /Add-ProvisionedAppxPackage /FolderPath:c:\Test\Apps\MyUnpackedApp /CustomDataPath:c:\Test\Apps\CustomData.xml

Dism /Online /Add-ProvisionedAppxPackage /PackagePath:C:\Test\Apps\MyPackedApp\MainPackage.appx /DependencyPackagePath:C:\Test\Apps\MyPackedApp\Framework-x86.appx /DependencyPackagePath:C:\Test\Apps\MyPackedApp\Framework-x64.appx /LicensePath:C:\Test\Apps\MyLicense.xml

Dism /Online /Add-ProvisionedAppxPackage /FolderPath:C:\Test\Apps\MyUnpackedApp /SkipLicense

Dism /Image:C:\test\offline /Add-ProvisionedAppxPackage /PackagePath:C:\Test\Apps\MyPackedApp\MainPackage.appxbundle /SkipLicense

Dism /Online /Add-ProvisionedAppxPackage /PackagePath:C:\Test\Apps\MyPackedApp\MainPackage.appxbundle /Region:"all"

Dism /Online /Add-ProvisionedAppxPackage /PackagePath:C:\Test\Apps\MyPackedApp\MainPackage.appxbundle /Region:"US;GB"
/Remove-ProvisionedAppxPackage/Remove-ProvisionedAppxPackage 从映像中删除应用程序包(.appx 或 .appxbundle)的预配。Removes provisioning for app packages (.appx or .appxbundle) from the image. 应用程序包将不会注册到所创建的新用户帐户。App packages will not be registered to new user accounts that are created.


/Remove-ProvisionedAppxPackage /PackageName:<PackageName>

重要说明:仅当包注册到任何用户配置文件时,此选项才会删除此设置。Important: This option will only remove the provisioning for a package if it is registered to any user profile. 在 PowerShell 中使用add-appxpackage cmdlet 来删除已注册的每个用户的应用,以便从映像中完全删除该应用。Use the Remove-AppxPackage cmdlet in PowerShell to remove the app for each user that it is already registered to in order to fully remove the app from the image.

如果应用尚未注册到任何用户配置文件,则/Remove-ProvisionedAppxPackage 选项会完全删除包。If the app has not been registered to any user profile, the /Remove-ProvisionedAppxPackage option will remove the package completely.

若要从安装了桌面体验的 Windows Server 2012 映像删除应用程序包,必须在删除桌面体验之前删除应用程序包。To remove app packages from a Windows Server 2012 image that has the Desktop Experience installed, you must remove the app packages before you remove the Desktop Experience. 桌面体验是 Windows Server 2012 的服务器核心安装的 /Remove-ProvisionedAppxPackage选项的要求。The Desktop Experience is a requirement of the /Remove-ProvisionedAppxPackage option for Server Core installations of Windows Server 2012.
Dism /Image:C:\test\offline /Remove-ProvisionedAppxPackage /PackageName:microsoft.devx.appx.app1_1.0.0.0_neutral_ac4zc6fex2zjp
/Optimize-ProvisionedAppxPackages/Optimize-ProvisionedAppxPackages 通过使用 hardlinks 替换相同的文件,优化映像上预配包的总文件大小。Optimizes the total file size of provisioned packages on the image by replacing identical files with hardlinks. 预配 AppX 包的映像联机后, /optimize-provisionedappxpackages将无法优化预配的 appx 包。Once an image with provisioned AppX packages is online, /optimize-provisionedappxpackages won't be able to optimize provisioned AppX packages. 如果你将映像脱机并添加包,则只会优化在将映像恢复为脱机后设置的包。If you take an image offline and add packages, only the packages that are provisioned after the image was brought back offline will be optimized.

对于联机映像,不支持此命令。This command is not supported against an online image.
DISM.exe /Image:C:\test\offline /Optimize-ProvisionedAppxPackages
/Set-ProvisionedAppxDataFile/Set-ProvisionedAppxDataFile 将自定义数据文件添加到指定的应用包(.appx 或 .appxbundle)中。Adds a custom data file into the specified app package (.appx or .appxbundle).


/Set-ProvisionedAppxDataFile [/CustomDataPath<custom_file_path>] /PackageName<PackageName>

在添加具有此选项的自定义数据文件之前,必须已将指定的应用(.appx 或 .appxbundle)包添加到映像。The specified app (.appx or .appxbundle) package must already be added to the image prior to when you add the custom data file with this option. 使用 /Add-ProvisionedAppxPackage选项时,还可以添加自定义数据文件。You can also add a custom data file when you use the /Add-ProvisionedAppxPackage option.

使用 /CustomDataPath指定应用程序的可选自定义数据文件。Use /CustomDataPath to specify an optional custom data file for an app. 您可以指定任何文件名。You can specify any file name. 将文件添加到映像后,该文件将重命名为 "Custom"。The file will be renamed to Custom.dat when it is added to the image. 如果已存在自定义 .dat 文件,则将覆盖该文件。If a Custom.dat file already exists, it will be overwritten.

使用 /packagename指定应用包(.appx 或 .appxbundle)。Use /PackageName to specify an app package (.appx or .appxbundle).
DISM.exe /Image:C:\test\offline /Set-ProvisionedAppxDataFile /CustomDataPath:c:\Test\Apps\Custom.dat /PackageName:microsoft.appx.app1_1.0.0.0_neutral_ac4zc6fex2zjp
/StubPackageOption/StubPackageOption 指定包的存根(stub)首选项。Specifies the stub preference of the package.



将预配包设置为存根版本。Sets the provision package to the stub version. 将存根首选项隐式设置为存根。Implicitly sets the stub preference to stub.



将预配包设置为,预配完整版本。Sets the provision package to the provision the full version. 将存根首选项隐式设置为 full。Implicitly sets the stub preference to full.

如果未指定任何存根包选项,则设置为预定义的存根(stub)首选项。If no stub package option is specified than the provisioned package version is set to the predefined stub preferences.
Dism /image:C:\test\offline /add-provisionedappxpackage /packagepath:"C:\dism\stub\appwithresources.appxbundle" /stubpackageoption:installstub

了解 DISM 如何向映像添加 .appxbundle 资源包Understanding How DISM Adds .appxbundle Resource Packages to an Image

如果将 .appxbundle 添加到映像,则并非捆绑中的所有资源包都适用。When an .appxbundle is added to the image, not all resource packages within the bundle are applicable. 例如,如果将应用添加到使用西班牙语(西班牙)默认语言的 Windows 映像,则不应包含法语(法国)资源。For example, if an app is being added to a Windows image with a Spanish (Spain) default language, French (France) resources should not be included. 为了确定将哪些资源添加到映像,使用以下功能确定了包适用性:To determine what resources are added to the image, the package applicability is determined using:

  • 语言资源包:如果未提供操作系统语言,则不会添加相应的应用语言资源包。Language Resource Packs: If an operating system language is not present, the corresponding app language resource pack is not added. 例如,你可能有一个映像,该映像为 Windows 10,其中包含英语(美国)作为默认语言,并包含西班牙语(西班牙)语言包。For example, you might have an image that is a Windows 10 with English (US) as the default language, and a Spanish (Spain) language pack included. "英语(美国)" 和 "西班牙语(西班牙)" 应用资源包将添加到映像。English (US) and Spanish (Spain) app resource packs will be added to the image. 如果应用程序捆绑包中有一个法语(法国)资源包(或任何其他语言),则不会添加它。If a French (France) resource pack (or any other language) is available in the app bundle, it will not be added.

  • 规模和 directx (DXFL)资源包:规模和 DIRECTX (DXFL)资源包取决于 Windows 设备的硬件配置。Scale and DirectX (DXFL) Resource Packs: Scale and DirectX (DXFL) resource packs depend upon the hardware configuration of the Windows device. 由于运行 DISM 命令时目标硬件的类型无法识别,因此在预配时将所有 scale 和 DXFL 资源包添加到映像。Because the type of target hardware can’t be known at the time the DISM commands are run, all scale and DXFL resource packages are added to the image at provisioning time. 有关使用缩放资源开发应用的详细信息,请参阅缩放到像素密度(Microsoft Store 应用)的准则For more information about developing an app with scaling resources, see Guidelines for scaling to pixel density (Microsoft Store apps).

对于包含多个语言包的映像,应用资源包将添加到每种语言的映像中。For an image containing multiple language packs, app resource packages will be added to the image for each language. 当第一个用户使用已部署的映像登录到电脑,并且用户在 OOBE 期间选择了某种语言后,将删除与用户配置文件设置不匹配的不适用资源包(语言资源包、缩放资源包和 DXFL 资源包)。Once the first user has signed in to the PC with the deployed image and the user has chosen a language during OOBE, the inapplicable resource packages, (language resource packs, scale resource packs and DXFL resource packages) that do not match the user profile settings are removed.

例如,应用可能支持英语(美国)、法语(法国)和西班牙语(西班牙)语言。For example, an app might support English (US), French (France), and Spanish (Spain) languages. 如果将应用添加到包含英语(美国)和西班牙语(西班牙)语言包的映像,则只会将 "英语(美国)" 和 "西班牙语(西班牙)" 资源包添加到映像。If the app is added to an image with English (US) and Spanish (Spain) language packs present, only English (US) and Spanish (Spain) resource packs will be added these to the image. 然后,如果用户首次登录,并且在 OOBE 期间选择 "英语(美国)" 作为操作系统语言,则西班牙语(西班牙)资源包将在登录完成后删除。Then, if a user signs in for the first time and, during OOBE, selects English (US) as their operating system language, the Spanish (Spain) resource packages will be removed after sign in completes.

重要提示   如果在映像中添加或删除语言包,则会更改适用性上下文,这可能会导致映像中出现不正确或不完整的资源包集。Important   If you add or remove a language pack from an image, you change the applicability context which may result in leaving an incorrect or incomplete set of resource packages in the image. 添加或删除语言包时,必须再次将所有 .appxbundle 包(包括任何依赖项包和 Microsoft Store 许可证文件)添加到映像。When a language pack is added or removed, you must, once again, add all .appxbundle packages (including any dependency packages and Microsoft Store license file) to the image. 这将确保预配正确的资源包集。This will ensure that the correct set of resource packages is provisioned.


  • 不能在不支持 Windows 8 应用程序的操作系统上安装应用程序包(.appx)。You cannot install an app package (.appx) on an operating system that does not support Windows 8 apps. 无法在不支持 Windows 8.1 应用的操作系统上安装应用程序包(.appxbundle)。You can’t install an app bundle package (.appxbundle) on an operating system that does not support at least Windows 8.1 apps. 在 WinPE 4.0、Windows Server 2012 Server Core 安装选项或 windows 8 和 Windows Server 2012 之前的任何 Windows 版本上都不支持应用。Apps aren't supported on WinPE 4.0, the Windows Server 2012 Server Core installation option, or on any versions of Windows older than Windows 8 and Windows Server 2012.

    若要在 Windows Server 2012 上安装和运行应用程序,必须安装桌面体验To install and run apps on Windows Server 2012, you must install the Desktop Experience.

  • 仅基于 .appx 格式的应用包支持 /FolderPath选项。The /FolderPath option is only supported for app packages based on the .appx format.

  • 必须始终对 .appxbundle 包使用 /packagepath/PackagePath must always be used for .appxbundle packages.

相关主题Related topics

什么是 DISM?What is DISM?

DISM 映像管理命令行选项DISM Image Management Command-Line Options

部署映像服务和管理(DISM)命令行选项Deployment Image Servicing and Management (DISM) Command-Line Options

使用 DISM 旁加载应用Sideload Apps with DISM