排查 .MSIX 容器中的运行时问题Troubleshoot runtime issues in an MSIX container

本文介绍如何解决 .MSIX 容器中发生的运行时问题。In this article, we will review how you can troubleshoot runtime issues occurring in a MSIX container. .MSIX 容器本身相对简单简单。MSIX containers by themselves are relatively simple and straightforward. 随着更多应用程序在包含修改包的同一包标识中运行,虚拟注册表和虚拟文件系统将按安装应用程序的顺序排列。As more applications are run inside the same package identity with the help of modification packages, the virtual registry and virtual file system will be over-layed in the order in which the applications are installed.

在某些情况下,这些应用程序的安装顺序可能会导致意外问题,可能会覆盖所需的注册表项,并且可能会替换预期的文件。There can be cases where the order in which these applications are installed could cause unforseen issues where the expected registry keys might be overwritten and expected files might be replaced.

为了帮助诊断此类问题, CommandInDesktopPackage 是一个 PowerShell cmdlet,可用于在 .msix 容器中运行应用程序。To assist in diagnosing such issues, Invoke-CommandInDesktopPackage is a PowerShell cmdlet that can be used to run an application inside the MSIX container. 这样,用户便可以在 .MSIX 容器中运行命令提示符、注册表编辑器、PowerShell,并获得合并文件系统和合并的注册表配置单元。This allows for users to run command prompt, registry editor, PowerShell inside the MSIX container and get a view of the merged file system and merged registry hive.

重要

CommandInDesktopPackage 要求设备处于18922之前的 Windows 10 内部版本的开发人员模式。Invoke-CommandInDesktopPackage requires the device to be in Developer mode for Windows 10 builds prior to 18922.

查看合并文件系统View the merged file system

若要查看由容器内运行的应用程序观察到的文件系统,请使用以下 PowerShell 命令:To view the file system as observed by the applications that are running inside the container, use the following PowerShell command:

Invoke-CommandInDesktopPackage -AppId "AppPackage1" -PackageFamilyName "Contoso.AppPackage1_8h66172c634n0" -Command "cmd.exe" -PreventBreakaway

上述命令将启动 Contoso. AppPackage1_8h66172c634n0 包容器中 cmd.exe 的实例。The above command will launch an instance of cmd.exe in the Contoso.AppPackage1_8h66172c634n0 package container. 在容器内部运行命令提示符时,可以浏览文件系统并查看合并的文件。As you are running the command prompt from inside the container, you can browse through the file system and view the merged files.

查看合并的注册表配置单元View the merged registry hive

若要查看由运行有问必答容器的应用程序观察到的完整设备注册表配置单元,请使用以下 PowerShell 命令:To view the full device registry hive as observed by the applications that are running insider the container, use the following PowerShell command:

Invoke-CommandInDesktopPackage -AppId "AppPackage1" -PackageFamilyName "Contoso.AppPackage1_8h66172c634n0" -Command "regedit.exe" -PreventBreakaway

上述命令将在 Contoso. AppPackage1_8h66172c634n0 包容器的上下文中启动注册表编辑器。The above command will launch registry editor within the context of the Contoso.AppPackage1_8h66172c634n0 package container. 可在此处浏览 "本地计算机" 和 "当前用户" 注册表项,并确定导致此问题的可能的问题。Here you can browse through local machine and current user registry keys and identify possible offender that is causing the issue.

提示

如果要在同一容器中启动后续进程,请在使用 CommandInDesktopPackage 时使用 "-PreventBreakaway" 标志。Use '-PreventBreakaway' flag while using Invoke-CommandInDesktopPackage if you would like to launch subsequent processes in the same container. 否则,任何后续启动都将中断容器。Else, any subsequent launch will break out of the container.

备注

并非所有应用程序都可以在容器中启动。Not all applications can be launched within the container. 例如,explorer.exe 会分类容器。For instance, explorer.exe will breakout of the container.