Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion eng/testing/tests.singlefile.targets
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@
<DefineConstants>$(DefineConstants);TEST_READY_TO_RUN_COMPILED</DefineConstants>
</PropertyGroup>

<Import Project="$(CoreCLRBuildIntegrationDir)Microsoft.DotNet.ILCompiler.SingleEntry.targets" Condition="'$(TestNativeAot)' == 'true'" />
<!-- Import ILC targets after the SDK targets so that the NativeCompile target redefinition
in Microsoft.NETCore.Native.Publish.targets comes AFTER the SDK's empty placeholder
in Microsoft.NET.Publish.targets (MSBuild last-definition-wins). This mirrors how
ILLink targets are imported via $(ILLinkTargetsPath) at the end of Microsoft.NET.Sdk.targets. -->
<PropertyGroup Condition="'$(TestNativeAot)' == 'true'">
<AfterMicrosoftNETSdkTargets>$(AfterMicrosoftNETSdkTargets);$(CoreCLRBuildIntegrationDir)Microsoft.DotNet.ILCompiler.SingleEntry.targets</AfterMicrosoftNETSdkTargets>
Comment thread
sbomer marked this conversation as resolved.
Outdated
</PropertyGroup>

<ItemGroup Condition="'$(TestNativeAot)' == 'true'">
<RdXmlFile Include="$(MSBuildThisFileDirectory)default.rd.xml" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
</Target>

<!-- Locate the runtime package according to the current target runtime -->
<Target Name="ImportRuntimeIlcPackageTarget" Condition="'$(BuildingFrameworkLibrary)' != 'true' and '$(PublishAot)' == 'true'" DependsOnTargets="$(ImportRuntimeIlcPackageTargetDependsOn)" BeforeTargets="Publish">
<Target Name="ImportRuntimeIlcPackageTarget" Condition="'$(BuildingFrameworkLibrary)' != 'true' and '$(PublishAot)' == 'true'" DependsOnTargets="$(ImportRuntimeIlcPackageTargetDependsOn)">
<Error Condition="'@(ResolvedILCompilerPack)' == ''" Text="The ResolvedILCompilerPack ItemGroup is required for target ImportRuntimeIlcPackageTarget" />
Comment thread
sbomer marked this conversation as resolved.

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,21 @@
</Target>

<!--
This target hooks into the dotnet CLI publish pipeline. That pipeline has
a target called ComputeFilesToPublish which produces the ItemGroup
ResolvedFileToPublish. We modify this item group to control what gets
published after NativeAOT optimizes the application.
============================================================
NativeCompile

Redefine the SDK's empty NativeCompile placeholder target to perform the full
NativeAOT compilation pipeline: ILC compilation, native linking, and updating
ResolvedFileToPublish to replace managed assemblies with the native binary.

The SDK typically sequences this target in the publish pipeline as:
ComputeResolvedFilesToPublishList -> ILLink (when RunILLink is true) -> NativeCompile -> ...

This gives us a clean, explicit position after trim configuration (_PrepareTrimConfiguration),
regardless of whether ILLink itself runs.
============================================================
-->
<Target Name="ComputeLinkedFilesToPublish"
AfterTargets="ComputeResolvedFilesToPublishList"
<Target Name="NativeCompile"
DependsOnTargets="_ComputeAssembliesToCompileToNative;LinkNative">

<ItemGroup>
Expand Down Expand Up @@ -60,6 +68,10 @@
</ItemGroup>
</Target>

<!-- Back-compat: keep ComputeLinkedFilesToPublish as an empty target for anything that
references it via BeforeTargets/AfterTargets. The work moved to NativeCompile. -->
<Target Name="ComputeLinkedFilesToPublish" />
Comment thread
sbomer marked this conversation as resolved.
Outdated

<!--
Classify ResolvedFileToPublish for NativeAOT, then replace CoreCLR runtime pack
files with DefaultFrameworkAssemblies (tagged PostprocessAssembly=true) so that
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ The .NET Foundation licenses this file to you under the MIT license.
</ItemDefinitionGroup>

<!-- The properties below need to be defined only after we've found the correct runtime package reference -->
<Target Name="SetupProperties" DependsOnTargets="$(IlcSetupPropertiesDependsOn)" BeforeTargets="Publish">
<Target Name="SetupProperties" DependsOnTargets="$(IlcSetupPropertiesDependsOn)">
Comment thread
sbomer marked this conversation as resolved.
<ItemGroup>
<_NETCoreAppFrameworkReference Include="@(ResolvedFrameworkReference)" Condition="'%(ResolvedFrameworkReference.RuntimePackName)' == 'Microsoft.NETCore.App.Runtime.NativeAOT.$(RuntimeIdentifier)'" />
</ItemGroup>
Expand Down Expand Up @@ -156,7 +156,7 @@ The .NET Foundation licenses this file to you under the MIT license.
</ItemGroup>
</Target>

<Target Name="ComputeIlcCompileInputs" DependsOnTargets="$(IlcDynamicBuildPropertyDependencies)" BeforeTargets="Publish">
<Target Name="ComputeIlcCompileInputs" DependsOnTargets="$(IlcDynamicBuildPropertyDependencies)">
Comment thread
sbomer marked this conversation as resolved.
<ItemGroup>
<ManagedBinary Condition="$(BuildingFrameworkLibrary) != 'true'" Include="@(IntermediateAssembly)" />
<IlcCompileInput Include="@(ManagedBinary)" />
Expand Down
7 changes: 6 additions & 1 deletion src/tests/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,12 @@

<Import Project="$(RepositoryEngineeringDir)nativeSanitizers.targets" Condition="'$(TestBuildMode)' == 'nativeaot'" />

<Import Project="$(CoreCLRBuildIntegrationDir)Microsoft.DotNet.ILCompiler.SingleEntry.targets" Condition="'$(TestBuildMode)' == 'nativeaot'" />
<!-- Import ILC targets after the SDK targets so that the NativeCompile target redefinition
in Microsoft.NETCore.Native.Publish.targets comes AFTER the SDK's empty placeholder
in Microsoft.NET.Publish.targets (MSBuild last-definition-wins). -->
<PropertyGroup Condition="'$(TestBuildMode)' == 'nativeaot'">
<AfterMicrosoftNETSdkTargets>$(AfterMicrosoftNETSdkTargets);$(CoreCLRBuildIntegrationDir)Microsoft.DotNet.ILCompiler.SingleEntry.targets</AfterMicrosoftNETSdkTargets>
</PropertyGroup>
<Import Project="$(RepoRoot)eng/liveILLink.targets" />

<ItemGroup Condition="'$(TestBuildMode)' == 'nativeaot'">
Expand Down
Loading