Improved code signing

MSBuild parameters used instead of project file rewriting
dependabot/npm_and_yarn/BuildServer/eslint-7.2.0
Inga 🏳‍🌈 9 years ago
parent 5b078c6ea1
commit ec9f30efb5
  1. 1
      BuildServer/lib/tasks/dotnetbuild.js
  2. 4
      BuildServer/lib/tasks/dotnetcompile.js
  3. 1
      BuildServer/lib/tasks/dotnetpackwebapp.js
  4. 17
      BuildServer/lib/tasks/dotnetrewrite.js
  5. 2
      DotNetBuilder/CompileRequest.cs
  6. 5
      DotNetBuilder/Compiler.cs

@ -21,6 +21,7 @@ module.exports = function (params, processor) {
type: "dotnetcompile", type: "dotnetcompile",
params: { params: {
solution: params.solution, solution: params.solution,
skipCodeSigning: params.skipCodeSigning,
target: "Build" target: "Build"
} }
} }

@ -1,5 +1,6 @@
"use strict"; "use strict";
var settings = require('../../settings');
var dotnetbuilderwrapper = require('./dotnetbuilderwrapper'); var dotnetbuilderwrapper = require('./dotnetbuilderwrapper');
module.exports = function (params, processor) { module.exports = function (params, processor) {
@ -9,5 +10,8 @@ module.exports = function (params, processor) {
Target: params.target, Target: params.target,
OutputDirectory: params.overrideOutputDirectory OutputDirectory: params.overrideOutputDirectory
}; };
if (!params.skipCodeSigning && !settings.skipCodeSigning) {
compileParams.SigningKey = settings.codeSigningKeyFile;
}
return dotnetbuilderwrapper(compileParams, processor); return dotnetbuilderwrapper(compileParams, processor);
} }

@ -38,6 +38,7 @@ module.exports = function (params, processor) {
type: "dotnetcompile", type: "dotnetcompile",
params: { params: {
solution: "MakePackage.msbuild", solution: "MakePackage.msbuild",
skipCodeSigning: params.skipCodeSigning,
target: "Package", target: "Package",
overrideOutputDirectory: processor.context.release overrideOutputDirectory: processor.context.release
} }

@ -34,27 +34,18 @@ module.exports = function (params, processor) {
content += "\r\n"; content += "\r\n";
content = addAssemblyAttribute(content, "[assembly: AssemblyInformationalVersion(\"" + version + "\")]"); content = addAssemblyAttribute(content, "[assembly: AssemblyInformationalVersion(\"" + version + "\")]");
return cb(null, content); return cb(null, content);
},
processCsproj = function (content, cb) {
if (!params.skipCodeSigning && !settings.skipCodeSigning) {
if (content.indexOf("</PropertyGroup>") < 0) {
return cb("CSProj file does not contain PropertyGroups");
}
content = content.replace("</PropertyGroup>", "</PropertyGroup><PropertyGroup><SignAssembly>true</SignAssembly><AssemblyOriginatorKeyFile>" + settings.codeSigningKeyFile + "</AssemblyOriginatorKeyFile></PropertyGroup>");
}
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) { if (err) {
processor.onError(err); processor.onError(err);
return processor.done(); return processor.done();
} }
processor.onInfo("Found " + files.length + " AssemblyInfo.cs/csproj files"); processor.onInfo("Found " + files.length + " AssemblyInfo.cs files");
if (!files || !files.length) { if (!files || !files.length) {
processor.onWarn("No AssemblyInfo.cs/csproj found"); processor.onWarn("No AssemblyInfo.cs found");
return processor.done(); return processor.done();
} }
@ -62,7 +53,7 @@ module.exports = function (params, processor) {
return function (callback) { return function (callback) {
return async.waterfall([ return async.waterfall([
fs.readFile.bind(null, processor.context.exported + "/" + file, { encoding: "utf8" }), 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) fs.writeFile.bind(null, processor.context.exported + "/" + file)
], function (err) { ], function (err) {
if (err) { if (err) {

@ -7,5 +7,7 @@
public string Target { get; set; } public string Target { get; set; }
public string OutputDirectory { get; set; } public string OutputDirectory { get; set; }
public string SigningKey { get; set; }
} }
} }

@ -78,6 +78,11 @@ namespace MicroBuildServer.DotNetBuilder
{ {
globalProperty.Add("OutputDirectory", request.OutputDirectory); 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); var buildRequest = new BuildRequestData(request.SolutionPath, globalProperty, null, new [] { request.Target }, null);

Loading…
Cancel
Save