How to Sign ClickOnce with Sha256 Cert for .NET 4.0 like Visual Studio Update 3

十年热恋 提交于 2019-12-03 11:59:52

As user2404450 correctly wrote, the problem cannot be solved with Mage included in any VS 2013 Update. Microsoft has updated the API, but not the mage.exe tool. If you add the "-algorithm sha1RSA" parameter while calling mage.exe, you only specify what digest algorithm to use when generating hashes for your application resources.

To solve this, we have written a small tool that calls the correct API, see an example:

Microsoft.Build.Tasks.Deployment.ManifestUtilities.SecurityUtilities.SignFile(certThumbprint, timestampUrl, path, "v4.0");

You have to install VS 2013 Update 3 to get the 4th parameter working.

I have figured out how to do it with just msbuild

I have Visual Studio 2013 with Update 3 installed. Loaded the certificates needed into the store using the project Properties > Signing tab, taking note of the <ManifestCertificateThumbprint> in the .csproj file for each certificate. Then you can use them on command line like this:

msbuild /target:publish /property:ManifestKeyFile="certificate.pfx" /property:ManifestCertificateThumbprint="CERTIFICATE THUMBPRINT"

You cannot accompish this using mage. The reason is that mage is not updated to use the new API added in VS2013 Update 3.

However, it turns out the new API in VS2013 Update 3 are public so you can simply create a simple console app that uses this API to sign your code. Simply pass "3.5" or "4.0" as the last parameter (targetFrameworkVersion) and you're set. Also note that this method requires your certificate to be present in a certificate store.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!