@@ -27,6 +27,8 @@ public class GivenThatWeWantToPublishAnAotApp : SdkTest
27
27
{
28
28
private readonly string RuntimeIdentifier = $ "/p:RuntimeIdentifier={ RuntimeInformation . RuntimeIdentifier } ";
29
29
30
+ private readonly string ExplicitPackageVersion = "7.0.0-rc.2.22456.11" ;
31
+
30
32
public GivenThatWeWantToPublishAnAotApp ( ITestOutputHelper log ) : base ( log )
31
33
{
32
34
}
@@ -272,7 +274,7 @@ public void NativeAot_hw_runs_with_PackageReference_PublishAot_is_enabled(string
272
274
testProject . AdditionalProperties [ "PublishAot" ] = "true" ;
273
275
274
276
// This will add a reference to a package that will also be automatically imported by the SDK
275
- testProject . PackageReferences . Add ( new TestPackageReference ( "Microsoft.DotNet.ILCompiler" , "7.0.0-rc.2.22456.11" ) ) ;
277
+ testProject . PackageReferences . Add ( new TestPackageReference ( "Microsoft.DotNet.ILCompiler" , ExplicitPackageVersion ) ) ;
276
278
277
279
// Linux symbol files are embedded and require additional steps to be stripped to a separate file
278
280
// assumes /bin (or /usr/bin) are in the PATH
@@ -282,7 +284,7 @@ public void NativeAot_hw_runs_with_PackageReference_PublishAot_is_enabled(string
282
284
}
283
285
var testAsset = _testAssetsManager . CreateTestProject ( testProject ) ;
284
286
285
- var publishCommand = new PublishCommand ( Log , Path . Combine ( testAsset . TestRoot , testProject . Name ) ) ;
287
+ var publishCommand = new PublishCommand ( Log , Path . Combine ( testAsset . TestRoot , testProject . Name ) ) ;
286
288
publishCommand
287
289
. Execute ( $ "/p:RuntimeIdentifier={ rid } ")
288
290
. Should ( ) . Pass ( )
@@ -307,6 +309,8 @@ public void NativeAot_hw_runs_with_PackageReference_PublishAot_is_enabled(string
307
309
var command = new RunExeCommand ( Log , publishedExe )
308
310
. Execute ( ) . Should ( ) . Pass ( )
309
311
. And . HaveStdOutContaining ( "Hello World" ) ;
312
+
313
+ CheckIlcVersions ( Path . Combine ( testAsset . TestRoot , testProject . Name ) , targetFramework , ExplicitPackageVersion ) ;
310
314
}
311
315
}
312
316
@@ -322,7 +326,7 @@ public void NativeAot_hw_runs_with_PackageReference_PublishAot_is_empty(string t
322
326
var testProject = CreateHelloWorldTestProject ( targetFramework , projectName , true ) ;
323
327
324
328
// This will add a reference to a package that will also be automatically imported by the SDK
325
- testProject . PackageReferences . Add ( new TestPackageReference ( "Microsoft.DotNet.ILCompiler" , "7.0.0-rc.2.22456.11" ) ) ;
329
+ testProject . PackageReferences . Add ( new TestPackageReference ( "Microsoft.DotNet.ILCompiler" , ExplicitPackageVersion ) ) ;
326
330
327
331
// Linux symbol files are embedded and require additional steps to be stripped to a separate file
328
332
// assumes /bin (or /usr/bin) are in the PATH
@@ -373,7 +377,6 @@ public void NativeAot_hw_runs_with_cross_target_PublishAot_is_enabled(string tar
373
377
var publishedExe = Path . Combine ( publishDirectory , $ "{ testProject . Name } { Constants . ExeSuffix } ") ;
374
378
File . Exists ( publishedDll ) . Should ( ) . BeFalse ( ) ;
375
379
File . Exists ( publishedExe ) . Should ( ) . BeTrue ( ) ;
376
-
377
380
}
378
381
}
379
382
@@ -391,8 +394,8 @@ public void NativeAot_hw_runs_with_cross_PackageReference_PublishAot_is_enabled(
391
394
testProject . AdditionalProperties [ "PublishAot" ] = "true" ;
392
395
393
396
// This will add a reference to a package that will also be automatically imported by the SDK
394
- testProject . PackageReferences . Add ( new TestPackageReference ( "Microsoft.DotNet.ILCompiler" , "7.0.0-rc.2.22456.11" ) ) ;
395
- testProject . PackageReferences . Add ( new TestPackageReference ( "runtime.win-x64.Microsoft.DotNet.ILCompiler" , "7.0.0-rc.2.22456.11" ) ) ;
397
+ testProject . PackageReferences . Add ( new TestPackageReference ( "Microsoft.DotNet.ILCompiler" , ExplicitPackageVersion ) ) ;
398
+ testProject . PackageReferences . Add ( new TestPackageReference ( "runtime.win-x64.Microsoft.DotNet.ILCompiler" , ExplicitPackageVersion ) ) ;
396
399
397
400
var testAsset = _testAssetsManager . CreateTestProject ( testProject ) ;
398
401
@@ -409,6 +412,8 @@ public void NativeAot_hw_runs_with_cross_PackageReference_PublishAot_is_enabled(
409
412
var publishedExe = Path . Combine ( publishDirectory , $ "{ testProject . Name } { Constants . ExeSuffix } ") ;
410
413
File . Exists ( publishedDll ) . Should ( ) . BeFalse ( ) ;
411
414
File . Exists ( publishedExe ) . Should ( ) . BeTrue ( ) ;
415
+
416
+ CheckIlcVersions ( Path . Combine ( testAsset . TestRoot , testProject . Name ) , targetFramework , ExplicitPackageVersion ) ;
412
417
}
413
418
}
414
419
@@ -424,8 +429,8 @@ public void NativeAot_hw_runs_with_cross_PackageReference_PublishAot_is_empty(st
424
429
var testProject = CreateHelloWorldTestProject ( targetFramework , projectName , true ) ;
425
430
426
431
// This will add a reference to a package that will also be automatically imported by the SDK
427
- testProject . PackageReferences . Add ( new TestPackageReference ( "Microsoft.DotNet.ILCompiler" , "7.0.0-rc.2.22456.11" ) ) ;
428
- testProject . PackageReferences . Add ( new TestPackageReference ( "runtime.win-x64.Microsoft.DotNet.ILCompiler" , "7.0.0-rc.2.22456.11" ) ) ;
432
+ testProject . PackageReferences . Add ( new TestPackageReference ( "Microsoft.DotNet.ILCompiler" , ExplicitPackageVersion ) ) ;
433
+ testProject . PackageReferences . Add ( new TestPackageReference ( "runtime.win-x64.Microsoft.DotNet.ILCompiler" , ExplicitPackageVersion ) ) ;
429
434
430
435
var testAsset = _testAssetsManager . CreateTestProject ( testProject ) ;
431
436
@@ -438,7 +443,6 @@ public void NativeAot_hw_runs_with_cross_PackageReference_PublishAot_is_empty(st
438
443
var publishDirectory = publishCommand . GetOutputDirectory ( targetFramework : targetFramework , runtimeIdentifier : rid ) . FullName ;
439
444
var publishedDll = Path . Combine ( publishDirectory , $ "{ projectName } .dll") ;
440
445
File . Exists ( publishedDll ) . Should ( ) . BeTrue ( ) ;
441
-
442
446
}
443
447
}
444
448
@@ -476,7 +480,7 @@ public void NativeAot_hw_fails_with_sdk6_PackageReference_PublishAot_is_enabled(
476
480
var testProject = CreateHelloWorldTestProject ( "net6.0" , projectName , true ) ;
477
481
testProject . AdditionalProperties [ "PublishAot" ] = "true" ;
478
482
479
- testProject . PackageReferences . Add ( new TestPackageReference ( "Microsoft.DotNet.ILCompiler" , "7.0.0-rc.2.22456.11" ) ) ;
483
+ testProject . PackageReferences . Add ( new TestPackageReference ( "Microsoft.DotNet.ILCompiler" , ExplicitPackageVersion ) ) ;
480
484
481
485
var testAsset = _testAssetsManager . CreateTestProject ( testProject ) ;
482
486
@@ -700,6 +704,30 @@ public void It_publishes_with_implicit_rid_with_NativeAotApp(string targetFramew
700
704
}
701
705
}
702
706
707
+ private void CheckIlcVersions ( string projectPath , string targetFramework , string expectedVersion )
708
+ {
709
+ // Compiler version matches expected version
710
+ var ilcToolsPathCommand = new GetValuesCommand ( Log , projectPath , targetFramework , "IlcToolsPath" )
711
+ {
712
+ DependsOnTargets = "WriteIlcRspFileForCompilation"
713
+ } ;
714
+ ilcToolsPathCommand . Execute ( ) . Should ( ) . Pass ( ) ;
715
+ var ilcToolsPath = ilcToolsPathCommand . GetValues ( ) [ 0 ] ;
716
+ var ilcVersion = Path . GetFileName ( Path . GetDirectoryName ( Path . GetDirectoryName ( ilcToolsPath ) ) ) ;
717
+ ilcVersion . Should ( ) . Be ( ExplicitPackageVersion ) ;
718
+
719
+ // Compilation references (corelib) match expected version
720
+ var ilcReferenceCommand = new GetValuesCommand ( Log , projectPath , targetFramework , "IlcReference" , GetValuesCommand . ValueType . Item )
721
+ {
722
+ DependsOnTargets = "WriteIlcRspFileForCompilation"
723
+ } ;
724
+ ilcReferenceCommand . Execute ( ) . Should ( ) . Pass ( ) ;
725
+ var ilcReference = ilcReferenceCommand . GetValues ( ) ;
726
+ var corelibReference = ilcReference . Where ( r => Path . GetFileName ( r ) . Equals ( "System.Private.CoreLib.dll" ) ) . Single ( ) ;
727
+ var ilcReferenceVersion = Path . GetFileName ( Path . GetDirectoryName ( Path . GetDirectoryName ( corelibReference ) ) ) ;
728
+ ilcReferenceVersion . Should ( ) . Be ( ExplicitPackageVersion ) ;
729
+ }
730
+
703
731
private TestProject CreateHelloWorldTestProject ( string targetFramework , string projectName , bool isExecutable )
704
732
{
705
733
var testProject = new TestProject ( )
0 commit comments