@@ -42,10 +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
47
48
- <!-- Produce crossgen profiling symbols (.ni.pdb or .map files). -->
48
+ <!-- Produce crossgen2 profiling symbols (.ni.pdb or .map files). -->
49
49
<GenerateCrossgenProfilingSymbols >true</GenerateCrossgenProfilingSymbols >
50
50
<GenerateCrossgenProfilingSymbols Condition =" '$(CrossgenOutput)' != 'true' OR '$(TargetOsName)' == 'osx' " >false</GenerateCrossgenProfilingSymbols >
51
51
@@ -80,34 +80,31 @@ This package is an internal implementation of the .NET Core SDK and is not meant
80
80
<!-- This project should not be referenced via the `<Reference>` implementation. -->
81
81
<IsProjectReferenceProvider >false</IsProjectReferenceProvider >
82
82
83
- <!-- Properties related to crossgen -->
83
+ <!-- Properties related to crossgen2 -->
84
84
<CrossGenSymbolsType >PerfMap</CrossGenSymbolsType >
85
85
<CrossGenSymbolsType Condition =" '$(TargetOsName)' == 'win'" >PDB</CrossGenSymbolsType >
86
86
87
+ <!--
88
+ hostfxr and hostpolicy libraries are named libhostfxr.so and libhostpolicy.so in non-Windows
89
+ microsoft.netcore.app.runtime packages.
90
+ -->
87
91
<LibPrefix Condition =" '$(TargetOsName)' != 'win' " >lib</LibPrefix >
88
- <LibExtension >.so</LibExtension >
89
- <LibExtension Condition =" '$(TargetOsName)' == 'win' " >.dll</LibExtension >
90
- <LibExtension Condition =" '$(TargetOsName)' == 'osx' " >.dylib</LibExtension >
91
- <ExeExtension Condition =" '$(TargetOsName)' == 'win' " >.exe</ExeExtension >
92
- <!-- 3B = semicolon in ASCII -->
93
- <PathSeparator Condition =" '$(PathSeparator)' == ''" >:</PathSeparator >
94
- <PathSeparator Condition =" '$(TargetOsName)' == 'win' " >%3B</PathSeparator >
95
-
96
- <CrossCompileDirectory Condition =" '$(TargetRuntimeIdentifier)' == 'linux-arm' OR '$(TargetRuntimeIdentifier)' == 'linux-musl-arm'" >x64_arm</CrossCompileDirectory >
97
- <CrossCompileDirectory Condition =" '$(TargetArchitecture)' == 'arm64' AND '$(BuildArchitecture)' != 'arm64' " >x64_arm64</CrossCompileDirectory >
98
- <CrossCompileDirectory Condition =" '$(TargetRuntimeIdentifier)' == 'win-arm' " >x86_arm</CrossCompileDirectory >
99
-
100
- <!-- Crossgen executable name -->
101
- <CrossgenToolFileName >crossgen</CrossgenToolFileName >
102
- <CrossgenToolFileName Condition =" '$(TargetOsName)' == 'win' " >$(CrossgenToolFileName).exe</CrossgenToolFileName >
103
- <!-- Default crossgen executable relative path -->
104
- <CrossgenToolPackagePath >$(CrossgenToolFileName)</CrossgenToolPackagePath >
105
- <!-- Disambiguated RID-specific crossgen executable relative path -->
106
- <CrossgenToolPackagePath Condition =" '$(CrossCompileDirectory)' != '' " >$(CrossCompileDirectory)\$(CrossgenToolPackagePath)</CrossgenToolPackagePath >
92
+
93
+ <!-- crossgen2 executable name -->
94
+ <Crossgen2ToolFileName >crossgen2</Crossgen2ToolFileName >
95
+ <Crossgen2ToolFileName Condition =" '$(TargetOsName)' == 'win' " >$(Crossgen2ToolFileName).exe</Crossgen2ToolFileName >
107
96
108
97
<!-- E.g. "PkgMicrosoft_NETCore_App_Runtime_win-x64" (set in obj/Microsoft.AspNetCore.App.Runtime.csproj.nuget.g.props). -->
109
98
<RuntimePackageRootVariableName >PkgMicrosoft_NETCore_App_Runtime_$(RuntimeIdentifier)</RuntimePackageRootVariableName >
110
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
+ -->
104
+ <BuildOsName >$(TargetOsName)</BuildOsName >
105
+ <BuildOsName Condition =" '$(TargetOsName)' == 'linux-musl' and '$(TargetArchitecture)'!='x64'" >linux</BuildOsName >
106
+ <Crossgen2PackageRootVariableName >PkgMicrosoft_NETCore_App_Crossgen2_$(BuildOsName)-$(BuildArchitecture)</Crossgen2PackageRootVariableName >
107
+
111
108
<AssetTargetFallback >$(AssetTargetFallback);native,Version=0.0</AssetTargetFallback >
112
109
113
110
<NativePlatform >$(TargetArchitecture)</NativePlatform >
@@ -125,6 +122,15 @@ This package is an internal implementation of the .NET Core SDK and is not meant
125
122
PrivateAssets =" All"
126
123
GeneratePathProperty =" true" />
127
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
+ -->
129
+ <Reference Include =" Microsoft.NETCore.App.Crossgen2.$(BuildOsName)-$(BuildArchitecture)"
130
+ ExcludeAssets =" All"
131
+ PrivateAssets =" All"
132
+ GeneratePathProperty =" true" />
133
+
128
134
<ProjectReference Condition =" '$(BuildIisNativeProjects)' == 'true' AND $(BuildNative) "
129
135
Include =" $(RepoRoot)src\Servers\IIS\AspNetCoreModuleV2\InProcessRequestHandler\InProcessRequestHandler.vcxproj" >
130
136
<SetPlatform >Platform=$(NativePlatform)</SetPlatform >
@@ -286,7 +292,7 @@ This package is an internal implementation of the .NET Core SDK and is not meant
286
292
<BuildOutputFiles Include =" @(ReferenceCopyLocalPaths)" Condition =" '%(ReferenceCopyLocalPaths.IsNativeImage)' != 'true' " />
287
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. -->
288
294
<BuildOutputFiles Include =" $(TargetDir)*.pdb" Exclude =" @(ReferenceCopyLocalPaths)" />
289
- <!-- 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. -->
290
296
<BuildOutputFiles Include =" $(TargetDir)*.map" Condition =" '$(CrossGenSymbolsType)' == 'PerfMap'" />
291
297
292
298
<!-- Strip duplicate Files by checking for distinct %(FileName)%(Extension) -->
@@ -341,18 +347,24 @@ This package is an internal implementation of the .NET Core SDK and is not meant
341
347
342
348
<Target Name =" _ExpandRuntimePackageRoot" >
343
349
<!--
344
- Use an item group for expansion of $($(RuntimePackageRootVariableName)) (an illegal MSBuild expression )
345
- 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.
346
352
-->
347
353
<ItemGroup >
348
354
<RuntimePackageRootMapping Include =" $(RuntimePackageRootVariableName)" />
349
355
<RuntimePackageRootMapping >
350
356
<RuntimePackageRoot >$(%(Identity))</RuntimePackageRoot >
351
357
</RuntimePackageRootMapping >
358
+ <Crossgen2PackageRootMapping Include =" $(Crossgen2PackageRootVariableName)" />
359
+ <Crossgen2PackageRootMapping >
360
+ <Crossgen2PackageRoot >$(%(Identity))</Crossgen2PackageRoot >
361
+ </Crossgen2PackageRootMapping >
352
362
</ItemGroup >
353
363
<PropertyGroup >
354
364
<RuntimePackageRoot >@(RuntimePackageRootMapping->'%(RuntimePackageRoot)')</RuntimePackageRoot >
355
365
<RuntimePackageRoot >$([MSBuild]::EnsureTrailingSlash('$(RuntimePackageRoot)'))</RuntimePackageRoot >
366
+ <Crossgen2PackageRoot >@(Crossgen2PackageRootMapping->'%(Crossgen2PackageRoot)')</Crossgen2PackageRoot >
367
+ <Crossgen2PackageRoot >$([MSBuild]::EnsureTrailingSlash('$(Crossgen2PackageRoot)'))</Crossgen2PackageRoot >
356
368
</PropertyGroup >
357
369
</Target >
358
370
@@ -362,11 +374,11 @@ This package is an internal implementation of the .NET Core SDK and is not meant
362
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. -->
363
375
<Copy SourceFiles =" @(ReferenceCopyLocalPaths)" DestinationFolder =" $(CrossgenPlatformAssembliesDir)" Condition =" '%(ReferenceCopyLocalPaths.ProjectPath)' != ''" />
364
376
365
- <!-- Resolve list of assemblies to crossgen -->
377
+ <!-- Resolve list of assemblies to crossgen2 -->
366
378
<ItemGroup >
367
379
<IntermediateCrossgenAssembly Include =" @(ReferenceCopyLocalPaths)" Condition =" '%(ReferenceCopyLocalPaths.IsNativeImage)' != 'true' AND '%(ReferenceCopyLocalPaths.Extension)' != '.pdb'" />
368
380
369
- <!-- 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. -->
370
382
<_PlatformAssemblyPaths Include =" $(CrossgenToolDir)" />
371
383
<!-- Include the directories of the assemblies not built in this repo. These contain only implementation assemblies. -->
372
384
<_PlatformAssemblyPaths Include =" @(ReferenceCopyLocalPaths->'%(RootDir)%(Directory)')" Condition =" '%(ReferenceCopyLocalPaths.ProjectPath)' == ''" />
@@ -375,54 +387,64 @@ This package is an internal implementation of the .NET Core SDK and is not meant
375
387
376
388
<ReferenceCopyLocalPaths Remove =" @(IntermediateCrossgenAssembly)" />
377
389
<ReferenceCopyLocalPaths Include =" @(IntermediateCrossgenAssembly->'$(TargetDir)%(FileName)%(Extension)')" />
390
+
391
+ <_DistinctPlatformAssemblyPaths Include =" @(_PlatformAssemblyPaths->Distinct())" />
392
+ <_DistinctPlatformAssemblyPaths >
393
+ <CommandLineOption >-r:%(Identity)*.dll</CommandLineOption >
394
+ </_DistinctPlatformAssemblyPaths >
395
+
396
+ <Crossgen2PlatformAssemblyPaths Include =" @(_DistinctPlatformAssemblyPaths->'%(CommandLineOption)')" />
378
397
</ItemGroup >
379
398
380
399
<PropertyGroup >
381
- <CrossgenToolPath >$([System.IO.Path]::Combine('$(RuntimePackageRoot )', 'tools', '$(CrossgenToolPackagePath )'))</CrossgenToolPath >
400
+ <CrossgenToolPath >$([System.IO.Path]::Combine('$(Crossgen2PackageRoot )', 'tools', '$(Crossgen2ToolFileName )'))</CrossgenToolPath >
382
401
<CrossgenSymbolsTargetDir >$(TargetDir)</CrossgenSymbolsTargetDir >
383
- <CrossgenPlatformAssemblyPaths >@(_PlatformAssemblyPaths->Distinct(), '$(PathSeparator)')</CrossgenPlatformAssemblyPaths >
384
402
385
403
<!-- Escaping (double backslash at end) required due to the way batch processes backslashes. -->
386
404
<CrossgenSymbolsTargetDir Condition =" HasTrailingSlash($(CrossgenSymbolsTargetDir)) AND '$(OS)' == 'Windows_NT'" >$(TargetDir)\</CrossgenSymbolsTargetDir >
387
- <CrossgenPlatformAssemblyPaths Condition =" HasTrailingSlash($(CrossgenPlatformAssemblyPaths)) AND '$(OS)' == 'Windows_NT'" >$(CrossgenPlatformAssemblyPaths)\</CrossgenPlatformAssemblyPaths >
388
405
</PropertyGroup >
389
406
390
407
<WriteLinesToFile
391
- Lines =" -platform_assemblies_paths " $(CrossgenPlatformAssemblyPaths) " "
392
- File =" $(CrossgenToolDir)PlatformAssembliesPaths .rsp"
408
+ Lines =" @(Crossgen2PlatformAssemblyPaths) "
409
+ File =" $(CrossgenToolDir)PlatformAssembliesPathsCrossgen2 .rsp"
393
410
Overwrite =" true" />
394
411
395
412
<ItemGroup >
396
413
<RuntimePackageFiles Include =" $(RuntimePackageRoot)runtimes\**\*" />
397
414
</ItemGroup >
398
415
399
- <Error Text =" Could not find crossgen $(CrossgenToolPath)" Condition =" ! Exists($(CrossgenToolPath))" />
416
+ <Error Text =" Could not find crossgen2 $(CrossgenToolPath)" Condition =" ! Exists($(CrossgenToolPath))" />
400
417
401
- <!-- Create tool directory with crossgen executable and runtime assemblies -->
402
- <Copy SourceFiles =" @(RuntimePackageFiles);$(CrossgenToolPath)" DestinationFolder =" $(CrossGenToolDir)" />
403
- <Exec Command =" chmod +x " $(CrossGenToolDir)$(CrossgenToolFileName)" " Condition =" '$(OS)' != 'Windows_NT'" />
418
+ <!-- Create tool directory with runtime assemblies -->
419
+ <Copy SourceFiles =" @(RuntimePackageFiles)" DestinationFolder =" $(CrossGenToolDir)" />
404
420
</Target >
405
421
422
+ <!-- Target executes once per @(IntermediateCrossgenAssembly) item. -->
406
423
<Target Name =" _BatchCrossGenAssemblies"
407
424
DependsOnTargets =" _ExpandRuntimePackageRoot"
408
425
Inputs =" @(IntermediateCrossgenAssembly)"
409
426
Outputs =" @(IntermediateCrossgenAssembly->'$(TargetDir)%(FileName)%(Extension)')" >
410
427
<PropertyGroup >
411
- <!-- Pick the right coreclr jit based on whether we are cross-compiling or not. -->
412
- <CoreCLRJitPath
413
- Condition =" '$(CrossCompileDirectory)' == ''" >$(RuntimePackageRoot)runtimes\$(RuntimeIdentifier)\native\$(LibPrefix)clrjit$(LibExtension)</CoreCLRJitPath >
414
- <CoreCLRJitPath
415
- Condition =" '$(CrossCompileDirectory)' != ''" >$(RuntimePackageRoot)runtimes\$(CrossCompileDirectory)\native\$(LibPrefix)clrjit$(LibExtension)</CoreCLRJitPath >
428
+ <!--
429
+ Handle different names for the target OS on the crossgen2 command line. This often matches neither
430
+ $(TargetOsName) nor $(BuildOsName).
431
+ -->
432
+ <Crossgen2TargetOs >$(TargetOsName)</Crossgen2TargetOs >
433
+ <Crossgen2TargetOs Condition =" '$(TargetOsName)' == 'win'" >windows</Crossgen2TargetOs >
434
+ <Crossgen2TargetOs Condition =" '$(TargetOsName)' == 'linux-musl'" >linux</Crossgen2TargetOs >
435
+
436
+ <!-- Compose the crossgen2 command line. -->
437
+ <Crossgen2Args >--targetarch:$(TargetArchitecture)</Crossgen2Args >
438
+ <Crossgen2Args >$(Crossgen2Args) --targetos:$(Crossgen2TargetOs)</Crossgen2Args >
439
+ <Crossgen2Args >$(Crossgen2Args) -O</Crossgen2Args >
440
+ <Crossgen2Args >$(Crossgen2Args) @" $(CrossgenToolDir)PlatformAssembliesPathsCrossgen2.rsp" </Crossgen2Args >
441
+ <Crossgen2Args Condition =" Exists('$(RuntimePackageRoot)tools\StandardOptimizationData.mibc')" >$(Crossgen2Args) " -m:$(RuntimePackageRoot)tools\StandardOptimizationData.mibc" </Crossgen2Args >
442
+ <Crossgen2Args Condition =" '$(GenerateCrossgenProfilingSymbols)' == 'true' and '$(TargetOsName)' == 'win'" >$(Crossgen2Args) --pdb --pdb-path:" $(CrossgenSymbolsTargetDir)" </Crossgen2Args >
443
+ <Crossgen2Args Condition =" '$(GenerateCrossgenProfilingSymbols)' == 'true' and '$(TargetOsName)' != 'win'" >$(Crossgen2Args) --perfmap --perfmap-path:" $(CrossgenSymbolsTargetDir)" </Crossgen2Args >
416
444
</PropertyGroup >
417
445
418
- <Exec Command =" " $(CrossgenToolDir)$(CrossgenToolFileName)" -nologo -readytorun -in " %(IntermediateCrossgenAssembly.Identity)" -out " $(TargetDir)%(FileName)%(Extension)" -jitpath " $(CoreCLRJitPath)" " @$(CrossgenToolDir)PlatformAssembliesPaths.rsp" "
419
- EnvironmentVariables =" COMPlus_PartialNGen=0"
420
- IgnoreStandardErrorWarningFormat =" true"
421
- StandardOutputImportance =" High" />
422
-
423
- <Exec Condition =" '$(GenerateCrossgenProfilingSymbols)' == 'true' "
424
- Command =" " $(CrossgenToolDir)$(CrossgenToolFileName)" -nologo -readytorun -in " $(TargetDir)%(IntermediateCrossgenAssembly.FileName)%(Extension)" -Create$(CrossGenSymbolsType) " $(CrossgenSymbolsTargetDir)" " @$(CrossgenToolDir)PlatformAssembliesPaths.rsp" "
425
- EnvironmentVariables =" COMPlus_PartialNGen=0"
446
+ <!-- All metadata in batched task comes from current @(IntermediateCrossgenAssembly) item. -->
447
+ <Exec Command =" " $(CrossgenToolPath)" $(Crossgen2Args) -o:" $(TargetDir)%(FileName)%(Extension)" " %(IntermediateCrossgenAssembly.Identity)" "
426
448
IgnoreStandardErrorWarningFormat =" true"
427
449
StandardOutputImportance =" High" />
428
450
</Target >
0 commit comments