@@ -42,11 +42,10 @@ This package is an internal implementation of the .NET Core SDK and is not meant
42
42
<!-- Pack .map files in symbols package (native symbols for Linux) -->
43
43
<AllowedOutputExtensionsInSymbolsPackageBuildOutputFolder >$(AllowedOutputExtensionsInSymbolsPackageBuildOutputFolder);.map</AllowedOutputExtensionsInSymbolsPackageBuildOutputFolder >
44
44
45
- <!-- Optimize the framework using the crossgen tool -->
45
+ <!-- Optimize the framework using the crossgen2 tool -->
46
46
<CrossgenOutput Condition =" '$(CrossgenOutput)' == '' AND '$(Configuration)' != 'Debug' " >true</CrossgenOutput >
47
- <UseCrossgen2 >true</UseCrossgen2 >
48
47
49
- <!-- Produce crossgen profiling symbols (.ni.pdb or .map files). -->
48
+ <!-- Produce crossgen2 profiling symbols (.ni.pdb or .map files). -->
50
49
<GenerateCrossgenProfilingSymbols >true</GenerateCrossgenProfilingSymbols >
51
50
<GenerateCrossgenProfilingSymbols Condition =" '$(CrossgenOutput)' != 'true' OR '$(TargetOsName)' == 'osx' " >false</GenerateCrossgenProfilingSymbols >
52
51
@@ -81,38 +80,28 @@ This package is an internal implementation of the .NET Core SDK and is not meant
81
80
<!-- This project should not be referenced via the `<Reference>` implementation. -->
82
81
<IsProjectReferenceProvider >false</IsProjectReferenceProvider >
83
82
84
- <!-- Properties related to crossgen -->
83
+ <!-- Properties related to crossgen2 -->
85
84
<CrossGenSymbolsType >PerfMap</CrossGenSymbolsType >
86
85
<CrossGenSymbolsType Condition =" '$(TargetOsName)' == 'win'" >PDB</CrossGenSymbolsType >
87
86
87
+ <!--
88
+ hostfxr and hostpolicy libraries are named libhostfxr.so and libhostpolicy.so in non-Windows
89
+ microsoft.netcore.app.runtime packages.
90
+ -->
88
91
<LibPrefix Condition =" '$(TargetOsName)' != 'win' " >lib</LibPrefix >
89
- <LibExtension >.so</LibExtension >
90
- <LibExtension Condition =" '$(TargetOsName)' == 'win' " >.dll</LibExtension >
91
- <LibExtension Condition =" '$(TargetOsName)' == 'osx' " >.dylib</LibExtension >
92
- <ExeExtension Condition =" '$(TargetOsName)' == 'win' " >.exe</ExeExtension >
93
- <!-- 3B = semicolon in ASCII -->
94
- <PathSeparator Condition =" '$(PathSeparator)' == ''" >:</PathSeparator >
95
- <PathSeparator Condition =" '$(TargetOsName)' == 'win' " >%3B</PathSeparator >
96
-
97
- <CrossCompileDirectory Condition =" '$(TargetRuntimeIdentifier)' == 'linux-arm' OR '$(TargetRuntimeIdentifier)' == 'linux-musl-arm'" >x64_arm</CrossCompileDirectory >
98
- <CrossCompileDirectory Condition =" '$(TargetArchitecture)' == 'arm64' AND '$(BuildArchitecture)' != 'arm64' " >x64_arm64</CrossCompileDirectory >
99
- <CrossCompileDirectory Condition =" '$(TargetRuntimeIdentifier)' == 'win-arm' " >x86_arm</CrossCompileDirectory >
100
-
101
- <!-- Crossgen executable name -->
102
- <CrossgenToolFileName >crossgen</CrossgenToolFileName >
103
- <CrossgenToolFileName Condition =" '$(TargetOsName)' == 'win' " >$(CrossgenToolFileName).exe</CrossgenToolFileName >
92
+
93
+ <!-- crossgen2 executable name -->
104
94
<Crossgen2ToolFileName >crossgen2</Crossgen2ToolFileName >
105
95
<Crossgen2ToolFileName Condition =" '$(TargetOsName)' == 'win' " >$(Crossgen2ToolFileName).exe</Crossgen2ToolFileName >
106
- <!-- Default crossgen executable relative path -->
107
- <CrossgenToolPackagePath >$(CrossgenToolFileName)</CrossgenToolPackagePath >
108
- <!-- Disambiguated RID-specific crossgen executable relative path -->
109
- <CrossgenToolPackagePath Condition =" '$(CrossCompileDirectory)' != '' " >$(CrossCompileDirectory)\$(CrossgenToolPackagePath)</CrossgenToolPackagePath >
110
96
111
97
<!-- E.g. "PkgMicrosoft_NETCore_App_Runtime_win-x64" (set in obj/Microsoft.AspNetCore.App.Runtime.csproj.nuget.g.props). -->
112
98
<RuntimePackageRootVariableName >PkgMicrosoft_NETCore_App_Runtime_$(RuntimeIdentifier)</RuntimePackageRootVariableName >
113
99
100
+ <!--
101
+ Determine the crossgen2 package path property name. Special case linux-musl-arm and linux-musl-arm64 because they
102
+ are built on an Ubuntu container with cross compilation tools. linux-musl-x64 is built in an alpine container.
103
+ -->
114
104
<BuildOsName >$(TargetOsName)</BuildOsName >
115
- <!-- linux-musl-arm and linux-musl-arm64 are built on an Ubuntu container with cross compilation tools. linux-musl-x64 is built in an alpine container -->
116
105
<BuildOsName Condition =" '$(TargetOsName)' == 'linux-musl' and '$(TargetArchitecture)'!='x64'" >linux</BuildOsName >
117
106
<Crossgen2PackageRootVariableName >PkgMicrosoft_NETCore_App_Crossgen2_$(BuildOsName)-$(BuildArchitecture)</Crossgen2PackageRootVariableName >
118
107
@@ -133,6 +122,10 @@ This package is an internal implementation of the .NET Core SDK and is not meant
133
122
PrivateAssets =" All"
134
123
GeneratePathProperty =" true" />
135
124
125
+ <!--
126
+ This package contains the crossgen2 tool. Unfortunately, it doesn't make the tool easy to use.
127
+ $(GeneratePathProperty) and hacks in the _ExpandRuntimePackageRoot target work around the gaps.
128
+ -->
136
129
<Reference Include =" Microsoft.NETCore.App.Crossgen2.$(BuildOsName)-$(BuildArchitecture)"
137
130
ExcludeAssets =" All"
138
131
PrivateAssets =" All"
@@ -299,7 +292,7 @@ This package is an internal implementation of the .NET Core SDK and is not meant
299
292
<BuildOutputFiles Include =" @(ReferenceCopyLocalPaths)" Condition =" '%(ReferenceCopyLocalPaths.IsNativeImage)' != 'true' " />
300
293
<!-- Include all .pdbs in build output. Some .pdb files are part of ReferenceCopyLocalPaths, but this can change when running /t:Pack /p:NoBuild=true. -->
301
294
<BuildOutputFiles Include =" $(TargetDir)*.pdb" Exclude =" @(ReferenceCopyLocalPaths)" />
302
- <!-- Crossgen symbols for Linux include a GUID in the file name which cannot be predicted. -->
295
+ <!-- crossgen2 symbols for Linux include a GUID in the file name which cannot be predicted. -->
303
296
<BuildOutputFiles Include =" $(TargetDir)*.map" Condition =" '$(CrossGenSymbolsType)' == 'PerfMap'" />
304
297
305
298
<!-- Strip duplicate Files by checking for distinct %(FileName)%(Extension) -->
@@ -354,8 +347,8 @@ This package is an internal implementation of the .NET Core SDK and is not meant
354
347
355
348
<Target Name =" _ExpandRuntimePackageRoot" >
356
349
<!--
357
- Use an item group for expansion of $($(RuntimePackageRootVariableName)) (an illegal MSBuild expression )
358
- i.e. the prop value's value.
350
+ Use an item group for expansion of $($(RuntimePackageRootVariableName)) and $($(Crossgen2PackageRootMapping) )
351
+ (both illegal MSBuild expressions) i.e. the prop value's value.
359
352
-->
360
353
<ItemGroup >
361
354
<RuntimePackageRootMapping Include =" $(RuntimePackageRootVariableName)" />
@@ -381,11 +374,11 @@ This package is an internal implementation of the .NET Core SDK and is not meant
381
374
<!-- The output directories of assemblies built in this repo contain a mix of ref and impl assemblies. Copy impl assemblies to a separate directory. -->
382
375
<Copy SourceFiles =" @(ReferenceCopyLocalPaths)" DestinationFolder =" $(CrossgenPlatformAssembliesDir)" Condition =" '%(ReferenceCopyLocalPaths.ProjectPath)' != ''" />
383
376
384
- <!-- Resolve list of assemblies to crossgen -->
377
+ <!-- Resolve list of assemblies to crossgen2 -->
385
378
<ItemGroup >
386
379
<IntermediateCrossgenAssembly Include =" @(ReferenceCopyLocalPaths)" Condition =" '%(ReferenceCopyLocalPaths.IsNativeImage)' != 'true' AND '%(ReferenceCopyLocalPaths.Extension)' != '.pdb'" />
387
380
388
- <!-- These are the paths used by crossgen to find assemblies that are expected to exist at runtime in the shared frameworks. -->
381
+ <!-- These are the paths used by crossgen2 to find assemblies that are expected to exist at runtime in the shared frameworks. -->
389
382
<_PlatformAssemblyPaths Include =" $(CrossgenToolDir)" />
390
383
<!-- Include the directories of the assemblies not built in this repo. These contain only implementation assemblies. -->
391
384
<_PlatformAssemblyPaths Include =" @(ReferenceCopyLocalPaths->'%(RootDir)%(Directory)')" Condition =" '%(ReferenceCopyLocalPaths.ProjectPath)' == ''" />
@@ -404,21 +397,13 @@ This package is an internal implementation of the .NET Core SDK and is not meant
404
397
</ItemGroup >
405
398
406
399
<PropertyGroup >
407
- <CrossgenToolPath Condition =" '$(UseCrossgen2)' != 'true'" >$([System.IO.Path]::Combine('$(RuntimePackageRoot)', 'tools', '$(CrossgenToolPackagePath)'))</CrossgenToolPath >
408
- <CrossgenToolPath Condition =" '$(UseCrossgen2)' == 'true'" >$([System.IO.Path]::Combine('$(Crossgen2PackageRoot)', 'tools', '$(Crossgen2ToolFileName)'))</CrossgenToolPath >
400
+ <CrossgenToolPath >$([System.IO.Path]::Combine('$(Crossgen2PackageRoot)', 'tools', '$(Crossgen2ToolFileName)'))</CrossgenToolPath >
409
401
<CrossgenSymbolsTargetDir >$(TargetDir)</CrossgenSymbolsTargetDir >
410
- <CrossgenPlatformAssemblyPaths >@(_PlatformAssemblyPaths->Distinct(), '$(PathSeparator)')</CrossgenPlatformAssemblyPaths >
411
402
412
403
<!-- Escaping (double backslash at end) required due to the way batch processes backslashes. -->
413
404
<CrossgenSymbolsTargetDir Condition =" HasTrailingSlash($(CrossgenSymbolsTargetDir)) AND '$(OS)' == 'Windows_NT'" >$(TargetDir)\</CrossgenSymbolsTargetDir >
414
- <CrossgenPlatformAssemblyPaths Condition =" HasTrailingSlash($(CrossgenPlatformAssemblyPaths)) AND '$(OS)' == 'Windows_NT'" >$(CrossgenPlatformAssemblyPaths)\</CrossgenPlatformAssemblyPaths >
415
405
</PropertyGroup >
416
406
417
- <WriteLinesToFile
418
- Lines =" -platform_assemblies_paths " $(CrossgenPlatformAssemblyPaths)" "
419
- File =" $(CrossgenToolDir)PlatformAssembliesPaths.rsp"
420
- Overwrite =" true" />
421
-
422
407
<WriteLinesToFile
423
408
Lines =" @(Crossgen2PlatformAssemblyPaths)"
424
409
File =" $(CrossgenToolDir)PlatformAssembliesPathsCrossgen2.rsp"
@@ -428,28 +413,27 @@ This package is an internal implementation of the .NET Core SDK and is not meant
428
413
<RuntimePackageFiles Include =" $(RuntimePackageRoot)runtimes\**\*" />
429
414
</ItemGroup >
430
415
431
- <Error Text =" Could not find crossgen $(CrossgenToolPath)" Condition =" ! Exists($(CrossgenToolPath))" />
416
+ <Error Text =" Could not find crossgen2 $(CrossgenToolPath)" Condition =" ! Exists($(CrossgenToolPath))" />
432
417
433
- <!-- Create tool directory with crossgen executable and runtime assemblies -->
418
+ <!-- Create tool directory with runtime assemblies -->
434
419
<Copy SourceFiles =" @(RuntimePackageFiles)" DestinationFolder =" $(CrossGenToolDir)" />
435
- <Copy Condition =" '$(UseCrossgen2)' != 'true'" SourceFiles =" $(CrossgenToolPath)" DestinationFolder =" $(CrossGenToolDir)" />
436
- <Exec Command =" chmod +x " $(CrossGenToolDir)$(CrossgenToolFileName)" " Condition =" '$(OS)' != 'Windows_NT' and '$(UseCrossgen2)' != 'true'" />
437
420
</Target >
438
421
422
+ <!-- Target executes once per @(IntermediateCrossgenAssembly) item. -->
439
423
<Target Name =" _BatchCrossGenAssemblies"
440
424
DependsOnTargets =" _ExpandRuntimePackageRoot"
441
425
Inputs =" @(IntermediateCrossgenAssembly)"
442
426
Outputs =" @(IntermediateCrossgenAssembly->'$(TargetDir)%(FileName)%(Extension)')" >
443
427
<PropertyGroup >
444
- <!-- Pick the right coreclr jit based on whether we are cross-compiling or not. -->
445
- <CoreCLRJitPath
446
- Condition =" '$(CrossCompileDirectory)' == ''" >$(RuntimePackageRoot)runtimes\$(RuntimeIdentifier)\native\$(LibPrefix)clrjit$(LibExtension)</CoreCLRJitPath >
447
- <CoreCLRJitPath
448
- Condition =" '$(CrossCompileDirectory)' != ''" >$(RuntimePackageRoot)runtimes\$(CrossCompileDirectory)\native\$(LibPrefix)clrjit$(LibExtension)</CoreCLRJitPath >
449
-
428
+ <!--
429
+ Handle different names for the target OS on the crossgen2 command line. This often matches neither
430
+ $(TargetOsName) nor $(BuildOsName).
431
+ -->
450
432
<Crossgen2TargetOs >$(TargetOsName)</Crossgen2TargetOs >
451
433
<Crossgen2TargetOs Condition =" '$(TargetOsName)' == 'win'" >windows</Crossgen2TargetOs >
452
434
<Crossgen2TargetOs Condition =" '$(TargetOsName)' == 'linux-musl'" >linux</Crossgen2TargetOs >
435
+
436
+ <!-- Compose the crossgen2 command line. -->
453
437
<Crossgen2Args >--targetarch:$(TargetArchitecture)</Crossgen2Args >
454
438
<Crossgen2Args >$(Crossgen2Args) --targetos:$(Crossgen2TargetOs)</Crossgen2Args >
455
439
<Crossgen2Args >$(Crossgen2Args) -O</Crossgen2Args >
@@ -459,20 +443,8 @@ This package is an internal implementation of the .NET Core SDK and is not meant
459
443
<Crossgen2Args Condition =" '$(GenerateCrossgenProfilingSymbols)' == 'true' and '$(TargetOsName)' != 'win'" >$(Crossgen2Args) --perfmap --perfmap-path:" $(CrossgenSymbolsTargetDir)" </Crossgen2Args >
460
444
</PropertyGroup >
461
445
462
- <Exec Condition =" '$(UseCrossgen2)' != 'true'"
463
- Command =" " $(CrossgenToolDir)$(CrossgenToolFileName)" -nologo -readytorun -in " %(IntermediateCrossgenAssembly.Identity)" -out " $(TargetDir)%(FileName)%(Extension)" -jitpath " $(CoreCLRJitPath)" " @$(CrossgenToolDir)PlatformAssembliesPaths.rsp" "
464
- EnvironmentVariables =" COMPlus_PartialNGen=0"
465
- IgnoreStandardErrorWarningFormat =" true"
466
- StandardOutputImportance =" High" />
467
-
468
- <Exec Condition =" '$(GenerateCrossgenProfilingSymbols)' == 'true' and '$(UseCrossgen2)' != 'true'"
469
- Command =" " $(CrossgenToolDir)$(CrossgenToolFileName)" -nologo -readytorun -in " $(TargetDir)%(IntermediateCrossgenAssembly.FileName)%(Extension)" -Create$(CrossGenSymbolsType) " $(CrossgenSymbolsTargetDir)" " @$(CrossgenToolDir)PlatformAssembliesPaths.rsp" "
470
- EnvironmentVariables =" COMPlus_PartialNGen=0"
471
- IgnoreStandardErrorWarningFormat =" true"
472
- StandardOutputImportance =" High" />
473
-
474
- <Exec Condition =" '$(UseCrossgen2)' == 'true'"
475
- Command =" " $(CrossgenToolPath)" $(Crossgen2Args) -o:" $(TargetDir)%(FileName)%(Extension)" " %(IntermediateCrossgenAssembly.Identity)" "
446
+ <!-- All metadata in batched task comes from current @(IntermediateCrossgenAssembly) item. -->
447
+ <Exec Command =" " $(CrossgenToolPath)" $(Crossgen2Args) -o:" $(TargetDir)%(FileName)%(Extension)" " %(IntermediateCrossgenAssembly.Identity)" "
476
448
IgnoreStandardErrorWarningFormat =" true"
477
449
StandardOutputImportance =" High" />
478
450
</Target >
0 commit comments