Skip to content

Commit

Permalink
Improve resolving runtime pack in WasmApp targets (#55258)
Browse files Browse the repository at this point in the history
Use similar logic to `eng/targetingpacks.targets` in `WasmApp.InTree.targets` and `WasmApp.LocalBuild.targets`.

Also set `UseMonoRuntime=true` to make sure we get the Mono-based runtime pack.
  • Loading branch information
akoeplinger authored Jul 13, 2021
1 parent 53db2ec commit b2a670b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
3 changes: 2 additions & 1 deletion eng/targetingpacks.targets
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<Project>
<PropertyGroup>
<LocalFrameworkOverrideName>$(MicrosoftNetCoreAppFrameworkName)</LocalFrameworkOverrideName>
<TargetingpacksTargetsImported>true</TargetingpacksTargetsImported>
</PropertyGroup>

<PropertyGroup Condition="'$(DisableImplicitFrameworkReferences)' != 'true' and
Expand Down Expand Up @@ -103,7 +104,7 @@
</ItemGroup>
</Target>

<!-- Use local targeting pack for NetCoreAppCurrent. -->
<!-- Use local targeting/runtime pack for NetCoreAppCurrent. -->
<Target Name="UpdateTargetingAndRuntimePack"
Condition="'$(UseLocalTargetingRuntimePack)' == 'true'"
AfterTargets="ResolveFrameworkReferences">
Expand Down
17 changes: 11 additions & 6 deletions src/mono/wasm/build/WasmApp.InTree.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,21 @@
<!-- This depends on the root Directory.Build.targets imported this file -->
<UsingTask TaskName="MonoAOTCompiler" AssemblyFile="$(MonoAOTCompilerTasksAssemblyPath)" />

<!-- TODO: this breaks runtime tests on Helix due to the file not being there for some reason. Once this is fixed we can remove the UpdateRuntimePack target here -->
<!--<Import Project="$(RepositoryEngineeringDir)targetingpacks.targets" Condition="'$(TargetingpacksTargetsImported)' != 'true'"/>-->
<Import Project="$(MSBuildThisFileDirectory)WasmApp.targets" />

<!-- Redirect 'dotnet publish' to in-tree runtime pack -->
<Target Name="TrickRuntimePackLocation" AfterTargets="ProcessFrameworkReferences" Condition="@(RuntimePack->Count()) != 0">
<!-- Use local runtime pack -->
<Target Name="UpdateRuntimePack" AfterTargets="ResolveFrameworkReferences">
<PropertyGroup>
<_LocalMicrosoftNetCoreAppRuntimePackDir>$([MSBuild]::NormalizeDirectory($(ArtifactsBinDir), 'microsoft.netcore.app.runtime.browser-wasm', $(Configuration)))</_LocalMicrosoftNetCoreAppRuntimePackDir>
</PropertyGroup>
<ItemGroup>
<RuntimePack>
<PackageDirectory>$([MSBuild]::NormalizeDirectory($(ArtifactsBinDir), 'microsoft.netcore.app.runtime.browser-wasm', $(Configuration)))</PackageDirectory>
</RuntimePack>
<ResolvedRuntimePack PackageDirectory="$(_LocalMicrosoftNetCoreAppRuntimePackDir)"
Condition="'$(_LocalMicrosoftNetCoreAppRuntimePackDir)' != '' and
'%(ResolvedRuntimePack.FrameworkName)' == 'Microsoft.NETCore.App'" />
</ItemGroup>
<Message Text="Using RuntimePack.PackageDirectory: %(RuntimePack.PackageDirectory)" Importance="Low" />
<Message Text="Used runtime pack: %(ResolvedRuntimePack.PackageDirectory)" Importance="high" />
</Target>

<Target Name="RebuildWasmAppBuilder">
Expand Down
13 changes: 7 additions & 6 deletions src/mono/wasm/build/WasmApp.LocalBuild.targets
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<PropertyGroup>
<PublishTrimmed>true</PublishTrimmed>
<TrimMode>link</TrimMode>
<UseMonoRuntime>true</UseMonoRuntime>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' != 'Debug'">
Expand All @@ -37,14 +38,14 @@
<DebuggerSupport>false</DebuggerSupport>
</PropertyGroup>

<Target Name="UpdateTargetingAndRuntimePack" AfterTargets="ResolveFrameworkReferences" DependsOnTargets="_PrepareAndValidateWasmInputs">
<!-- Use local runtime pack -->
<Target Name="UpdateRuntimePack" AfterTargets="ResolveFrameworkReferences" DependsOnTargets="_PrepareAndValidateWasmInputs">
<ItemGroup>
<RuntimePack>
<PackageDirectory>$(MicrosoftNetCoreAppRuntimePackLocationToUse)</PackageDirectory>
</RuntimePack>
<ResolvedRuntimePack PackageDirectory="$(MicrosoftNetCoreAppRuntimePackLocationToUse)" />
<ResolvedRuntimePack PackageDirectory="$(MicrosoftNetCoreAppRuntimePackLocationToUse)"
Condition="'$(MicrosoftNetCoreAppRuntimePackLocationToUse)' != '' and
'%(ResolvedRuntimePack.FrameworkName)' == 'Microsoft.NETCore.App'" />
</ItemGroup>
<Message Text="Using Runtime pack from: %(ResolvedRuntimePack.PackageDirectory)" Importance="high" />
<Message Text="Used runtime pack: %(ResolvedRuntimePack.PackageDirectory)" Importance="high" />
</Target>

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

0 comments on commit b2a670b

Please sign in to comment.