From 55cc7e3a873d2d651d268c98860221118e633ff9 Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Thu, 1 Mar 2018 19:51:55 +0100 Subject: [PATCH] Fix NUnit3 task on Linux Current nunit3-console versions use "--" as switch separator on both Windows and Linux. Also the --verbose switch has been replaced by --trace=Verbose. --- Source/MSBuild.Community.Tasks/NUnit3.cs | 44 +++++++++++------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/Source/MSBuild.Community.Tasks/NUnit3.cs b/Source/MSBuild.Community.Tasks/NUnit3.cs index e6254f22..c22f9e3d 100644 --- a/Source/MSBuild.Community.Tasks/NUnit3.cs +++ b/Source/MSBuild.Community.Tasks/NUnit3.cs @@ -369,68 +369,66 @@ protected override string GenerateCommandLineCommands() { CommandLineBuilder builder = new CommandLineBuilder(); - string c = Environment.OSVersion.Platform == PlatformID.Unix ? "-" : "--"; - if (EnableShadowCopy) { - builder.AppendSwitch(c+"shadowcopy"); + builder.AppendSwitch("--shadowcopy"); } if (_testInNewThread.HasValue && !_testInNewThread.Value) { - builder.AppendSwitch(c+"nothread"); + builder.AppendSwitch("--nothread"); } if(Force32Bit) { - builder.AppendSwitch(c+"x86"); + builder.AppendSwitch("--x86"); } if (NoHeader) { - builder.AppendSwitch(c+"noheader"); + builder.AppendSwitch("--noheader"); } if (NoColor) { - builder.AppendSwitch(c+"nocolor"); + builder.AppendSwitch("--nocolor"); } if (Verbose) { - builder.AppendSwitch(c+"verbose"); + builder.AppendSwitch("--trace=Verbose"); } builder.AppendFileNamesIfNotNull(_assemblies, " "); - builder.AppendSwitchIfNotNull(c+"config=", _projectConfiguration); + builder.AppendSwitchIfNotNull("--config=", _projectConfiguration); - builder.AppendSwitchIfNotNull(c+"err=", _errorOutputFile); + builder.AppendSwitchIfNotNull("--err=", _errorOutputFile); - builder.AppendSwitchIfNotNull(c+"out=", _textOutputFile); + builder.AppendSwitchIfNotNull("--out=", _textOutputFile); - builder.AppendSwitchIfNotNull(c+"framework=",_framework); + builder.AppendSwitchIfNotNull("--framework=",_framework); - builder.AppendSwitchIfNotNull(c+"process=",_process); + builder.AppendSwitchIfNotNull("--process=",_process); - builder.AppendSwitchIfNotNull(c+"domain=",_domain); + builder.AppendSwitchIfNotNull("--domain=",_domain); - builder.AppendSwitchIfNotNull(c+"apartment=",_apartment); + builder.AppendSwitchIfNotNull("--apartment=",_apartment); - builder.AppendSwitchIfNotNull(c+"where=", _where); + builder.AppendSwitchIfNotNull("--where=", _where); - builder.AppendSwitchIfNotNull(c+"timeout=", _timeout); + builder.AppendSwitchIfNotNull("--timeout=", _timeout); - builder.AppendSwitchIfNotNull(c+"workers=", _workers); + builder.AppendSwitchIfNotNull("--workers=", _workers); - builder.AppendSwitchIfNotNull(c+"result=", _outputXmlFile); + builder.AppendSwitchIfNotNull("--result=", _outputXmlFile); - builder.AppendSwitchIfNotNull(c+"work=", _workingDirectory); + builder.AppendSwitchIfNotNull("--work=", _workingDirectory); - builder.AppendSwitchIfNotNull(c+"labels=", _showLabels); + builder.AppendSwitchIfNotNull("--labels=", _showLabels); - builder.AppendSwitchIfNotNull(c+"trace=", _trace); + builder.AppendSwitchIfNotNull("--trace=", _trace); return builder.ToString(); } private void CheckToolPath() { - string nunitPath = ToolPath == null ? String.Empty : ToolPath.Trim(); + string nunitPath = ToolPath?.Trim() ?? String.Empty; if (!String.IsNullOrEmpty(nunitPath)) { ToolPath = nunitPath;