@@ -42,11 +42,10 @@ This package is an internal implementation of the .NET Core SDK and is not meant
4242 <!-- Pack .map files in symbols package (native symbols for Linux) -->
4343 <AllowedOutputExtensionsInSymbolsPackageBuildOutputFolder >$(AllowedOutputExtensionsInSymbolsPackageBuildOutputFolder);.map</AllowedOutputExtensionsInSymbolsPackageBuildOutputFolder >
4444
45- <!-- Optimize the framework using the crossgen tool -->
45+ <!-- Optimize the framework using the crossgen2 tool -->
4646 <CrossgenOutput Condition =" '$(CrossgenOutput)' == '' AND '$(Configuration)' != 'Debug' " >true</CrossgenOutput >
47- <UseCrossgen2 >true</UseCrossgen2 >
4847
49- <!-- Produce crossgen profiling symbols (.ni.pdb or .map files). -->
48+ <!-- Produce crossgen2 profiling symbols (.ni.pdb or .map files). -->
5049 <GenerateCrossgenProfilingSymbols >true</GenerateCrossgenProfilingSymbols >
5150 <GenerateCrossgenProfilingSymbols Condition =" '$(CrossgenOutput)' != 'true' OR '$(TargetOsName)' == 'osx' " >false</GenerateCrossgenProfilingSymbols >
5251
@@ -81,38 +80,28 @@ This package is an internal implementation of the .NET Core SDK and is not meant
8180 <!-- This project should not be referenced via the `<Reference>` implementation. -->
8281 <IsProjectReferenceProvider >false</IsProjectReferenceProvider >
8382
84- <!-- Properties related to crossgen -->
83+ <!-- Properties related to crossgen2 -->
8584 <CrossGenSymbolsType >PerfMap</CrossGenSymbolsType >
8685 <CrossGenSymbolsType Condition =" '$(TargetOsName)' == 'win'" >PDB</CrossGenSymbolsType >
8786
87+ <!--
88+ hostfxr and hostpolicy libraries are named libhostfxr.so and libhostpolicy.so in non-Windows
89+ microsoft.netcore.app.runtime packages.
90+ -->
8891 <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 -->
10494 <Crossgen2ToolFileName >crossgen2</Crossgen2ToolFileName >
10595 <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 >
11096
11197 <!-- E.g. "PkgMicrosoft_NETCore_App_Runtime_win-x64" (set in obj/Microsoft.AspNetCore.App.Runtime.csproj.nuget.g.props). -->
11298 <RuntimePackageRootVariableName >PkgMicrosoft_NETCore_App_Runtime_$(RuntimeIdentifier)</RuntimePackageRootVariableName >
11399
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+ -->
114104 <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 -->
116105 <BuildOsName Condition =" '$(TargetOsName)' == 'linux-musl' and '$(TargetArchitecture)'!='x64'" >linux</BuildOsName >
117106 <Crossgen2PackageRootVariableName >PkgMicrosoft_NETCore_App_Crossgen2_$(BuildOsName)-$(BuildArchitecture)</Crossgen2PackageRootVariableName >
118107
@@ -133,6 +122,10 @@ This package is an internal implementation of the .NET Core SDK and is not meant
133122 PrivateAssets =" All"
134123 GeneratePathProperty =" true" />
135124
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+ -->
136129 <Reference Include =" Microsoft.NETCore.App.Crossgen2.$(BuildOsName)-$(BuildArchitecture)"
137130 ExcludeAssets =" All"
138131 PrivateAssets =" All"
@@ -299,7 +292,7 @@ This package is an internal implementation of the .NET Core SDK and is not meant
299292 <BuildOutputFiles Include =" @(ReferenceCopyLocalPaths)" Condition =" '%(ReferenceCopyLocalPaths.IsNativeImage)' != 'true' " />
300293 <!-- Include all .pdbs in build output. Some .pdb files are part of ReferenceCopyLocalPaths, but this can change when running /t:Pack /p:NoBuild=true. -->
301294 <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. -->
303296 <BuildOutputFiles Include =" $(TargetDir)*.map" Condition =" '$(CrossGenSymbolsType)' == 'PerfMap'" />
304297
305298 <!-- 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
354347
355348 <Target Name =" _ExpandRuntimePackageRoot" >
356349 <!--
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.
359352 -->
360353 <ItemGroup >
361354 <RuntimePackageRootMapping Include =" $(RuntimePackageRootVariableName)" />
@@ -381,11 +374,11 @@ This package is an internal implementation of the .NET Core SDK and is not meant
381374 <!-- The output directories of assemblies built in this repo contain a mix of ref and impl assemblies. Copy impl assemblies to a separate directory. -->
382375 <Copy SourceFiles =" @(ReferenceCopyLocalPaths)" DestinationFolder =" $(CrossgenPlatformAssembliesDir)" Condition =" '%(ReferenceCopyLocalPaths.ProjectPath)' != ''" />
383376
384- <!-- Resolve list of assemblies to crossgen -->
377+ <!-- Resolve list of assemblies to crossgen2 -->
385378 <ItemGroup >
386379 <IntermediateCrossgenAssembly Include =" @(ReferenceCopyLocalPaths)" Condition =" '%(ReferenceCopyLocalPaths.IsNativeImage)' != 'true' AND '%(ReferenceCopyLocalPaths.Extension)' != '.pdb'" />
387380
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. -->
389382 <_PlatformAssemblyPaths Include =" $(CrossgenToolDir)" />
390383 <!-- Include the directories of the assemblies not built in this repo. These contain only implementation assemblies. -->
391384 <_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
404397 </ItemGroup >
405398
406399 <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 >
409401 <CrossgenSymbolsTargetDir >$(TargetDir)</CrossgenSymbolsTargetDir >
410- <CrossgenPlatformAssemblyPaths >@(_PlatformAssemblyPaths->Distinct(), '$(PathSeparator)')</CrossgenPlatformAssemblyPaths >
411402
412403 <!-- Escaping (double backslash at end) required due to the way batch processes backslashes. -->
413404 <CrossgenSymbolsTargetDir Condition =" HasTrailingSlash($(CrossgenSymbolsTargetDir)) AND '$(OS)' == 'Windows_NT'" >$(TargetDir)\</CrossgenSymbolsTargetDir >
414- <CrossgenPlatformAssemblyPaths Condition =" HasTrailingSlash($(CrossgenPlatformAssemblyPaths)) AND '$(OS)' == 'Windows_NT'" >$(CrossgenPlatformAssemblyPaths)\</CrossgenPlatformAssemblyPaths >
415405 </PropertyGroup >
416406
417- <WriteLinesToFile
418- Lines =" -platform_assemblies_paths " $(CrossgenPlatformAssemblyPaths)" "
419- File =" $(CrossgenToolDir)PlatformAssembliesPaths.rsp"
420- Overwrite =" true" />
421-
422407 <WriteLinesToFile
423408 Lines =" @(Crossgen2PlatformAssemblyPaths)"
424409 File =" $(CrossgenToolDir)PlatformAssembliesPathsCrossgen2.rsp"
@@ -428,28 +413,27 @@ This package is an internal implementation of the .NET Core SDK and is not meant
428413 <RuntimePackageFiles Include =" $(RuntimePackageRoot)runtimes\**\*" />
429414 </ItemGroup >
430415
431- <Error Text =" Could not find crossgen $(CrossgenToolPath)" Condition =" ! Exists($(CrossgenToolPath))" />
416+ <Error Text =" Could not find crossgen2 $(CrossgenToolPath)" Condition =" ! Exists($(CrossgenToolPath))" />
432417
433- <!-- Create tool directory with crossgen executable and runtime assemblies -->
418+ <!-- Create tool directory with runtime assemblies -->
434419 <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'" />
437420 </Target >
438421
422+ <!-- Target executes once per @(IntermediateCrossgenAssembly) item. -->
439423 <Target Name =" _BatchCrossGenAssemblies"
440424 DependsOnTargets =" _ExpandRuntimePackageRoot"
441425 Inputs =" @(IntermediateCrossgenAssembly)"
442426 Outputs =" @(IntermediateCrossgenAssembly->'$(TargetDir)%(FileName)%(Extension)')" >
443427 <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+ -->
450432 <Crossgen2TargetOs >$(TargetOsName)</Crossgen2TargetOs >
451433 <Crossgen2TargetOs Condition =" '$(TargetOsName)' == 'win'" >windows</Crossgen2TargetOs >
452434 <Crossgen2TargetOs Condition =" '$(TargetOsName)' == 'linux-musl'" >linux</Crossgen2TargetOs >
435+
436+ <!-- Compose the crossgen2 command line. -->
453437 <Crossgen2Args >--targetarch:$(TargetArchitecture)</Crossgen2Args >
454438 <Crossgen2Args >$(Crossgen2Args) --targetos:$(Crossgen2TargetOs)</Crossgen2Args >
455439 <Crossgen2Args >$(Crossgen2Args) -O</Crossgen2Args >
@@ -459,20 +443,8 @@ This package is an internal implementation of the .NET Core SDK and is not meant
459443 <Crossgen2Args Condition =" '$(GenerateCrossgenProfilingSymbols)' == 'true' and '$(TargetOsName)' != 'win'" >$(Crossgen2Args) --perfmap --perfmap-path:" $(CrossgenSymbolsTargetDir)" </Crossgen2Args >
460444 </PropertyGroup >
461445
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)" "
476448 IgnoreStandardErrorWarningFormat =" true"
477449 StandardOutputImportance =" High" />
478450 </Target >
0 commit comments