@@ -14,7 +14,9 @@ public GivenDotnetOsArchOptions(ITestOutputHelper log) : base(log)
1414 {
1515 }
1616
17- const string ExpectedPrefix = "-maxcpucount -verbosity:m -tlp:default=auto -nologo" ;
17+ private static readonly string [ ] ExpectedPrefix = [ "-maxcpucount" , "-verbosity:m" , "-tlp:default=auto" , "-nologo" ] ;
18+ private const string NugetInteractiveProperty = "-property:NuGetInteractive=true" ;
19+ private static readonly string [ ] DefaultArgs = [ "-restore" , "-consoleloggerparameters:Summary" , NugetInteractiveProperty ] ;
1820
1921 private static readonly string WorkingDirectory =
2022 TestPathUtilities . FormatAbsolutePath ( nameof ( GivenDotnetBuildInvocation ) ) ;
@@ -25,11 +27,12 @@ public void OsOptionIsCorrectlyResolved()
2527 CommandDirectoryContext . PerformActionWithBasePath ( WorkingDirectory , ( ) =>
2628 {
2729 var msbuildPath = "<msbuildpath>" ;
28- var command = BuildCommand . FromArgs ( new string [ ] { "--os" , "os" } , msbuildPath ) ;
30+ var command = BuildCommand . FromArgs ( [ "--os" , "os" ] , msbuildPath ) ;
2931 var expectedArch = RuntimeInformation . ProcessArchitecture . Equals ( Architecture . Arm64 ) ? "arm64" : Environment . Is64BitOperatingSystem ? "x64" : "x86" ;
30- command . GetArgumentsToMSBuild ( )
32+
33+ command . GetArgumentTokensToMSBuild ( )
3134 . Should ( )
32- . StartWith ( $ " { ExpectedPrefix } -restore -consoleloggerparameters:Summary -property:RuntimeIdentifier=os-{ expectedArch } ") ;
35+ . BeEquivalentTo ( [ .. ExpectedPrefix , .. DefaultArgs , $ " -property:RuntimeIdentifier=os-{ expectedArch } "] ) ;
3336 } ) ;
3437 }
3538
@@ -39,7 +42,7 @@ public void ArchOptionIsCorrectlyResolved()
3942 CommandDirectoryContext . PerformActionWithBasePath ( WorkingDirectory , ( ) =>
4043 {
4144 var msbuildPath = "<msbuildpath>" ;
42- var command = BuildCommand . FromArgs ( new string [ ] { "--arch" , "arch" } , msbuildPath ) ;
45+ var command = BuildCommand . FromArgs ( [ "--arch" , "arch" ] , msbuildPath ) ;
4346 var expectedOs = RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ? "win" :
4447 RuntimeInformation . IsOSPlatform ( OSPlatform . Linux ) ? "linux" :
4548 RuntimeInformation . IsOSPlatform ( OSPlatform . OSX ) ? "osx" :
@@ -49,9 +52,9 @@ public void ArchOptionIsCorrectlyResolved()
4952 // Not a supported OS for running test
5053 return ;
5154 }
52- command . GetArgumentsToMSBuild ( )
55+ command . GetArgumentTokensToMSBuild ( )
5356 . Should ( )
54- . StartWith ( $ " { ExpectedPrefix } -restore -consoleloggerparameters:Summary -property:RuntimeIdentifier={ expectedOs } -arch") ;
57+ . BeEquivalentTo ( [ .. ExpectedPrefix , .. DefaultArgs , $ " -property:RuntimeIdentifier={ expectedOs } -arch"] ) ;
5558 } ) ;
5659 }
5760
@@ -61,10 +64,10 @@ public void OSAndArchOptionsCanBeCombined()
6164 CommandDirectoryContext . PerformActionWithBasePath ( WorkingDirectory , ( ) =>
6265 {
6366 var msbuildPath = "<msbuildpath>" ;
64- var command = BuildCommand . FromArgs ( new string [ ] { "--arch" , "arch" , "--os" , "os" } , msbuildPath ) ;
65- command . GetArgumentsToMSBuild ( )
67+ var command = BuildCommand . FromArgs ( [ "--arch" , "arch" , "--os" , "os" ] , msbuildPath ) ;
68+ command . GetArgumentTokensToMSBuild ( )
6669 . Should ( )
67- . StartWith ( $ " { ExpectedPrefix } -restore -consoleloggerparameters:Summary -property:RuntimeIdentifier=os-arch") ;
70+ . BeEquivalentTo ( [ .. ExpectedPrefix , .. DefaultArgs , " -property:RuntimeIdentifier=os-arch"] ) ;
6871 } ) ;
6972 }
7073
@@ -74,10 +77,17 @@ public void OptionsRespectUserSpecifiedSelfContained()
7477 CommandDirectoryContext . PerformActionWithBasePath ( WorkingDirectory , ( ) =>
7578 {
7679 var msbuildPath = "<msbuildpath>" ;
77- var command = BuildCommand . FromArgs ( new string [ ] { "--arch" , "arch" , "--os" , "os" , "--self-contained" } , msbuildPath ) ;
78- command . GetArgumentsToMSBuild ( )
80+ var command = BuildCommand . FromArgs ( [ "--arch" , "arch" , "--os" , "os" , "--self-contained" ] , msbuildPath ) ;
81+ string [ ] expectedArgs = [
82+ .. ExpectedPrefix ,
83+ .. DefaultArgs ,
84+ "-property:SelfContained=True" ,
85+ "-property:_CommandLineDefinedSelfContained=true" ,
86+ "-property:RuntimeIdentifier=os-arch"
87+ ] ;
88+ command . GetArgumentTokensToMSBuild ( )
7989 . Should ( )
80- . StartWith ( $ " { ExpectedPrefix } -restore -consoleloggerparameters:Summary -property:SelfContained=True -property:_CommandLineDefinedSelfContained=true -property:RuntimeIdentifier=os-arch" ) ;
90+ . BeEquivalentTo ( expectedArgs ) ;
8191 } ) ;
8292 }
8393
@@ -87,7 +97,7 @@ public void OSOptionCannotBeCombinedWithRuntime()
8797 CommandDirectoryContext . PerformActionWithBasePath ( WorkingDirectory , ( ) =>
8898 {
8999 var msbuildPath = "<msbuildpath>" ;
90- var exceptionThrown = Assert . Throws < GracefulException > ( ( ) => BuildCommand . FromArgs ( new string [ ] { "--os" , "os" , "--runtime" , "rid" } , msbuildPath ) ) ;
100+ var exceptionThrown = Assert . Throws < GracefulException > ( ( ) => BuildCommand . FromArgs ( [ "--os" , "os" , "--runtime" , "rid" ] , msbuildPath ) ) ;
91101 exceptionThrown . Message . Should ( ) . Be ( CommonLocalizableStrings . CannotSpecifyBothRuntimeAndOsOptions ) ;
92102 } ) ;
93103 }
@@ -98,7 +108,7 @@ public void ArchOptionCannotBeCombinedWithRuntime()
98108 CommandDirectoryContext . PerformActionWithBasePath ( WorkingDirectory , ( ) =>
99109 {
100110 var msbuildPath = "<msbuildpath>" ;
101- var exceptionThrown = Assert . Throws < GracefulException > ( ( ) => BuildCommand . FromArgs ( new string [ ] { "--arch" , "arch" , "--runtime" , "rid" } , msbuildPath ) ) ;
111+ var exceptionThrown = Assert . Throws < GracefulException > ( ( ) => BuildCommand . FromArgs ( [ "--arch" , "arch" , "--runtime" , "rid" ] , msbuildPath ) ) ;
102112 exceptionThrown . Message . Should ( ) . Be ( CommonLocalizableStrings . CannotSpecifyBothRuntimeAndArchOptions ) ;
103113 } ) ;
104114 }
@@ -143,10 +153,10 @@ public void ArchOptionsAMD64toX64()
143153 CommandDirectoryContext . PerformActionWithBasePath ( WorkingDirectory , ( ) =>
144154 {
145155 var msbuildPath = "<msbuildpath>" ;
146- var command = BuildCommand . FromArgs ( new string [ ] { "--arch" , "amd64" , "--os" , "os" } , msbuildPath ) ;
147- command . GetArgumentsToMSBuild ( )
156+ var command = BuildCommand . FromArgs ( [ "--arch" , "amd64" , "--os" , "os" ] , msbuildPath ) ;
157+ command . GetArgumentTokensToMSBuild ( )
148158 . Should ( )
149- . StartWith ( $ " { ExpectedPrefix } -restore -consoleloggerparameters:Summary -property:RuntimeIdentifier=os-x64") ;
159+ . BeEquivalentTo ( [ .. ExpectedPrefix , .. DefaultArgs , " -property:RuntimeIdentifier=os-x64"] ) ;
150160 } ) ;
151161 }
152162
@@ -160,11 +170,11 @@ public void ArchOptionIsResolvedFromRidUnderDifferentCulture()
160170 CommandDirectoryContext . PerformActionWithBasePath ( WorkingDirectory , ( ) =>
161171 {
162172 var msbuildPath = "<msbuildpath>" ;
163- var command = BuildCommand . FromArgs ( new string [ ] { "--os" , "os" } , msbuildPath ) ;
173+ var command = BuildCommand . FromArgs ( [ "--os" , "os" ] , msbuildPath ) ;
164174 var expectedArch = RuntimeInformation . ProcessArchitecture . Equals ( Architecture . Arm64 ) ? "arm64" : Environment . Is64BitOperatingSystem ? "x64" : "x86" ;
165- command . GetArgumentsToMSBuild ( )
175+ command . GetArgumentTokensToMSBuild ( )
166176 . Should ( )
167- . StartWith ( $ " { ExpectedPrefix } -restore -consoleloggerparameters:Summary -property:RuntimeIdentifier=os-{ expectedArch } ") ;
177+ . BeEquivalentTo ( [ .. ExpectedPrefix , .. DefaultArgs , $ " -property:RuntimeIdentifier=os-{ expectedArch } "] ) ;
168178 } ) ;
169179 }
170180 finally { CultureInfo . CurrentCulture = currentCultureBefore ; }
@@ -180,7 +190,7 @@ public void OsOptionIsResolvedFromRidUnderDifferentCulture()
180190 CommandDirectoryContext . PerformActionWithBasePath ( WorkingDirectory , ( ) =>
181191 {
182192 var msbuildPath = "<msbuildpath>" ;
183- var command = BuildCommand . FromArgs ( new string [ ] { "--arch" , "arch" } , msbuildPath ) ;
193+ var command = BuildCommand . FromArgs ( [ "--arch" , "arch" ] , msbuildPath ) ;
184194 var expectedOs = RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ? "win" :
185195 RuntimeInformation . IsOSPlatform ( OSPlatform . Linux ) ? "linux" :
186196 RuntimeInformation . IsOSPlatform ( OSPlatform . OSX ) ? "osx" :
@@ -190,9 +200,9 @@ public void OsOptionIsResolvedFromRidUnderDifferentCulture()
190200 // Not a supported OS for running test
191201 return ;
192202 }
193- command . GetArgumentsToMSBuild ( )
203+ command . GetArgumentTokensToMSBuild ( )
194204 . Should ( )
195- . StartWith ( $ " { ExpectedPrefix } -restore -consoleloggerparameters:Summary -property:RuntimeIdentifier={ expectedOs } -arch") ;
205+ . BeEquivalentTo ( [ .. ExpectedPrefix , .. DefaultArgs , $ " -property:RuntimeIdentifier={ expectedOs } -arch"] ) ;
196206 } ) ;
197207 }
198208 finally { CultureInfo . CurrentCulture = currentCultureBefore ; }
0 commit comments