From c57b3e4f17dcbb981a0037a1ba6388aa0eca0be7 Mon Sep 17 00:00:00 2001 From: Bert van Brakel Date: Tue, 26 Apr 2016 10:24:50 +1000 Subject: [PATCH] resolves #34, allow setting NodeReuse and passing custom args --- .gitignore | 4 +++- README.md | 4 ++++ tasks/msbuild.js | 20 +++++++++++++++----- tests/vs/multiple-project-files/gruntfile.js | 1 + tests/vs/single-project-file/gruntfile.js | 1 + 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index b146a18..882e3f6 100755 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ node_modules/ .idea/ +# Ignore backup and temp files +*~ ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. @@ -22,4 +24,4 @@ build/ # MSTest test Results [Tt]est[Rr]esult*/ [Bb]uild[Ll]og.* -Nunit-Test-Results.xml \ No newline at end of file +Nunit-Test-Results.xml diff --git a/README.md b/README.md index a227265..26b824e 100755 --- a/README.md +++ b/README.md @@ -35,6 +35,8 @@ grunt.initConfig({ buildParameters: { WarningLevel: 2 }, + nodeReuse:false, + customArgs:[ '/noautoresponse', '/detailedsummary'], verbosity: 'quiet' } } @@ -50,8 +52,10 @@ grunt.initConfig({ | targets | Targets to run | Build | version | .NET version | 4.0 | maxCpuCount | Number of cores to use | 1 +| nodeReuse | If msbuild should hang around | false | consoleLoggerParameters | Customize Console Logger | buildParameters | Additional [properties](http://msdn.microsoft.com/en-us/library/ms171458.aspx) +| customArgs | Additional args, see [MSBuild Command-Line Reference](http://msdn.microsoft.com/en-us/library/ms164311.aspx) | verbosity | Verbosity level (quiet, minimal, normal, detailed or diagnostic) | normal For more information, see [MSBuild Command-Line Reference](http://msdn.microsoft.com/en-us/library/ms164311.aspx). diff --git a/tasks/msbuild.js b/tasks/msbuild.js index fcb4bf7..9d7996b 100755 --- a/tasks/msbuild.js +++ b/tasks/msbuild.js @@ -26,10 +26,12 @@ module.exports = function(grunt) { var options = this.options({ targets: ['Build'], buildParameters: {}, + customArgs:[], failOnError: true, verbosity: 'normal', processor: '', - nologo: true + nologo: true, + nodeReuse: true }); if (!options.projectConfiguration) { @@ -132,21 +134,29 @@ module.exports = function(grunt) { } } - if (options.consoleLoggerParameters) { + if (options.consoleLoggerParameters) { grunt.verbose.writeln('Using clp:' + options.consoleLoggerParameters); - args.push('/clp:' + options.consoleLoggerParameters); - } + args.push('/clp:' + options.consoleLoggerParameters); + } args.push('/property:Configuration=' + options.projectConfiguration); if (options.platform) { args.push('/p:Platform=' + options.platform); } - + + if (!options.nodeReuse) { + args.push('/nodeReuse:false'); + } + for (var buildArg in options.buildParameters) { args.push('/property:' + buildArg + '=' + options.buildParameters[buildArg]); } + for (var customArg in options.customArgs) { + args.push(customArg); + } + return args; } diff --git a/tests/vs/multiple-project-files/gruntfile.js b/tests/vs/multiple-project-files/gruntfile.js index 39e035f..fdaf722 100755 --- a/tests/vs/multiple-project-files/gruntfile.js +++ b/tests/vs/multiple-project-files/gruntfile.js @@ -18,6 +18,7 @@ module.exports = function(grunt) { WarningLevel: 2, OutputPath: 'bin\\Debug' }, + customArgs:['/nr:false'], verbosity: 'quiet' } } diff --git a/tests/vs/single-project-file/gruntfile.js b/tests/vs/single-project-file/gruntfile.js index bee5342..2df3c6d 100755 --- a/tests/vs/single-project-file/gruntfile.js +++ b/tests/vs/single-project-file/gruntfile.js @@ -15,6 +15,7 @@ module.exports = function (grunt) { WarningLevel: 2, OutputPath: 'bin\\Debug' }, + nodeReuse:false, verbosity: 'minimal', execOptions: { maxBuffer: 1000 * 1024