Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

Commit

Permalink
More params!
Browse files Browse the repository at this point in the history
  • Loading branch information
jabbera committed Jul 7, 2017
1 parent 5c92442 commit ced21e8
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ _temp/
gulp-tsc-tmp-*
.gulp-tsc-tmp-*
*.vsix
*.pfx

node_modules
typings
Expand Down
3 changes: 3 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"INPUT_FILEALGO": "sha256",
"INPUT_FILEPATH": "c:\\temp\\*.dll",
"INPUT_RETRYCOUNT": "5",
"INPUT_CERTIFICATELOCATION": "computerStore",
"INPUT_PFXPATH": "c:\\temp\\code.pfx",
//"INPUT_PFXPASSWORD": "passwordhere",
"PROCESSOR_ARCHITECTURE": "x64"
}
}
Expand Down
59 changes: 54 additions & 5 deletions Tasks/authenticode-sign/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ import * as tr from "vsts-task-lib/ToolRunner";

async function run() {
let signToolLocation: string = getSignToolLocation();
let timestampServer: string = tl.getInput("timestampServer", true);
let timestampAlgo: string = tl.getInput("timestampAlgo", true);
let fileAlgo: string = tl.getInput("fileAlgo", true);
let filePath: string = tl.getInput("filePath", true);
let retryCount: number = Number(tl.getInput("retryCount", true));

let signtool: tr.ToolRunner = new tr.ToolRunner(signToolLocation);

signtool.arg([ "sign", "/tr", timestampServer, "/td", timestampAlgo, "/fd", fileAlgo, "/a", filePath ]);
let signtoolArguments: string[] = ["sign"];

pushTimestampArgs(signtoolArguments);
pushCertArgs(signtoolArguments);
pushFileArgs(signtoolArguments);

signtool.arg(signtoolArguments);

let i: number = 0;

Expand All @@ -31,8 +33,55 @@ async function run() {
}
}
}
}

function pushTimestampArgs(args: string[]) {
let timestampServer: string = tl.getInput("timestampServer", true);
let timestampAlgo: string = tl.getInput("timestampAlgo", true);

args.push("/tr", timestampServer, "/td", timestampAlgo);
}

function pushCertArgs(args: string[]) {
let certificateLocation: string = tl.getInput("certificateLocation", true);
if (certificateLocation == "computerStore") {
return; // Nothing to do.
}

if (certificateLocation == "userStore") {
args.push("/sm");
}

if (certificateLocation != "pfxFile") {
tl.setResult(tl.TaskResult.Failed, `Unknown cert location: ${certificateLocation}`);
}

let pfxLocation: string = tl.getPathInput("pfxPath", true);
if (pfxLocation == null || pfxLocation == '') {
let error: string = "Pfx Location not set.";
tl.setResult(tl.TaskResult.Failed, error);
throw error;
}

tl.checkPath(pfxLocation, "pfxfile");

let pfxPassword: string = tl.getInput("pfxPassword");
if (pfxPassword == null || pfxPassword == '') {
let error: string = "Pfx Password not set.";
tl.setResult(tl.TaskResult.Failed, error);
throw error;
}

args.push("/f", pfxLocation, "/p", pfxPassword);
}

function pushFileArgs(args: string[]) {
let fileAlgo: string = tl.getInput("fileAlgo", true);
let filePath: string = tl.getInput("filePath", true);

args.push("/fd", fileAlgo, "/a", filePath);
}

function getSignToolLocation(): string {
let toolLocation: string = tl.getInput("toolLocation", false);
if (toolLocation != null && toolLocation != "") {
Expand Down
2 changes: 1 addition & 1 deletion Tasks/authenticode-sign/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
},
{
"name": "pfxFile",
"type": "string",
"type": "filePath",
"label": "Pfx File",
"defaultValue": "",
"required": true,
Expand Down

0 comments on commit ced21e8

Please sign in to comment.