diff --git a/BuildServer/lib/tasks/dotnetbuild.js b/BuildServer/lib/tasks/dotnetbuild.js index 38fa28c..139f477 100644 --- a/BuildServer/lib/tasks/dotnetbuild.js +++ b/BuildServer/lib/tasks/dotnetbuild.js @@ -21,6 +21,7 @@ module.exports = function (params, processor) { type: "dotnetcompile", params: { solution: params.solution, + skipCodeSigning: params.skipCodeSigning, target: "Build" } } diff --git a/BuildServer/lib/tasks/dotnetcompile.js b/BuildServer/lib/tasks/dotnetcompile.js index 560eca9..a9d0e61 100644 --- a/BuildServer/lib/tasks/dotnetcompile.js +++ b/BuildServer/lib/tasks/dotnetcompile.js @@ -1,5 +1,6 @@ "use strict"; +var settings = require('../../settings'); var dotnetbuilderwrapper = require('./dotnetbuilderwrapper'); module.exports = function (params, processor) { @@ -9,5 +10,8 @@ module.exports = function (params, processor) { Target: params.target, OutputDirectory: params.overrideOutputDirectory }; + if (!params.skipCodeSigning && !settings.skipCodeSigning) { + compileParams.SigningKey = settings.codeSigningKeyFile; + } return dotnetbuilderwrapper(compileParams, processor); } diff --git a/BuildServer/lib/tasks/dotnetpackwebapp.js b/BuildServer/lib/tasks/dotnetpackwebapp.js index 9df868f..6742c7f 100644 --- a/BuildServer/lib/tasks/dotnetpackwebapp.js +++ b/BuildServer/lib/tasks/dotnetpackwebapp.js @@ -38,6 +38,7 @@ module.exports = function (params, processor) { type: "dotnetcompile", params: { solution: "MakePackage.msbuild", + skipCodeSigning: params.skipCodeSigning, target: "Package", overrideOutputDirectory: processor.context.release } diff --git a/BuildServer/lib/tasks/dotnetrewrite.js b/BuildServer/lib/tasks/dotnetrewrite.js index fadd350..1f2709f 100644 --- a/BuildServer/lib/tasks/dotnetrewrite.js +++ b/BuildServer/lib/tasks/dotnetrewrite.js @@ -34,27 +34,18 @@ module.exports = function (params, processor) { content += "\r\n"; content = addAssemblyAttribute(content, "[assembly: AssemblyInformationalVersion(\"" + version + "\")]"); return cb(null, content); - }, - processCsproj = function (content, cb) { - if (!params.skipCodeSigning && !settings.skipCodeSigning) { - if (content.indexOf("") < 0) { - return cb("CSProj file does not contain PropertyGroups"); - } - content = content.replace("", "true" + settings.codeSigningKeyFile + ""); - } - return cb(null, content); }; - glob("**/{AssemblyInfo.cs,*.csproj}", {cwd: processor.context.exported}, function (err, files) { + glob("**/AssemblyInfo.cs", {cwd: processor.context.exported}, function (err, files) { if (err) { processor.onError(err); return processor.done(); } - processor.onInfo("Found " + files.length + " AssemblyInfo.cs/csproj files"); + processor.onInfo("Found " + files.length + " AssemblyInfo.cs files"); if (!files || !files.length) { - processor.onWarn("No AssemblyInfo.cs/csproj found"); + processor.onWarn("No AssemblyInfo.cs found"); return processor.done(); } @@ -62,7 +53,7 @@ module.exports = function (params, processor) { return function (callback) { return async.waterfall([ fs.readFile.bind(null, processor.context.exported + "/" + file, { encoding: "utf8" }), - (file.substr(-7).toLowerCase() == ".csproj") ? processCsproj : processAssemblyInfo, + processAssemblyInfo, fs.writeFile.bind(null, processor.context.exported + "/" + file) ], function (err) { if (err) { diff --git a/DotNetBuilder/CompileRequest.cs b/DotNetBuilder/CompileRequest.cs index 41bbb2e..31e7cab 100644 --- a/DotNetBuilder/CompileRequest.cs +++ b/DotNetBuilder/CompileRequest.cs @@ -7,5 +7,7 @@ public string Target { get; set; } public string OutputDirectory { get; set; } + + public string SigningKey { get; set; } } } diff --git a/DotNetBuilder/Compiler.cs b/DotNetBuilder/Compiler.cs index 424f433..e74a0bb 100644 --- a/DotNetBuilder/Compiler.cs +++ b/DotNetBuilder/Compiler.cs @@ -78,6 +78,11 @@ namespace MicroBuildServer.DotNetBuilder { globalProperty.Add("OutputDirectory", request.OutputDirectory); } + if (!string.IsNullOrEmpty(request.SigningKey)) + { + globalProperty.Add("SignAssembly", "true"); + globalProperty.Add("AssemblyOriginatorKeyFile", request.SigningKey); + } var buildRequest = new BuildRequestData(request.SolutionPath, globalProperty, null, new [] { request.Target }, null);