diff --git a/BuildServer/lib/tasks/dotnetbuild.js b/BuildServer/lib/tasks/dotnetbuild.js index f16a9f1..97bddb9 100644 --- a/BuildServer/lib/tasks/dotnetbuild.js +++ b/BuildServer/lib/tasks/dotnetbuild.js @@ -6,7 +6,10 @@ module.exports = function (params, processor) { return sequential({ tasks: [ { - type: "dotnetrewrite", + type: "dotnetcheckstyle" + }, + { + type: "dotnetrewrite" }, { type: "dotnetbuilderwrapper", diff --git a/BuildServer/lib/tasks/dotnetcheckstyle.js b/BuildServer/lib/tasks/dotnetcheckstyle.js new file mode 100644 index 0000000..5747d45 --- /dev/null +++ b/BuildServer/lib/tasks/dotnetcheckstyle.js @@ -0,0 +1,46 @@ +"use strict"; + +var fs = require('fs'); +var async = require('async'); +var glob = require('glob'); + +module.exports = function (params, processor) { + return { + process: function () { + if (processor.context.dotnetcheckerDone) { + return processor.done(); + } + + processor.context.dotnetcheckerDone = true; + + glob("**/*.cs", {cwd: processor.context.exported}, function (err, files) { + if (err) { + processor.onError(err); + return processor.done(); + } + + processor.onInfo("Found " + files.length + " .cs files"); + + if (!files || !files.length) { + processor.onWarn("No AssemblyInfo.cs found"); + return processor.done(); + } + + return async.parallel(files.map(function (file) { + return function (callback) { + return fs.readFile(processor.context.exported + "/" + file, { encoding: "utf8" }, function (err, data) { + if (err) { + processor.onError("Unable to rewrite file " + file + ": " + err); + } else if (data.indexOf("\r\n") >= 0) { + processor.onError("Windows-style EOL (0D0A) found in file " + file); + } else { + processor.onInfo("Rewritten file " + file); + } + callback(err); + }); + }; + }), processor.done.bind(processor)); + }); + } + }; +};