@@ -15,7 +15,7 @@ public class GivenThatWeWantToPublishAnAotApp : SdkTest
15
15
{
16
16
private readonly string RuntimeIdentifier = $ "/p:RuntimeIdentifier={ RuntimeInformation . RuntimeIdentifier } ";
17
17
18
- private readonly string ExplicitPackageVersion = "7 .0.0-rc.2.22456.11 " ;
18
+ private const string NetCurrentExplicitPackageVersion = "10 .0.0-preview.6.25316.103 " ;
19
19
20
20
public GivenThatWeWantToPublishAnAotApp ( ITestOutputHelper log ) : base ( log )
21
21
{
@@ -67,8 +67,10 @@ public void NativeAot_hw_runs_with_no_warnings_when_PublishAot_is_enabled(string
67
67
DoSymbolsExist ( publishDirectory , testProject . Name ) . Should ( ) . BeTrue ( $ "{ publishDirectory } should contain { testProject . Name } symbol") ;
68
68
IsNativeImage ( publishedExe ) . Should ( ) . BeTrue ( ) ;
69
69
70
+ bool useRuntimePackLayout = targetFramework is not ( "net7.0" or "net8.0" or "net9.0" ) ;
71
+
70
72
GetKnownILCompilerPackVersion ( testAsset , targetFramework , out string expectedVersion ) ;
71
- CheckIlcVersions ( testAsset , targetFramework , rid , expectedVersion ) ;
73
+ CheckIlcVersions ( testAsset , targetFramework , rid , expectedVersion , useRuntimePackLayout ) ;
72
74
73
75
var command = new RunExeCommand ( Log , publishedExe )
74
76
. Execute ( ) . Should ( ) . Pass ( )
@@ -249,8 +251,10 @@ public void NativeAot_app_builds_with_config_when_PublishAot_is_enabled(string t
249
251
File . Exists ( depsPath ) . Should ( ) . BeTrue ( ) ;
250
252
}
251
253
254
+ private const string Net7ExplicitPackageVersion = "7.0.0" ;
255
+
252
256
[ RequiresMSBuildVersionTheory ( "17.0.0.32901" ) ]
253
- [ InlineData ( ToolsetInfo . CurrentTargetFramework ) ]
257
+ [ InlineData ( "net7.0" ) ]
254
258
public void NativeAot_hw_runs_with_PackageReference_PublishAot_is_enabled ( string targetFramework )
255
259
{
256
260
if ( RuntimeInformation . IsOSPlatform ( OSPlatform . OSX ) )
@@ -266,7 +270,7 @@ public void NativeAot_hw_runs_with_PackageReference_PublishAot_is_enabled(string
266
270
testProject . AdditionalProperties [ "PublishAot" ] = "true" ;
267
271
268
272
// This will add a reference to a package that will also be automatically imported by the SDK
269
- testProject . PackageReferences . Add ( new TestPackageReference ( "Microsoft.DotNet.ILCompiler" , ExplicitPackageVersion ) ) ;
273
+ testProject . PackageReferences . Add ( new TestPackageReference ( "Microsoft.DotNet.ILCompiler" , Net7ExplicitPackageVersion ) ) ;
270
274
271
275
// Linux symbol files are embedded and require additional steps to be stripped to a separate file
272
276
// assumes /bin (or /usr/bin) are in the PATH
@@ -302,7 +306,7 @@ public void NativeAot_hw_runs_with_PackageReference_PublishAot_is_enabled(string
302
306
. Execute ( ) . Should ( ) . Pass ( )
303
307
. And . HaveStdOutContaining ( "Hello World" ) ;
304
308
305
- CheckIlcVersions ( testAsset , targetFramework , rid , ExplicitPackageVersion ) ;
309
+ CheckIlcVersions ( testAsset , targetFramework , rid , Net7ExplicitPackageVersion , useRuntimePackLayout : false ) ;
306
310
}
307
311
308
312
[ RequiresMSBuildVersionTheory ( "17.0.0.32901" ) ]
@@ -315,7 +319,7 @@ public void NativeAot_hw_runs_with_PackageReference_PublishAot_is_empty(string t
315
319
var testProject = CreateHelloWorldTestProject ( targetFramework , projectName , true ) ;
316
320
317
321
// This will add a reference to a package that will also be automatically imported by the SDK
318
- testProject . PackageReferences . Add ( new TestPackageReference ( "Microsoft.DotNet.ILCompiler" , ExplicitPackageVersion ) ) ;
322
+ testProject . PackageReferences . Add ( new TestPackageReference ( "Microsoft.DotNet.ILCompiler" , NetCurrentExplicitPackageVersion ) ) ;
319
323
320
324
// Linux symbol files are embedded and require additional steps to be stripped to a separate file
321
325
// assumes /bin (or /usr/bin) are in the PATH
@@ -343,7 +347,7 @@ public void NativeAot_hw_runs_with_PackageReference_PublishAot_is_empty(string t
343
347
}
344
348
345
349
[ RequiresMSBuildVersionTheory ( "17.0.0.32901" ) ]
346
- [ MemberData ( nameof ( Net7Plus ) , MemberType = typeof ( PublishTestUtils ) ) ]
350
+ [ InlineData ( ToolsetInfo . CurrentTargetFramework ) ]
347
351
public void NativeAot_hw_runs_with_cross_target_PublishAot_is_enabled ( string targetFramework )
348
352
{
349
353
if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) && ( RuntimeInformation . OSArchitecture == Architecture . X64 ) )
@@ -367,13 +371,13 @@ public void NativeAot_hw_runs_with_cross_target_PublishAot_is_enabled(string tar
367
371
File . Exists ( publishedExe ) . Should ( ) . BeTrue ( ) ;
368
372
369
373
GetKnownILCompilerPackVersion ( testAsset , targetFramework , out string expectedVersion ) ;
370
- CheckIlcVersions ( testAsset , targetFramework , rid , expectedVersion ) ;
374
+ CheckIlcVersions ( testAsset , targetFramework , rid , expectedVersion , useRuntimePackLayout : true ) ;
371
375
}
372
376
}
373
377
374
378
375
379
[ RequiresMSBuildVersionTheory ( "17.0.0.32901" ) ]
376
- [ MemberData ( nameof ( Net7Plus ) , MemberType = typeof ( PublishTestUtils ) ) ]
380
+ [ InlineData ( ToolsetInfo . CurrentTargetFramework ) ]
377
381
public void NativeAot_hw_runs_with_cross_PackageReference_PublishAot_is_enabled ( string targetFramework )
378
382
{
379
383
if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) && ( RuntimeInformation . OSArchitecture == Architecture . X64 ) )
@@ -382,11 +386,16 @@ public void NativeAot_hw_runs_with_cross_PackageReference_PublishAot_is_enabled(
382
386
var rid = "win-arm64" ;
383
387
384
388
var testProject = CreateHelloWorldTestProject ( targetFramework , projectName , true ) ;
389
+ testProject . RecordProperties ( "BundledNETCoreAppPackageVersion" ) ;
385
390
testProject . AdditionalProperties [ "PublishAot" ] = "true" ;
386
391
387
392
// This will add a reference to a package that will also be automatically imported by the SDK
388
- testProject . PackageReferences . Add ( new TestPackageReference ( "Microsoft.DotNet.ILCompiler" , ExplicitPackageVersion ) ) ;
389
- testProject . PackageReferences . Add ( new TestPackageReference ( "runtime.win-x64.Microsoft.DotNet.ILCompiler" , ExplicitPackageVersion ) ) ;
393
+ testProject . PackageReferences . Add ( new TestPackageReference ( "Microsoft.DotNet.ILCompiler" , "$(BundledNETCoreAppPackageVersion)" ) ) ;
394
+ testProject . AddItem ( "PackageDownload" , new Dictionary < string , string >
395
+ {
396
+ { "Include" , "Microsoft.NETCore.App.Runtime.NativeAOT.win-arm64" } ,
397
+ { "Version" , $ "[$(BundledNETCoreAppPackageVersion)]" }
398
+ } ) ;
390
399
391
400
var testAsset = _testAssetsManager . CreateTestProject ( testProject , identifier : targetFramework ) ;
392
401
@@ -398,13 +407,16 @@ public void NativeAot_hw_runs_with_cross_PackageReference_PublishAot_is_enabled(
398
407
. And . HaveStdOutContaining ( "warning" )
399
408
. And . HaveStdOutContaining ( "Microsoft.DotNet.ILCompiler" ) ;
400
409
410
+ var buildProperties = testProject . GetPropertyValues ( testAsset . TestRoot , targetFramework ) ;
411
+ var targetVersion = buildProperties [ "BundledNETCoreAppPackageVersion" ] ;
412
+
401
413
var publishDirectory = publishCommand . GetOutputDirectory ( targetFramework : targetFramework , runtimeIdentifier : rid ) . FullName ;
402
414
var publishedDll = Path . Combine ( publishDirectory , $ "{ projectName } .dll") ;
403
415
var publishedExe = Path . Combine ( publishDirectory , $ "{ testProject . Name } { Constants . ExeSuffix } ") ;
404
416
File . Exists ( publishedDll ) . Should ( ) . BeFalse ( ) ;
405
417
File . Exists ( publishedExe ) . Should ( ) . BeTrue ( ) ;
406
418
407
- CheckIlcVersions ( testAsset , targetFramework , rid , ExplicitPackageVersion ) ;
419
+ CheckIlcVersions ( testAsset , targetFramework , rid , targetVersion , useRuntimePackLayout : true ) ;
408
420
}
409
421
}
410
422
@@ -420,8 +432,8 @@ public void NativeAot_hw_runs_with_cross_PackageReference_PublishAot_is_empty(st
420
432
var testProject = CreateHelloWorldTestProject ( targetFramework , projectName , true ) ;
421
433
422
434
// This will add a reference to a package that will also be automatically imported by the SDK
423
- testProject . PackageReferences . Add ( new TestPackageReference ( "Microsoft.DotNet.ILCompiler" , ExplicitPackageVersion ) ) ;
424
- testProject . PackageReferences . Add ( new TestPackageReference ( "runtime.win-x64.Microsoft.DotNet.ILCompiler" , ExplicitPackageVersion ) ) ;
435
+ testProject . PackageReferences . Add ( new TestPackageReference ( "Microsoft.DotNet.ILCompiler" , NetCurrentExplicitPackageVersion ) ) ;
436
+ testProject . PackageReferences . Add ( new TestPackageReference ( "runtime.win-x64.Microsoft.DotNet.ILCompiler" , NetCurrentExplicitPackageVersion ) ) ;
425
437
426
438
var testAsset = _testAssetsManager . CreateTestProject ( testProject , identifier : targetFramework ) ;
427
439
@@ -469,7 +481,7 @@ public void NativeAot_hw_fails_with_sdk6_PackageReference_PublishAot_is_enabled(
469
481
var testProject = CreateHelloWorldTestProject ( "net6.0" , projectName , true ) ;
470
482
testProject . AdditionalProperties [ "PublishAot" ] = "true" ;
471
483
472
- testProject . PackageReferences . Add ( new TestPackageReference ( "Microsoft.DotNet.ILCompiler" , ExplicitPackageVersion ) ) ;
484
+ testProject . PackageReferences . Add ( new TestPackageReference ( "Microsoft.DotNet.ILCompiler" , NetCurrentExplicitPackageVersion ) ) ;
473
485
474
486
var testAsset = _testAssetsManager . CreateTestProject ( testProject , identifier : targetFramework ) ;
475
487
@@ -1041,7 +1053,7 @@ private void GetKnownILCompilerPackVersion(TestAsset testAsset, string targetFra
1041
1053
. Single ( ) ;
1042
1054
}
1043
1055
1044
- private void CheckIlcVersions ( TestAsset testAsset , string targetFramework , string rid , string expectedVersion )
1056
+ private void CheckIlcVersions ( TestAsset testAsset , string targetFramework , string rid , string expectedVersion , bool useRuntimePackLayout )
1045
1057
{
1046
1058
// Compiler version matches expected version
1047
1059
var ilcToolsPathCommand = new GetValuesCommand ( testAsset , "IlcToolsPath" , targetFramework : targetFramework )
@@ -1061,7 +1073,17 @@ private void CheckIlcVersions(TestAsset testAsset, string targetFramework, strin
1061
1073
ilcReferenceCommand . Execute ( $ "/p:RuntimeIdentifier={ rid } ", "/p:SelfContained=true" ) . Should ( ) . Pass ( ) ;
1062
1074
var ilcReference = ilcReferenceCommand . GetValues ( ) ;
1063
1075
var corelibReference = ilcReference . Where ( r => Path . GetFileName ( r ) . Equals ( "System.Private.CoreLib.dll" ) ) . Single ( ) ;
1064
- var ilcReferenceVersion = Path . GetFileName ( Path . GetDirectoryName ( Path . GetDirectoryName ( corelibReference ) ) ) ;
1076
+ string ilcReferenceVersion ;
1077
+ if ( useRuntimePackLayout )
1078
+ {
1079
+ // In the runtime pack layout, System.Private.CoreLib.dll is in the runtimes/<rid>/native directory
1080
+ ilcReferenceVersion = Path . GetFileName ( Path . GetDirectoryName ( Path . GetDirectoryName ( Path . GetDirectoryName ( Path . GetDirectoryName ( corelibReference ) ) ) ) ) ;
1081
+ }
1082
+ else
1083
+ {
1084
+ // In the old layout, System.Private.CoreLib.dll is in the framework directory
1085
+ ilcReferenceVersion = Path . GetFileName ( Path . GetDirectoryName ( Path . GetDirectoryName ( corelibReference ) ) ) ;
1086
+ }
1065
1087
ilcReferenceVersion . Should ( ) . Be ( expectedVersion ) ;
1066
1088
}
1067
1089
0 commit comments