从源代码管理丢失后如何生成新的 .pfx 文件?

How to generate a new .pfx file after being lost from source control?

我正在使用 GitHub 托管我正在开发的开源 Windows 10 应用程序。我不小心 gitignored 我的应用程序的 PFX 文件,所以当我删除我的本地副本并重新克隆 repo 时,我没有 MyApp_TemporaryKey.pfx 文件。现在 Visual Studio 抱怨这个,我无法构建解决方案。

如何重新生成此文件以便再次 运行 应用程序?感谢您的帮助。

您可以使用 Visual Studio 生成的证书或自己生成一个,没有问题。这与购买证书的区别在于,当用户安装应用程序时,如果您购买了证书,它将显示 "published by: yourcompanyanme" 而不是 "Uknown Publisher".

我知道买一个可能不是一个选择,所以据我所知你必须选择:

  1. 创建一个空项目并复制你的代码,但我同意这不是一个很好的项目。

  2. 使用 MakeCert tool (can create .pvk and/or .cer files) and then use the Pvk2Pfx 工具为您的应用程序创建证书以将证书转换为 .pfx 文件。

您可以在 this link.

中找到有关如何完成所有这些操作的 MSFT 的完整教程

如果您正在开发通用 windows 应用程序,如果没有其他错误,您应该不会在没有 pfx 文件的情况下无法构建解决方案。

如果您正在开发其他应用程序,如 winform,您可以右键单击该项目并转到属性|签名,您应该找到 "Sign the ClickOnce manifests" 然后您可以 "Create Test Certificate"。

如果我是对的,我已经下载了您的 github project 并成功构建。请检查您的解决方案中是否还有其他错误,然后重试。 (别忘了更改启动项目)

通常情况下,缺少 .pfx 文件只会在 Visual Studio 中引发几个 警告,不会影响项目的构建。

但是如果你想在Windows10 app中重新生成这个文件,你可以参考Signing an app package (Windows Store apps)中的更新证书部分:

To renew the certificate

  1. In Solution Explorer, open the shortcut menu for the .appxmanifest file, choose Open With, and then choose App Manifest Designer.
  2. In the App Manifest Designer, choose the Packaging tab, and then choose the Choose Certificate button.
  3. In the Choose Certificate dialog box, expand the Configure Certificate list, and then choose Create test certificate.
  4. In the Create test certificate dialog box, click the OK button.

Visual Studio regenerates the certificate with a new expiration date.