Code Signing

Jan 30, 2015 at 11:50 AM
Edited Jan 30, 2015 at 11:53 AM
Just want to report that while the "Signing" sample was of great help, the code didn't work with "signtool not found error.
In the end I implemented that method (which inject the path to signtool)

Perhaps you could update the Tasks.DigitalySign() method?

static void SignMSI(string msi)
{
    var path = Environment.GetEnvironmentVariable("PATH");
    var cmdpath = @"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin";
    if (!path.Contains(cmdpath))
    {
        Environment.SetEnvironmentVariable("PATH", cmdpath + ";" + path);
    }
    int exitCode = Tasks.DigitalySign(msi,
                                @"path.to.pfx",
                                  "http://timestamp.verisign.com/scripts/timstamp.dll",
                                 "password");
    if (exitCode != 0)
        Console.WriteLine("Could not sign the MSI file.");
    else
        Console.WriteLine("the MSI file was signed successfully.");

}
Coordinator
Jan 31, 2015 at 12:57 AM
I just extended the buit-in wll-known locations of the SignTool.exe with your extra path to allow a better probing for the tool executable.

I also added an optional parameter to CommonTasks.Tasks.DigitalySign to allow a user defined location of the tool:
int DigitalySign(string fileToSign, string pfxFile, string timeURL, string password, string optionalArguments = null, string wellKnownLocations = null)
The change is commited and will be available with the next release

Thanks
Jan 31, 2015 at 3:04 AM
Well done Oleg! :)