@@ -622,8 +622,7 @@ public void FeatureAvailibilitySwitchIdentificationTest(string switchName)
622622 public void TargetsSwitchParameter ( )
623623 {
624624 CommandLineSwitches switches = new CommandLineSwitches ( ) ;
625- CommandLineParser parser = new CommandLineParser ( ) ;
626- parser . GatherCommandLineSwitches ( new List < string > ( ) { "/targets:targets.txt" } , switches ) ;
625+ MSBuildApp . GatherCommandLineSwitches ( new List < string > ( ) { "/targets:targets.txt" } , switches ) ;
627626
628627 switches . HaveErrors ( ) . ShouldBeFalse ( ) ;
629628 switches [ CommandLineSwitches . ParameterizedSwitch . Targets ] . ShouldBe ( new [ ] { "targets.txt" } ) ;
@@ -633,8 +632,7 @@ public void TargetsSwitchParameter()
633632 public void TargetsSwitchDoesNotSupportMultipleOccurrences ( )
634633 {
635634 CommandLineSwitches switches = new CommandLineSwitches ( ) ;
636- CommandLineParser parser = new CommandLineParser ( ) ;
637- parser . GatherCommandLineSwitches ( new List < string > ( ) { "/targets /targets" } , switches ) ;
635+ MSBuildApp . GatherCommandLineSwitches ( new List < string > ( ) { "/targets /targets" } , switches ) ;
638636
639637 switches . HaveErrors ( ) . ShouldBeTrue ( ) ;
640638 }
@@ -711,9 +709,8 @@ public void LowPrioritySwitchIdentificationTests(string lowpriority)
711709 public void GraphBuildSwitchCanHaveParameters ( )
712710 {
713711 CommandLineSwitches switches = new CommandLineSwitches ( ) ;
714- CommandLineParser parser = new CommandLineParser ( ) ;
715712
716- parser . GatherCommandLineSwitches ( new List < string > { "/graph" , "/graph:true; NoBuild ;; ;" , "/graph:foo" } , switches ) ;
713+ MSBuildApp . GatherCommandLineSwitches ( new List < string > { "/graph" , "/graph:true; NoBuild ;; ;" , "/graph:foo" } , switches ) ;
717714
718715 switches [ CommandLineSwitches . ParameterizedSwitch . GraphBuild ] . ShouldBe ( new [ ] { "true" , " NoBuild " , " " , "foo" } ) ;
719716
@@ -724,9 +721,8 @@ public void GraphBuildSwitchCanHaveParameters()
724721 public void GraphBuildSwitchCanBeParameterless ( )
725722 {
726723 CommandLineSwitches switches = new CommandLineSwitches ( ) ;
727- CommandLineParser parser = new CommandLineParser ( ) ;
728724
729- parser . GatherCommandLineSwitches ( new List < string > { "/graph" } , switches ) ;
725+ MSBuildApp . GatherCommandLineSwitches ( new List < string > { "/graph" } , switches ) ;
730726
731727 switches [ CommandLineSwitches . ParameterizedSwitch . GraphBuild ] . ShouldBe ( Array . Empty < string > ( ) ) ;
732728
@@ -737,9 +733,8 @@ public void GraphBuildSwitchCanBeParameterless()
737733 public void InputResultsCachesSupportsMultipleOccurrence ( )
738734 {
739735 CommandLineSwitches switches = new CommandLineSwitches ( ) ;
740- CommandLineParser parser = new CommandLineParser ( ) ;
741736
742- parser . GatherCommandLineSwitches ( new List < string > ( ) { "/irc" , "/irc:a;b" , "/irc:c;d" } , switches ) ;
737+ MSBuildApp . GatherCommandLineSwitches ( new List < string > ( ) { "/irc" , "/irc:a;b" , "/irc:c;d" } , switches ) ;
743738
744739 switches [ CommandLineSwitches . ParameterizedSwitch . InputResultsCaches ] . ShouldBe ( new [ ] { null , "a" , "b" , "c" , "d" } ) ;
745740
@@ -750,9 +745,8 @@ public void InputResultsCachesSupportsMultipleOccurrence()
750745 public void OutputResultsCache ( )
751746 {
752747 CommandLineSwitches switches = new CommandLineSwitches ( ) ;
753- CommandLineParser parser = new CommandLineParser ( ) ;
754748
755- parser . GatherCommandLineSwitches ( new List < string > ( ) { "/orc:a" } , switches ) ;
749+ MSBuildApp . GatherCommandLineSwitches ( new List < string > ( ) { "/orc:a" } , switches ) ;
756750
757751 switches [ CommandLineSwitches . ParameterizedSwitch . OutputResultsCache ] . ShouldBe ( new [ ] { "a" } ) ;
758752
@@ -763,9 +757,8 @@ public void OutputResultsCache()
763757 public void OutputResultsCachesDoesNotSupportMultipleOccurrences ( )
764758 {
765759 CommandLineSwitches switches = new CommandLineSwitches ( ) ;
766- CommandLineParser parser = new CommandLineParser ( ) ;
767760
768- parser . GatherCommandLineSwitches ( new List < string > ( ) { "/orc:a" , "/orc:b" } , switches ) ;
761+ MSBuildApp . GatherCommandLineSwitches ( new List < string > ( ) { "/orc:a" , "/orc:b" } , switches ) ;
769762
770763 switches . HaveErrors ( ) . ShouldBeTrue ( ) ;
771764 }
@@ -1295,9 +1288,8 @@ public void ExtractAnyLoggerParameterPickLast()
12951288 public void ProcessWarnAsErrorSwitchNotSpecified ( )
12961289 {
12971290 CommandLineSwitches commandLineSwitches = new CommandLineSwitches ( ) ;
1298- CommandLineParser parser = new CommandLineParser ( ) ;
12991291
1300- parser . GatherCommandLineSwitches ( new List < string > ( new [ ] { "" } ) , commandLineSwitches ) ;
1292+ MSBuildApp . GatherCommandLineSwitches ( new List < string > ( new [ ] { "" } ) , commandLineSwitches ) ;
13011293
13021294 Assert . Null ( MSBuildApp . ProcessWarnAsErrorSwitch ( commandLineSwitches ) ) ;
13031295 }
@@ -1311,9 +1303,8 @@ public void ProcessWarnAsErrorSwitchWithCodes()
13111303 ISet < string > expectedWarningsAsErrors = new HashSet < string > ( StringComparer . OrdinalIgnoreCase ) { "a" , "B" , "c" , "D" , "e" } ;
13121304
13131305 CommandLineSwitches commandLineSwitches = new CommandLineSwitches ( ) ;
1314- CommandLineParser parser = new CommandLineParser ( ) ;
13151306
1316- parser . GatherCommandLineSwitches ( new List < string > ( new [ ]
1307+ MSBuildApp . GatherCommandLineSwitches ( new List < string > ( new [ ]
13171308 {
13181309 "\" /warnaserror: a,B ; c \" " , // Leading, trailing, leading and trailing whitespace
13191310 "/warnaserror:A,b,C" , // Repeats of different case
@@ -1337,9 +1328,8 @@ public void ProcessWarnAsErrorSwitchWithCodes()
13371328 public void ProcessWarnAsErrorSwitchEmptySwitchClearsSet ( )
13381329 {
13391330 CommandLineSwitches commandLineSwitches = new CommandLineSwitches ( ) ;
1340- CommandLineParser parser = new CommandLineParser ( ) ;
13411331
1342- parser . GatherCommandLineSwitches ( new List < string > ( new [ ]
1332+ MSBuildApp . GatherCommandLineSwitches ( new List < string > ( new [ ]
13431333 {
13441334 "/warnaserror:a;b;c" ,
13451335 "/warnaserror" ,
@@ -1361,9 +1351,8 @@ public void ProcessWarnAsErrorSwitchValuesAfterEmptyAddOn()
13611351 ISet < string > expectedWarningsAsErors = new HashSet < string > ( StringComparer . OrdinalIgnoreCase ) { "e" , "f" , "g" } ;
13621352
13631353 CommandLineSwitches commandLineSwitches = new CommandLineSwitches ( ) ;
1364- CommandLineParser parser = new CommandLineParser ( ) ;
13651354
1366- parser . GatherCommandLineSwitches ( new List < string > ( new [ ]
1355+ MSBuildApp . GatherCommandLineSwitches ( new List < string > ( new [ ]
13671356 {
13681357 "/warnaserror:a;b;c" ,
13691358 "/warnaserror" ,
@@ -1384,9 +1373,8 @@ public void ProcessWarnAsErrorSwitchValuesAfterEmptyAddOn()
13841373 public void ProcessWarnAsErrorSwitchEmpty ( )
13851374 {
13861375 CommandLineSwitches commandLineSwitches = new CommandLineSwitches ( ) ;
1387- CommandLineParser parser = new CommandLineParser ( ) ;
13881376
1389- parser . GatherCommandLineSwitches ( new List < string > ( new [ ] { "/warnaserror" } ) , commandLineSwitches ) ;
1377+ MSBuildApp . GatherCommandLineSwitches ( new List < string > ( new [ ] { "/warnaserror" } ) , commandLineSwitches ) ;
13901378
13911379 ISet < string > actualWarningsAsErrors = MSBuildApp . ProcessWarnAsErrorSwitch ( commandLineSwitches ) ;
13921380
@@ -1402,11 +1390,10 @@ public void ProcessWarnAsErrorSwitchEmpty()
14021390 public void ProcessWarnAsMessageSwitchEmpty ( )
14031391 {
14041392 CommandLineSwitches commandLineSwitches = new CommandLineSwitches ( ) ;
1405- CommandLineParser parser = new CommandLineParser ( ) ;
14061393
14071394 // Set "expanded" content to match the placeholder so the verify can use the exact resource string as "expected."
14081395 string command = "{0}" ;
1409- parser . GatherCommandLineSwitches ( new List < string > ( new [ ] { "/warnasmessage" } ) , commandLineSwitches , command ) ;
1396+ MSBuildApp . GatherCommandLineSwitches ( new List < string > ( new [ ] { "/warnasmessage" } ) , commandLineSwitches , command ) ;
14101397
14111398 VerifySwitchError ( commandLineSwitches , "/warnasmessage" , AssemblyResources . GetString ( "MissingWarnAsMessageParameterError" ) ) ;
14121399 }
@@ -1423,15 +1410,13 @@ public void ProcessEnvironmentVariableSwitch()
14231410 env . SetEnvironmentVariable ( "ENVIRONMENTVARIABLE" , string . Empty ) ;
14241411
14251412 CommandLineSwitches commandLineSwitches = new ( ) ;
1426- CommandLineParser parser = new CommandLineParser ( ) ;
1427-
14281413 string fullCommandLine = "msbuild validProject.csproj %ENVIRONMENTVARIABLE%" ;
1429- parser . GatherCommandLineSwitches ( new List < string > ( ) { "validProject.csproj" , "%ENVIRONMENTVARIABLE%" } , commandLineSwitches , fullCommandLine ) ;
1414+ MSBuildApp . GatherCommandLineSwitches ( new List < string > ( ) { "validProject.csproj" , "%ENVIRONMENTVARIABLE%" } , commandLineSwitches , fullCommandLine ) ;
14301415 VerifySwitchError ( commandLineSwitches , "%ENVIRONMENTVARIABLE%" , String . Format ( AssemblyResources . GetString ( "EnvironmentVariableAsSwitch" ) , fullCommandLine ) ) ;
14311416
14321417 commandLineSwitches = new ( ) ;
14331418 fullCommandLine = "msbuild %ENVIRONMENTVARIABLE% validProject.csproj" ;
1434- parser . GatherCommandLineSwitches ( new List < string > ( ) { "%ENVIRONMENTVARIABLE%" , "validProject.csproj" } , commandLineSwitches , fullCommandLine ) ;
1419+ MSBuildApp . GatherCommandLineSwitches ( new List < string > ( ) { "%ENVIRONMENTVARIABLE%" , "validProject.csproj" } , commandLineSwitches , fullCommandLine ) ;
14351420 VerifySwitchError ( commandLineSwitches , "%ENVIRONMENTVARIABLE%" , String . Format ( AssemblyResources . GetString ( "EnvironmentVariableAsSwitch" ) , fullCommandLine ) ) ;
14361421 }
14371422 }
@@ -1445,9 +1430,8 @@ public void ProcessWarnAsMessageSwitchWithCodes()
14451430 ISet < string > expectedWarningsAsMessages = new HashSet < string > ( StringComparer . OrdinalIgnoreCase ) { "a" , "B" , "c" , "D" , "e" } ;
14461431
14471432 CommandLineSwitches commandLineSwitches = new CommandLineSwitches ( ) ;
1448- CommandLineParser parser = new CommandLineParser ( ) ;
14491433
1450- parser . GatherCommandLineSwitches ( new List < string > ( new [ ]
1434+ MSBuildApp . GatherCommandLineSwitches ( new List < string > ( new [ ]
14511435 {
14521436 "\" /warnasmessage: a,B ; c \" " , // Leading, trailing, leading and trailing whitespace
14531437 "/warnasmessage:A,b,C" , // Repeats of different case
@@ -1471,9 +1455,8 @@ public void ProcessWarnAsMessageSwitchWithCodes()
14711455 public void ProcessProfileEvaluationEmpty ( )
14721456 {
14731457 CommandLineSwitches commandLineSwitches = new CommandLineSwitches ( ) ;
1474- CommandLineParser parser = new CommandLineParser ( ) ;
14751458
1476- parser . GatherCommandLineSwitches ( new List < string > ( new [ ] { "/profileevaluation" } ) , commandLineSwitches ) ;
1459+ MSBuildApp . GatherCommandLineSwitches ( new List < string > ( new [ ] { "/profileevaluation" } ) , commandLineSwitches ) ;
14771460 commandLineSwitches [ CommandLineSwitches . ParameterizedSwitch . ProfileEvaluation ] [ 0 ] . ShouldBe ( "no-file" ) ;
14781461 }
14791462
@@ -1565,7 +1548,11 @@ public void ProcessInvalidTargetSwitch()
15651548 using TestEnvironment testEnvironment = TestEnvironment . Create ( ) ;
15661549 string project = testEnvironment . CreateTestProjectWithFiles ( "project.proj" , projectContent ) . ProjectFile ;
15671550
1551+ #if FEATURE_GET_COMMANDLINE
15681552 MSBuildApp . Execute ( @"msbuild.exe " + project + " /t:foo.bar" ) . ShouldBe ( MSBuildApp . ExitType . SwitchError ) ;
1553+ #else
1554+ MSBuildApp . Execute ( new [ ] { @"msbuild.exe" , project , "/t:foo.bar" } ) . ShouldBe ( MSBuildApp . ExitType . SwitchError ) ;
1555+ #endif
15691556 }
15701557
15711558 /// <summary>
0 commit comments