Skip to content

Commit 443922a

Browse files
authored
Allow easier overriding of crossgen tasks/targets (#52021)
- Remove `ResolveReadyToRunCompilers` from `Microsoft.NET.Publish.targets`. This was always overriding (and identical to) the one in Microsoft.NET.CrossGen.targets - Add properties for `CrossGenTargetsPath` and `CrossGenTasksPath` that can be set to import a different targets file and use a different task assembly. This is more in line with what we do for ILLink and should allow simplification of how dotnet/runtime uses in-repo crossgen targets in dotnet/runtime
1 parent 49c0d73 commit 443922a

File tree

3 files changed

+12
-20
lines changed

3 files changed

+12
-20
lines changed

src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.CrossGen.targets

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ Copyright (c) .NET Foundation. All rights reserved.
3535
<PublishReadyToRunEmitSymbols Condition="'$(PublishReadyToRunEmitSymbols)' == '' and $(RuntimeIdentifier.StartsWith('osx-'))">false</PublishReadyToRunEmitSymbols>
3636
</PropertyGroup>
3737

38+
<PropertyGroup>
39+
<CrossGenTasksPath Condition="'$(CrossGenTasksPath)' == ''">$(MicrosoftNETBuildTasksAssembly)</CrossGenTasksPath>
40+
</PropertyGroup>
41+
3842
<!--
3943
============================================================
4044
PrepOptimizer
@@ -386,7 +390,7 @@ Copyright (c) .NET Foundation. All rights reserved.
386390
Prepare build for ReadyToRun compilations. Builds list of assemblies to compile, and computes paths to ReadyToRun compiler bits
387391
============================================================
388392
-->
389-
<UsingTask Condition="'$(Crossgen2TasksOverriden)' != 'true'" TaskName="PrepareForReadyToRunCompilation" AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" />
393+
<UsingTask Condition="'$(Crossgen2TasksOverriden)' != 'true'" TaskName="PrepareForReadyToRunCompilation" AssemblyFile="$(CrossGenTasksPath)" />
390394
<Target Name="_PrepareForReadyToRunCompilation" DependsOnTargets="ResolveReadyToRunCompilers;_ComputeManagedRuntimePackAssemblies;_ComputeAssembliesToPostprocessOnPublish">
391395

392396
<PropertyGroup>
@@ -453,7 +457,7 @@ Copyright (c) .NET Foundation. All rights reserved.
453457
</ItemGroup>
454458
</Target>
455459

456-
<UsingTask Condition="'$(Crossgen2TasksOverriden)' != 'true'" TaskName="ResolveReadyToRunCompilers" AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" />
460+
<UsingTask Condition="'$(Crossgen2TasksOverriden)' != 'true'" TaskName="ResolveReadyToRunCompilers" AssemblyFile="$(CrossGenTasksPath)" />
457461
<Target Name="ResolveReadyToRunCompilers">
458462
<ResolveReadyToRunCompilers RuntimePacks="@(ResolvedRuntimePack)"
459463
Crossgen2Packs="@(ResolvedCrossgen2Pack)"
@@ -476,7 +480,7 @@ Copyright (c) .NET Foundation. All rights reserved.
476480
Compiles assemblies in the _ReadyToRunCompileList list into ReadyToRun images
477481
============================================================
478482
-->
479-
<UsingTask Condition="'$(Crossgen2TasksOverriden)' != 'true'" TaskName="RunReadyToRunCompiler" AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" />
483+
<UsingTask Condition="'$(Crossgen2TasksOverriden)' != 'true'" TaskName="RunReadyToRunCompiler" AssemblyFile="$(CrossGenTasksPath)" />
480484
<Target Name="_CreateR2RImages"
481485
Inputs="$(MSBuildAllProjects);@(_ReadyToRunCompileList);@(_ReadyToRunCompositeBuildInput);@(_ReadyToRunPgoFiles)"
482486
Outputs="%(_ReadyToRunCompileList.OutputR2RImage);%(_ReadyToRunCompileList.OutputPDBImage)">

src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -411,22 +411,6 @@ Copyright (c) .NET Foundation. All rights reserved.
411411
</Copy>
412412
</Target>
413413

414-
<UsingTask TaskName="ResolveReadyToRunCompilers" AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" />
415-
<Target Name="ResolveReadyToRunCompilers">
416-
<ResolveReadyToRunCompilers RuntimePacks="@(ResolvedRuntimePack)"
417-
Crossgen2Packs="@(ResolvedCrossgen2Pack)"
418-
TargetingPacks="@(ResolvedTargetingPack)"
419-
RuntimeGraphPath="$(RuntimeIdentifierGraphPath)"
420-
NETCoreSdkRuntimeIdentifier="$(NETCoreSdkRuntimeIdentifier)"
421-
EmitSymbols="$(PublishReadyToRunEmitSymbols)"
422-
ReadyToRunUseCrossgen2="$(PublishReadyToRunUseCrossgen2)"
423-
PerfmapFormatVersion="$(PublishReadyToRunPerfmapFormatVersion)">
424-
425-
<Output TaskParameter="CrossgenTool" ItemName="CrossgenTool" />
426-
<Output TaskParameter="Crossgen2Tool" ItemName="Crossgen2Tool" />
427-
</ResolveReadyToRunCompilers>
428-
</Target>
429-
430414
<!--
431415
============================================================
432416
_ComputeResolvedFilesToPublishTypes

src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1370,14 +1370,18 @@ Copyright (c) .NET Foundation. All rights reserved.
13701370
<ProjectCapability Remove="ReferenceManagerAssemblies" />
13711371
</ItemGroup>
13721372

1373+
<PropertyGroup>
1374+
<CrossGenTargetsPath Condition="'$(CrossGenTargetsPath)' == ''">$(MSBuildThisFileDirectory)Microsoft.NET.CrossGen.targets</CrossGenTargetsPath>
1375+
</PropertyGroup>
1376+
13731377
<Import Project="$(MSBuildThisFileDirectory)Microsoft.NET.Sdk.SourceLink.targets" Condition="'$(SuppressImplicitGitSourceLink)' != 'true'" />
13741378
<Import Project="$(MSBuildThisFileDirectory)Microsoft.NET.DisableStandardFrameworkResolution.targets" Condition="'$(DisableStandardFrameworkResolution)' == 'true'" />
13751379
<Import Project="$(MSBuildThisFileDirectory)Microsoft.NET.DesignerSupport.targets" />
13761380
<Import Project="$(MSBuildThisFileDirectory)Microsoft.NET.GenerateAssemblyInfo.targets" Condition="'$(UsingNETSdkDefaults)' == 'true'"/>
13771381
<Import Project="$(MSBuildThisFileDirectory)Microsoft.NET.GenerateGlobalUsings.targets" Condition="'$(Language)' == 'C#'"/>
13781382
<Import Project="$(MSBuildThisFileDirectory)Microsoft.NET.GenerateSupportedRuntime.targets" />
13791383
<Import Project="$(MSBuildThisFileDirectory)Microsoft.NET.ComposeStore.targets" Condition="'$(UsingNETSdkDefaults)' == 'true'" />
1380-
<Import Project="$(MSBuildThisFileDirectory)Microsoft.NET.CrossGen.targets" />
1384+
<Import Project="$(CrossGenTargetsPath)" />
13811385
<Import Project="$(MSBuildThisFileDirectory)Microsoft.NET.ObsoleteReferences.targets" />
13821386
<Import Project="$(MSBuildThisFileDirectory)Microsoft.NET.Publish.targets" />
13831387
<Import Project="$(MSBuildThisFileDirectory)Microsoft.NET.PackStubs.targets" Condition="('$(Language)' == 'C++' and '$(_EnablePackageReferencesInVCProjects)' != 'true')"/>

0 commit comments

Comments
 (0)