InternalsVisibleTo rewriting for unsigned references in signed project; refactoring

dependabot/npm_and_yarn/BuildServer/eslint-7.2.0
Inga 🏳‍🌈 9 years ago
parent be2604f961
commit 567f02cc89
  1. 26
      BuildServer/lib/tasks/dotnetrewrite.js

@ -23,11 +23,6 @@ module.exports = function (params, processor) {
"repository: " + processor.context.owner + "/" + processor.context.reponame + "; " + "repository: " + processor.context.owner + "/" + processor.context.reponame + "; " +
"branch: " + processor.context.branch + ")"; "branch: " + processor.context.branch + ")";
var textToAppend = "\r\n[assembly: AssemblyInformationalVersion(\"" + version + "\")]\r\n";
if (!params.skipCodeSigning && !settings.skipCodeSigning) {
textToAppend += "[assembly: AssemblyKeyFileAttribute(\"" + settings.codeSigningKey + "\")]\r\n";
}
glob("**/AssemblyInfo.cs", {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);
@ -43,13 +38,30 @@ module.exports = function (params, processor) {
return async.parallel(files.map(function (file) { return async.parallel(files.map(function (file) {
return function (callback) { return function (callback) {
return fs.appendFile(processor.context.exported + "/" + file, textToAppend, function (err, result) { return async.waterfall([
fs.readFile.bind(null, processor.context.exported + "/" + file),
function (content, cb) {
content += "\r\n";
if (!params.skipCodeSigning && !settings.skipCodeSigning) {
content = content.replace(
/InternalsVisibleTo\s*\(\s*\"([\w.]+)\"\s*\)/g,
function (match, p1) {
return "InternalsVisibleTo(\"" + p1 + ",PublicKey=" + settings.codeSigningPublicKey + "\")";
}
);
content += "[assembly: AssemblyKeyFileAttribute(\"" + settings.codeSigningKeyFile + "\")]\r\n"
}
content += "[assembly: AssemblyInformationalVersion(\"" + version + "\")]\r\n";
return cb(null, content);
},
fs.writeFile.bind(null, processor.context.exported + "/" + file)
], function (err) {
if (err) { if (err) {
processor.onError("Unable to rewrite file " + file + ": " + err); processor.onError("Unable to rewrite file " + file + ": " + err);
} else { } else {
processor.onInfo("Rewritten file " + file); processor.onInfo("Rewritten file " + file);
} }
callback(err, result); callback(err);
}); });
} }
}), processor.done.bind(processor)); }), processor.done.bind(processor));

Loading…
Cancel
Save