@@ -78,7 +78,7 @@ public static (bool isSuccess, IConfig config, CommandLineOptions options) Parse
78
78
{
79
79
parser
80
80
. ParseArguments < CommandLineOptions > ( args )
81
- . WithParsed ( options => result = Validate ( options , logger ) ? ( true , CreateConfig ( options , globalConfig ) , options ) : ( false , default , default ) )
81
+ . WithParsed ( options => result = Validate ( options , logger ) ? ( true , CreateConfig ( options , globalConfig , args ) , options ) : ( false , default , default ) )
82
82
. WithNotParsed ( errors => result = ( false , default , default ) ) ;
83
83
}
84
84
@@ -163,9 +163,9 @@ private static bool Validate(CommandLineOptions options, ILogger logger)
163
163
return false ;
164
164
}
165
165
166
- if ( options . Runtimes . Count ( ) > 1 && ! options . CoreRunPaths . IsNullOrEmpty ( ) )
166
+ if ( ! options . CoreRunPaths . IsNullOrEmpty ( ) && ! RuntimeInformation . IsNetCore )
167
167
{
168
- logger . WriteLineError ( "CoreRun path can't be combined with multiple .NET Runtimes " ) ;
168
+ logger . WriteLineError ( "CoreRun path can be used only for .NET Core host processes. " ) ;
169
169
return false ;
170
170
}
171
171
@@ -197,12 +197,12 @@ private static bool Validate(CommandLineOptions options, ILogger logger)
197
197
return true ;
198
198
}
199
199
200
- private static IConfig CreateConfig ( CommandLineOptions options , IConfig globalConfig )
200
+ private static IConfig CreateConfig ( CommandLineOptions options , IConfig globalConfig , string [ ] args )
201
201
{
202
202
var config = new ManualConfig ( ) ;
203
203
204
204
var baseJob = GetBaseJob ( options , globalConfig ) ;
205
- var expanded = Expand ( baseJob . UnfreezeCopy ( ) , options ) . ToArray ( ) ; // UnfreezeCopy ensures that each of the expanded jobs will have it's own ID
205
+ var expanded = Expand ( baseJob . UnfreezeCopy ( ) , options , args ) . ToArray ( ) ; // UnfreezeCopy ensures that each of the expanded jobs will have it's own ID
206
206
if ( expanded . Length > 1 )
207
207
expanded [ 0 ] = expanded [ 0 ] . AsBaseline ( ) ; // if the user provides multiple jobs, then the first one should be a baseline
208
208
config . AddJob ( expanded ) ;
@@ -313,20 +313,46 @@ private static Job GetBaseJob(CommandLineOptions options, IConfig globalConfig)
313
313
. AsMutator ( ) ; // we mark it as mutator so it will be applied to other jobs defined via attributes and merged later in GetRunnableJobs method
314
314
}
315
315
316
- private static IEnumerable < Job > Expand ( Job baseJob , CommandLineOptions options )
316
+ private static IEnumerable < Job > Expand ( Job baseJob , CommandLineOptions options , string [ ] args )
317
317
{
318
318
if ( options . RunInProcess )
319
+ {
319
320
yield return baseJob . WithToolchain ( InProcessEmitToolchain . Instance ) ;
321
+ }
320
322
else if ( ! string . IsNullOrEmpty ( options . ClrVersion ) )
323
+ {
321
324
yield return baseJob . WithRuntime ( ClrRuntime . CreateForLocalFullNetFrameworkBuild ( options . ClrVersion ) ) ; // local builds of .NET Runtime
322
- else if ( options . CoreRunPaths . Any ( ) )
323
- foreach ( var coreRunPath in options . CoreRunPaths )
324
- yield return CreateCoreRunJob ( baseJob , options , coreRunPath ) ; // local CoreFX and CoreCLR builds
325
- else if ( options . CliPath != null && options . Runtimes . IsEmpty ( ) )
325
+ }
326
+ else if ( options . CliPath != null && options . Runtimes . IsEmpty ( ) && options . CoreRunPaths . IsEmpty ( ) )
327
+ {
326
328
yield return CreateCoreJobWithCli ( baseJob , options ) ;
329
+ }
327
330
else
328
- foreach ( string runtime in options . Runtimes ) // known runtimes
329
- yield return CreateJobForGivenRuntime ( baseJob , runtime , options ) ;
331
+ {
332
+ // in case both --runtimes and --corerun are specified, the first one is returned first and becomes a baseline job
333
+ string first = args . FirstOrDefault ( arg =>
334
+ arg . Equals ( "--runtimes" , StringComparison . OrdinalIgnoreCase )
335
+ || arg . Equals ( "-r" , StringComparison . OrdinalIgnoreCase )
336
+
337
+ || arg . Equals ( "--corerun" , StringComparison . OrdinalIgnoreCase ) ) ;
338
+
339
+ if ( first is null || first . Equals ( "--corerun" , StringComparison . OrdinalIgnoreCase ) )
340
+ {
341
+ foreach ( var coreRunPath in options . CoreRunPaths )
342
+ yield return CreateCoreRunJob ( baseJob , options , coreRunPath ) ; // local dotnet/runtime builds
343
+
344
+ foreach ( string runtime in options . Runtimes ) // known runtimes
345
+ yield return CreateJobForGivenRuntime ( baseJob , runtime , options ) ;
346
+ }
347
+ else
348
+ {
349
+ foreach ( string runtime in options . Runtimes ) // known runtimes
350
+ yield return CreateJobForGivenRuntime ( baseJob , runtime , options ) ;
351
+
352
+ foreach ( var coreRunPath in options . CoreRunPaths )
353
+ yield return CreateCoreRunJob ( baseJob , options , coreRunPath ) ; // local dotnet/runtime builds
354
+ }
355
+ }
330
356
}
331
357
332
358
private static Job CreateJobForGivenRuntime ( Job baseJob , string runtimeId , CommandLineOptions options )
@@ -479,7 +505,7 @@ private static Job CreateCoreRunJob(Job baseJob, CommandLineOptions options, Fil
479
505
. WithToolchain ( new CoreRunToolchain (
480
506
coreRunPath ,
481
507
createCopy : true ,
482
- targetFrameworkMoniker : options . Runtimes . SingleOrDefault ( ) ?? RuntimeInformation . GetCurrentRuntime ( ) . MsBuildMoniker ,
508
+ targetFrameworkMoniker : RuntimeInformation . GetCurrentRuntime ( ) . MsBuildMoniker ,
483
509
customDotNetCliPath : options . CliPath ,
484
510
restorePath : options . RestorePath ,
485
511
displayName : GetCoreRunToolchainDisplayName ( options . CoreRunPaths , coreRunPath ) ) ) ;
0 commit comments