ClickOnce hash failures when using code contract rewriter
I am creating a ClickOnce deployment.
Now, I am using CodeContracts rewriter, which means that the application manifest is generated before CodeContracts modifies my assembly.
Therefore, I update the application manifest file with an up-to-date hash and file size. Here's the algorithm to compute the hash:
public static string ComputeHash(FileInfo info)
{
SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider();
byte[] hashBytes = sha1.ComputeHash(info.OpenRead());
return Convert.ToBase64String(hashBytes);
}
I then save the manifest. I then update the ClickOnce deployment manifest (.application) which has a hash and size for the application manifest using the same hash computation routine.
After this, I run a test program which tells me that all the hashes and file sizes match those of the real files on disk.
Yet when I run the ClickOnce deployment it always complains that the hash verification failed for the main .exe file (which is the only dependent assembly in the application manifest that needs changing).
Note that if I d开发者_如何学Pythono not change the hashes and sizes myself, the ClickOnce also fails because the information is even more palpably wrong (the file size is different, not just the hash).
Is there anyway I can see why the hash validation is failing when I think it is valid?
Or better still, is there a way I can generate manifests after the code contracts rewriter has finished hacking my executables?
Thanks
Have you tried Mage to update and resign your manifests? Look at the Update (-u) and the Sign (-s) commands.
精彩评论