Windows Develop Bookmark and Share   
 index > ClickOnce and Setup & Deployment Projects > Sign manifests in code without mage
 

Sign manifests in code without mage

Some people have asked how to do this in other threads, so here's a slightly modified manifest-signing functionfrom the ClickOnce Community Resource Kit which can be downloaded at
http://www.codeplex.com/smartclient/Project/FileDownload.aspx?DownloadId=5060.

Code Block

using System.Security.Cryptography.X509Certificates;

using Microsoft.Build.Tasks.Deployment.ManifestUtilities;

// Also needs a reference to Microsoft.Build.Tasks

public static void SignManifest( string manifestFilePath, string certFilePath, stringpassword, string timestampUrl )

{

if ( !File.Exists( certFilePath ) )

{

throw new ArgumentException( "Invalid certificate file path" );

}

else if ( !File.Exists( manifestFilePath ) )

{

throw new ArgumentException( "Invalid manifest file path" );

}

else

{

X509Certificate2 cert;

if ( string.IsNullOrEmpty( password ) )

{

cert = new X509Certificate2( certFilePath );

}

else

{

cert = new X509Certificate2( certFilePath, password );

}

Uri timestampUri = null;

if ( !string.IsNullOrEmpty( timestampUrl ) )

{

timestampUri = new Uri( timestampUrl );

}

SecurityUtilities.SignFile( cert, timestampUri, manifestFilePath );

}

}

i-b  Tuesday, October 23, 2007 7:50 PM

Hi a-igorb,

Thank you for sharing with us!

Best regards,

Rong-Chun Zhang

Rong-Chun Zhang  Monday, October 29, 2007 6:00 AM

You can use google to search for other answers

Custom Search

More Threads

• System.Enterprise Services Error
• Encrypted .msi file results in installation failure
• C# Desktop windows application Setup and Deployment Project is not Compiling (Error)
• Click-Once deploys two instances of the application
• ERROR: Could not find file 'FileName' 'Not enough storage is available to complete this operation.'
• Will ClickOnce work for my weird application?
• Problem with Silent Installation of WebSetup
• InstallAllUsers Property
• installer requires .Net framework for a native application
• Install Directory