Skip to content

Commit 38bf9b4

Browse files
committed
Improve resolving runtime pack in WasmApp targets
Import targetingpacks.targets in WasmApp.InTree.targets and use similar logic in WasmApp.LocalBuild.targets.
1 parent 5f689e2 commit 38bf9b4

3 files changed

Lines changed: 13 additions & 15 deletions

File tree

eng/targetingpacks.targets

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<Project>
1212
<PropertyGroup>
1313
<LocalFrameworkOverrideName>$(MicrosoftNetCoreAppFrameworkName)</LocalFrameworkOverrideName>
14+
<TargetingpacksTargetsImported>true</TargetingpacksTargetsImported>
1415
</PropertyGroup>
1516

1617
<PropertyGroup Condition="'$(DisableImplicitFrameworkReferences)' != 'true' and
@@ -103,7 +104,7 @@
103104
</ItemGroup>
104105
</Target>
105106

106-
<!-- Use local targeting pack for NetCoreAppCurrent. -->
107+
<!-- Use local targeting/runtime pack for NetCoreAppCurrent. -->
107108
<Target Name="UpdateTargetingAndRuntimePack"
108109
Condition="'$(UseLocalTargetingRuntimePack)' == 'true'"
109110
AfterTargets="ResolveFrameworkReferences">

src/mono/wasm/build/WasmApp.InTree.targets

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,11 @@
22
<!-- This depends on the root Directory.Build.targets imported this file -->
33
<UsingTask TaskName="MonoAOTCompiler" AssemblyFile="$(MonoAOTCompilerTasksAssemblyPath)" />
44

5+
<Import Project="$(RepositoryEngineeringDir)targetingpacks.targets" Condition="'$(TargetingpacksTargetsImported)' != 'true'"/>
56
<Import Project="$(MSBuildThisFileDirectory)WasmApp.targets" />
67

7-
<!-- Redirect 'dotnet publish' to in-tree runtime pack -->
8-
<Target Name="TrickRuntimePackLocation" AfterTargets="ProcessFrameworkReferences" Condition="@(RuntimePack->Count()) != 0">
9-
<ItemGroup>
10-
<RuntimePack>
11-
<PackageDirectory>$([MSBuild]::NormalizeDirectory($(ArtifactsBinDir), 'microsoft.netcore.app.runtime.browser-wasm', $(Configuration)))</PackageDirectory>
12-
</RuntimePack>
13-
</ItemGroup>
14-
<Message Text="Using RuntimePack.PackageDirectory: %(RuntimePack.PackageDirectory)" Importance="Low" />
8+
<Target Name="PrintRuntimePackLocation" AfterTargets="UpdateTargetingAndRuntimePack">
9+
<Message Text="Used runtime pack: %(ResolvedRuntimePack.PackageDirectory)" Importance="high" />
1510
</Target>
1611

1712
<Target Name="RebuildWasmAppBuilder">

src/mono/wasm/build/WasmApp.LocalBuild.targets

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<PropertyGroup>
2727
<PublishTrimmed>true</PublishTrimmed>
2828
<TrimMode>link</TrimMode>
29+
<UseMonoRuntime>true</UseMonoRuntime>
2930
</PropertyGroup>
3031

3132
<PropertyGroup Condition="'$(Configuration)' != 'Debug'">
@@ -37,14 +38,15 @@
3738
<DebuggerSupport>false</DebuggerSupport>
3839
</PropertyGroup>
3940

40-
<Target Name="UpdateTargetingAndRuntimePack" AfterTargets="ResolveFrameworkReferences" DependsOnTargets="_PrepareAndValidateWasmInputs">
41+
<!-- Use local runtime pack -->
42+
<Target Name="UpdateRuntimePack" AfterTargets="ResolveFrameworkReferences" DependsOnTargets="_PrepareAndValidateWasmInputs">
43+
<Error Condition="@(ResolvedRuntimePack->Count()) == 0" Text="No runtime pack was resolved!" />
4144
<ItemGroup>
42-
<RuntimePack>
43-
<PackageDirectory>$(MicrosoftNetCoreAppRuntimePackLocationToUse)</PackageDirectory>
44-
</RuntimePack>
45-
<ResolvedRuntimePack PackageDirectory="$(MicrosoftNetCoreAppRuntimePackLocationToUse)" />
45+
<ResolvedRuntimePack PackageDirectory="$(MicrosoftNetCoreAppRuntimePackLocationToUse)"
46+
Condition="'$(MicrosoftNetCoreAppRuntimePackLocationToUse)' != '' and
47+
'%(ResolvedRuntimePack.FrameworkName)' == 'Microsoft.NETCore.App'" />
4648
</ItemGroup>
47-
<Message Text="Using Runtime pack from: %(ResolvedRuntimePack.PackageDirectory)" Importance="high" />
49+
<Message Text="Used runtime pack: %(ResolvedRuntimePack.PackageDirectory)" Importance="high" />
4850
</Target>
4951

5052
<!-- the actual properties need to get set in the props, so because UsingTasks depend on those. -->

0 commit comments

Comments
 (0)