How to generate a new .pfx file after being lost f

2019-03-15 23:48发布

I'm using GitHub to host an open-source Windows 10 app I'm developing. I accidentally gitignored my app's PFX file, so when I deleted my local copy and re-cloned the repo, I was left without a MyApp_TemporaryKey.pfx file. Now Visual Studio is complaining about this, and I'm unable to build the solution.

How do I regenerate this file so I can run the app again? Thanks for helping.

3条回答
Explosion°爆炸
2楼-- · 2019-03-16 00:12

If you are developing a universal windows app, you shouldn't be unable to build the solution without the pfx file if there are no other errors.

If you are developing other apps like winform, you can right click the project and go to Properties|Signing, you should find "Sign the ClickOnce manifests" then you can "Create Test Certificate".

And if I'm right, I have downloaded your github project and built successfully. Please check if there are any other errors in your solution and have a try again. (Don't forget to change startup project)

查看更多
男人必须洒脱
3楼-- · 2019-03-16 00:20

Typically, missing .pfx file will only raise several Warnings in Visual Studio and it won't affect the building of your project.

But if you want to regenerate this file in Windows 10 app, you can refer to Renewing a certificate section in 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.

查看更多
男人必须洒脱
4楼-- · 2019-03-16 00:23

You can use a certificate generated by Visual Studio or generate one yourself with no problem. The difference between this and purchasing a certificate is that when the user goes to install the application, if you have purchased a certificate it will say "published by: yourcompanyanme" instead of "Uknown Publisher".

I understand that buying one may not be an option, so from my knowledge you have to options:

  1. Create an empty project and copy your code over, but I agree it is not a nice one.

  2. Create a certificate for your application using the MakeCert tool (can create .pvk and/or .cer files) and then use the Pvk2Pfx tool to convert the certificate to a .pfx file.

You can find a full tutorial from MSFT about how to do all this in this link.

查看更多
登录 后发表回答