Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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: 6 additions & 2 deletions eng/testing/tests.singlefile.targets
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
<TrimmerSingleWarn>false</TrimmerSingleWarn>
<StackTraceLineNumberSupport>true</StackTraceLineNumberSupport>

<!-- Use the SDK's ILCompilerTargetsPath hook to import ILC targets in the correct order
(before ILLink), matching how the shipping SDK imports them. -->
<PublishAot>true</PublishAot>
<_IlcReferencedAsPackage>false</_IlcReferencedAsPackage>
<ILCompilerTargetsPath>$(CoreCLRBuildIntegrationDir)Microsoft.DotNet.ILCompiler.SingleEntry.targets</ILCompilerTargetsPath>

<!-- Forced by ILLink targets -->
<SelfContained>true</SelfContained>
</PropertyGroup>
Expand All @@ -42,8 +48,6 @@
<DefineConstants>$(DefineConstants);TEST_READY_TO_RUN_COMPILED</DefineConstants>
</PropertyGroup>

<Import Project="$(CoreCLRBuildIntegrationDir)Microsoft.DotNet.ILCompiler.SingleEntry.targets" Condition="'$(TestNativeAot)' == 'true'" />

<ItemGroup Condition="'$(TestNativeAot)' == 'true'">
<RdXmlFile Include="$(MSBuildThisFileDirectory)default.rd.xml" />
<TrimmerRootAssembly Include="TestUtilities" Condition="'$(SkipTestUtilitiesReference)' != 'true'" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<PropertyGroup>
<!-- If the NativeAOT toolchain is being consumed via package, runtime-specific properties must be set before compilation can proceed -->
<ImportRuntimeIlcPackageTargetDependsOn>RunResolvePackageDependencies</ImportRuntimeIlcPackageTargetDependsOn>
<IlcSetupPropertiesDependsOn>ImportRuntimeIlcPackageTarget</IlcSetupPropertiesDependsOn>
<IlcSetupPropertiesDependsOn Condition="'$(_IlcReferencedAsPackage)' != 'false'">ImportRuntimeIlcPackageTarget</IlcSetupPropertiesDependsOn>
<IlcDynamicBuildPropertyDependencies>SetupProperties</IlcDynamicBuildPropertyDependencies>
</PropertyGroup>

Expand All @@ -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" />

<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" />

<!--
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)">
<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)">
<ItemGroup>
<ManagedBinary Condition="$(BuildingFrameworkLibrary) != 'true'" Include="@(IntermediateAssembly)" />
<IlcCompileInput Include="@(ManagedBinary)" />
Expand Down
1 change: 1 addition & 0 deletions src/tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
<RunAnalyzers>false</RunAnalyzers>
<EnableTrimAnalyzer>false</EnableTrimAnalyzer>
<EnableAotAnalyzer>false</EnableAotAnalyzer>
<EnableSingleFileAnalyzer>false</EnableSingleFileAnalyzer>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<SkipSigning Condition="'$(CrossGen)' == 'true'">true</SkipSigning>
<AssemblyKey>Test</AssemblyKey>
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 @@ -544,6 +544,12 @@

<IlcTreatWarningsAsErrors>false</IlcTreatWarningsAsErrors>

<!-- Use the SDK's ILCompilerTargetsPath hook to import ILC targets in the correct order
(before ILLink), matching how the shipping SDK imports them. -->
<PublishAot>true</PublishAot>
<_IlcReferencedAsPackage>false</_IlcReferencedAsPackage>
<ILCompilerTargetsPath>$(CoreCLRBuildIntegrationDir)Microsoft.DotNet.ILCompiler.SingleEntry.targets</ILCompilerTargetsPath>

<IlcToolsPath>$(CoreCLRCrossILCompilerDir)</IlcToolsPath>
<IlcBuildTasksPath>$(CoreCLRILCompilerDir)netstandard/ILCompiler.Build.Tasks.dll</IlcBuildTasksPath>
<IlcSdkPath>$(CoreCLRAotSdkDir)</IlcSdkPath>
Expand Down Expand Up @@ -575,7 +581,6 @@

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

<Import Project="$(CoreCLRBuildIntegrationDir)Microsoft.DotNet.ILCompiler.SingleEntry.targets" Condition="'$(TestBuildMode)' == 'nativeaot'" />
<Import Project="$(RepoRoot)eng/liveILLink.targets" />

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