Skip to content

Commit

Permalink
UseLocalAppHostPack property
Browse files Browse the repository at this point in the history
  • Loading branch information
ViktorHofer committed Dec 4, 2022
1 parent 83279ca commit adcc6c8
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 21 deletions.
2 changes: 1 addition & 1 deletion eng/liveBuilds.targets
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<CoreCLRCrossTargetComponentDirName Condition="'$(TargetArchitecture)' == 'arm' and '$(BuildArchitecture)' != 'arm' and '$(TargetsLinux)' == 'true'">x64</CoreCLRCrossTargetComponentDirName>
<CoreCLRCrossTargetComponentDirName Condition="'$(TargetArchitecture)' == 'armel' and '$(BuildArchitecture)' != 'armel' and '$(TargetsLinux)' == 'true'">x64</CoreCLRCrossTargetComponentDirName>

<AppHostSourcePath Condition="'$(UseLiveAppHost)' == 'true'">$([MSBuild]::NormalizePath('$(DotNetHostBinDir)', 'apphost$(ExeSuffix)'))</AppHostSourcePath>
<AppHostSourcePath Condition="'$(UseLocalAppHostPack)' == 'true'">$([MSBuild]::NormalizePath('$(DotNetHostBinDir)', 'apphost$(ExeSuffix)'))</AppHostSourcePath>
<SingleFileHostSourcePath>$([MSBuild]::NormalizePath('$(CoreCLRArtifactsPath)', 'corehost', 'singlefilehost$(ExeSuffix)'))</SingleFileHostSourcePath>
</PropertyGroup>

Expand Down
48 changes: 35 additions & 13 deletions eng/targetingpacks.targets
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and
'$(TargetFrameworkVersion)' == 'v$(NetCoreAppCurrentVersion)'">
<UseLocalTargetingRuntimePack Condition="'$(UseLocalTargetingRuntimePack)' == ''">true</UseLocalTargetingRuntimePack>
<UseLocalAppHostPack Condition="'$(UseLocalAppHostPack)' == ''">true</UseLocalAppHostPack>
<EnableTargetingPackDownload>false</EnableTargetingPackDownload>
<!-- TODO: Enable when a 8.0.100 SDK is consumed
<EnableRuntimePackDownload>false</EnableRuntimePackDownload>
Expand Down Expand Up @@ -47,13 +48,6 @@
RuntimePackRuntimeIdentifiers="linux-arm;linux-arm64;linux-musl-arm64;linux-musl-x64;linux-x64;osx-x64;rhel.6-x64;win-arm;win-arm64;win-x64;win-x86;linux-musl-arm;osx-arm64;maccatalyst-x64;maccatalyst-arm64;linux-s390x;linux-bionic-arm;linux-bionic-arm64;linux-bionic-x64;linux-bionic-x86;browser-wasm;ios-arm64;ios-arm;iossimulator-arm64;iossimulator-x64;iossimulator-x86;tvos-arm64;tvossimulator-arm64;tvossimulator-x64;android-arm64;android-arm;android-x64;android-x86"
RuntimePackLabels="Mono"
Condition="'@(KnownRuntimePack)' == '' or !@(KnownRuntimePack->AnyHaveMetadataValue('TargetFramework', '$(NetCoreAppCurrent)'))"/>
<KnownAppHostPack Include="$(LocalFrameworkOverrideName)"
ExcludedRuntimeIdentifiers="android"
AppHostPackNamePattern="$(LocalFrameworkOverrideName).Host.**RID**"
AppHostPackVersion="$(ProductVersion)"
AppHostRuntimeIdentifiers="linux-arm;linux-arm64;linux-musl-arm64;linux-musl-x64;linux-x64;osx-x64;rhel.6-x64;tizen.4.0.0-armel;tizen.5.0.0-armel;win-arm;win-arm64;win-x64;win-x86;linux-musl-arm;osx-arm64;linux-s390x;linux-bionic-arm;linux-bionic-arm64;linux-bionic-x64;linux-bionic-x86"
TargetFramework="$(NetCoreAppCurrent)"
Condition="'@(KnownAppHostPack)' == '' or !@(KnownAppHostPack->AnyHaveMetadataValue('TargetFramework', '$(NetCoreAppCurrent)'))" />
<KnownCrossgen2Pack Include="$(LocalFrameworkOverrideName).Crossgen2"
TargetFramework="$(NetCoreAppCurrent)"
Crossgen2PackNamePattern="$(LocalFrameworkOverrideName).Crossgen2.**RID**"
Expand All @@ -68,6 +62,16 @@
Condition="'@(KnownILCompilerPack)' == '' or !@(KnownILCompilerPack->AnyHaveMetadataValue('TargetFramework', '$(NetCoreAppCurrent)'))" />
</ItemGroup>

<ItemGroup Condition="'$(UseLocalAppHostPack)' == 'true'">
<KnownAppHostPack Include="$(LocalFrameworkOverrideName)"
ExcludedRuntimeIdentifiers="android"
AppHostPackNamePattern="$(LocalFrameworkOverrideName).Host.**RID**"
AppHostPackVersion="$(ProductVersion)"
AppHostRuntimeIdentifiers="linux-arm;linux-arm64;linux-musl-arm64;linux-musl-x64;linux-x64;osx-x64;rhel.6-x64;tizen.4.0.0-armel;tizen.5.0.0-armel;win-arm;win-arm64;win-x64;win-x86;linux-musl-arm;osx-arm64;linux-s390x;linux-bionic-arm;linux-bionic-arm64;linux-bionic-x64;linux-bionic-x86"
TargetFramework="$(NetCoreAppCurrent)"
Condition="'@(KnownAppHostPack)' == '' or !@(KnownAppHostPack->AnyHaveMetadataValue('TargetFramework', '$(NetCoreAppCurrent)'))" />
</ItemGroup>

<!-- Simple name references will be resolved from the targeting pack folders and should never be copied to the output. -->
<ItemGroup>
<Reference Update="@(Reference)">
Expand All @@ -90,7 +94,7 @@

<!--
SDK tries to download runtime packs when RuntimeIdentifier is set, remove them from PackageDownload item.
TODO: Remove this target when an 8.0.100 SDK is consumed that respects EnableAppHostPackDownload.
TODO: Remove this target when an 8.0.100 SDK is consumed that respects EnableRuntimePackDownload.
-->
<Target Name="RemoveRuntimePackFromDownloadItem"
Condition="'$(UseLocalTargetingRuntimePack)' == 'true'"
Expand All @@ -100,19 +104,29 @@
Condition="'$(UsePackageDownload)' == 'true' and $([System.String]::Copy('%(Identity)').StartsWith('$(LocalFrameworkOverrideName).Runtime'))" />
<PackageReference Remove="@(PackageReference)"
Condition="'$(UsePackageDownload)' != 'true' and $([System.String]::Copy('%(Identity)').StartsWith('$(LocalFrameworkOverrideName).Runtime'))" />
<PackageDownload Remove="@(PackageDownload)"
Condition="'$(UsePackageDownload)' == 'true' and $([System.String]::Copy('%(Identity)').StartsWith('$(LocalFrameworkOverrideName).Host'))" />
<PackageReference Remove="@(PackageReference)"
Condition="'$(UsePackageDownload)' != 'true' and $([System.String]::Copy('%(Identity)').StartsWith('$(LocalFrameworkOverrideName).Host'))" />
<PackageDownload Remove="@(PackageDownload)"
Condition="'$(UsePackageDownload)' == 'true' and $([System.String]::Copy('%(Identity)').EndsWith('Microsoft.DotNet.ILCompiler'))" />
<PackageReference Remove="@(PackageReference)"
Condition="'$(UsePackageDownload)' != 'true' and $([System.String]::Copy('%(Identity)').EndsWith('Microsoft.DotNet.ILCompiler'))" />
</ItemGroup>
</Target>

<!--
TODO: Remove this target when an 8.0.100 SDK is consumed that respects EnableAppHostPackDownload.
-->
<Target Name="RemoveAppHostPackFromDownloadItem"
Condition="'$(UseLocalAppHostPack)' == 'true'"
AfterTargets="ProcessFrameworkReferences">
<ItemGroup>
<PackageDownload Remove="@(PackageDownload)"
Condition="'$(UsePackageDownload)' == 'true' and $([System.String]::Copy('%(Identity)').StartsWith('$(LocalFrameworkOverrideName).Host'))" />
<PackageReference Remove="@(PackageReference)"
Condition="'$(UsePackageDownload)' != 'true' and $([System.String]::Copy('%(Identity)').StartsWith('$(LocalFrameworkOverrideName).Host'))" />
</ItemGroup>
</Target>

<!-- Use local targeting/runtime pack for NetCoreAppCurrent. -->
<Target Name="UpdateTargetingAndRuntimePack"
<Target Name="UpdateLocalTargetingAndRuntimePack"
Condition="'$(UseLocalTargetingRuntimePack)' == 'true'"
AfterTargets="ResolveFrameworkReferences">
<ItemGroup>
Expand All @@ -129,6 +143,14 @@
Condition="'%(Identity)' == '$(LocalFrameworkOverrideName)'">
<RuntimePackPath Condition="'$(MicrosoftNetCoreAppRuntimePackDir)' != ''">$(MicrosoftNetCoreAppRuntimePackDir)</RuntimePackPath>
</ResolvedFrameworkReference>
</ItemGroup>
</Target>

<!-- Use local app host pack for NetCoreAppCurrent. -->
<Target Name="UpdateLocalAppHostPack"
Condition="'$(UseLocalAppHostPack)' == 'true'"
AfterTargets="ResolveFrameworkReferences">
<ItemGroup>
<ResolvedAppHostPack Path="$(AppHostSourcePath)"
PackageDirectory="$([System.IO.Path]::GetDirectoryName('$(AppHostSourcePath)'))"
PathInPackage="$([System.IO.Path]::GetFileName('$(AppHostSourcePath)'))"
Expand Down
2 changes: 1 addition & 1 deletion eng/testing/linker/trimmingTests.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<TrimmingTestDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'trimmingTests'))</TrimmingTestDir>
<TrimmingTestProjectsDir>$([MSBuild]::NormalizeDirectory('$(TrimmingTestDir)', 'projects'))</TrimmingTestProjectsDir>
<ProjectTemplate>$(MSBuildThisFileDirectory)project.csproj.template</ProjectTemplate>
<UseLiveAppHost>true</UseLiveAppHost>
<UseLocalAppHostPack>true</UseLocalAppHostPack>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
<EnableDynamicLoading>true</EnableDynamicLoading>
<DnneAddGeneratedBinaryToProject>true</DnneAddGeneratedBinaryToProject>
<DnneGenRollForward>Major</DnneGenRollForward>
<!-- NativeExports should use the live built apphost. We need to define a dependency
to the apphost to make sure that it is built before this project invokes DNNE. -->
<UseLocalAppHostPack>false</UseLocalAppHostPack>
<!-- To integrate with DNNE's architecture calculation, we need to set the RID for this project. -->
<RuntimeIdentifier>$(OutputRid)</RuntimeIdentifier>
<AppHostRuntimeIdentifier>$(PackageRID)</AppHostRuntimeIdentifier>
Expand All @@ -15,12 +18,9 @@
'$(TargetOS)' == 'tvOSSimulator'">true</_TargetsAppleOS>
</PropertyGroup>

<!-- NativeExports should use the live built apphost. We need to define a dependency
to the apphost to make sure that it is built before this project invokes DNNE.
Meanwhile, use a prebuilt apphost from the 7.0 SDK.
Remove this hack when the SDK understands the net8.0 tfm.
<!-- Until we use the live app host, use a prebuilt from the 7.0 SDK.
Issue: https://github.com/dotnet/runtime/issues/58109. -->
<ItemGroup>
<ItemGroup Condition="'$(UseLocalAppHostPack)' != 'true'">
<KnownAppHostPack Include="Microsoft.NETCore.App"
ExcludedRuntimeIdentifiers="android"
AppHostPackNamePattern="Microsoft.NETCore.App.Host.**RID**"
Expand Down Expand Up @@ -123,7 +123,7 @@
GetUnixCrossBuildArgumentsForDNNE"
BeforeTargets="DnneBuildNativeExports">
<PropertyGroup>
<DnneNetHostDir>$([System.IO.Path]::GetDirectoryName('$(AppHostSourcePath)'))</DnneNetHostDir>
<DnneNetHostDir>$([System.IO.Path]::GetDirectoryName('$( )'))</DnneNetHostDir>
</PropertyGroup>
</Target>
</Project>

0 comments on commit adcc6c8

Please sign in to comment.