如何使用可旁加载的证书创建 UWP 应用程序

How to created a UWP app with a certificate that can be sideloaded

我正在尝试创建一个可以旁加载到其他 PC 上的 UWP 应用程序。 我的主要问题是:我是否需要来自可信来源的证书来签署我的应用程序?

经过一番摸索,得知可以sideload/installUWP应用通过应用App Installer from the Windows Store. After installing the App Installer, one can install UWP apps by double clicking on the .appxbundle file. (Not using the .ps1 file, as indicated )

在执行此操作之前,我需要信任该证书。我通过 Visual Studio 创建了这个证书。它是通过双击 .appxmanifest 转到 Packaging,选择 Choose Certificate -> Configure Cerfiticate 然后选择 Create test certificate 创建的。

我试图在两台不同的 Windows 10 台机器上安装我的应用程序。在一台机器上,应用程序会失败,因为该包可能与另一个包冲突或依赖于未安装的东西(这不是真的),而在另一台机器上它会给出证书错误(即使我信任并将证书添加到我的根信任证书中)。

我是否需要受信任机构颁发的证书才能使其正常工作?我的印象是我的证书应该有效,只要用户信任它,但应用程序似乎没有安装。

此外,如果我确实需要受信任的证书,我该如何创建这个 pfx 文件?我从哪里得到它? Microsoft 文档似乎没有提及任何内容。

确保将证书添加到 Trusted People 存储区(这不是错字——它是 People)。如果您没有安装正确的框架包,或者如果您之前安装了应用程序但没有更改清单中的版本号,则可能会导致其他错误。

原来是我没有安装依赖。我将证书添加到 Trusted Root Authorities Section 中的 Local Computer(不是当前用户)。在此之后我仍然收到错误消息,即软件包依赖于未安装的东西。事实证明这是真的!根据 App Installer page

The App Installer does not automatically install framework dependencies. In most cases your device already has the dependencies, but there are some developer or enterprise scenarios where you need an additional framework. In this case just browse to the dependency folder with your app and install the dependency framework just like any app, using the App Installer!

依赖项都位于一个名为 "Dependencies" 的文件夹中,该文件夹由 Visual Studio 创建。安装后,应用程序安装成功!