Skip to content

Commit

Permalink
Improve resolving runtime pack in WasmApp targets
Browse files Browse the repository at this point in the history
Import targetingpacks.targets in WasmApp.InTree.targets and use similar logic in WasmApp.LocalBuild.targets.
  • Loading branch information
akoeplinger committed Jul 8, 2021
1 parent 5f689e2 commit 38bf9b4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 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
11 changes: 3 additions & 8 deletions src/mono/wasm/build/WasmApp.InTree.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@
<!-- This depends on the root Directory.Build.targets imported this file -->
<UsingTask TaskName="MonoAOTCompiler" AssemblyFile="$(MonoAOTCompilerTasksAssemblyPath)" />

<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">
<ItemGroup>
<RuntimePack>
<PackageDirectory>$([MSBuild]::NormalizeDirectory($(ArtifactsBinDir), 'microsoft.netcore.app.runtime.browser-wasm', $(Configuration)))</PackageDirectory>
</RuntimePack>
</ItemGroup>
<Message Text="Using RuntimePack.PackageDirectory: %(RuntimePack.PackageDirectory)" Importance="Low" />
<Target Name="PrintRuntimePackLocation" AfterTargets="UpdateTargetingAndRuntimePack">
<Message Text="Used runtime pack: %(ResolvedRuntimePack.PackageDirectory)" Importance="high" />
</Target>

<Target Name="RebuildWasmAppBuilder">
Expand Down
14 changes: 8 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,15 @@
<DebuggerSupport>false</DebuggerSupport>
</PropertyGroup>

<Target Name="UpdateTargetingAndRuntimePack" AfterTargets="ResolveFrameworkReferences" DependsOnTargets="_PrepareAndValidateWasmInputs">
<!-- Use local runtime pack -->
<Target Name="UpdateRuntimePack" AfterTargets="ResolveFrameworkReferences" DependsOnTargets="_PrepareAndValidateWasmInputs">
<Error Condition="@(ResolvedRuntimePack->Count()) == 0" Text="No runtime pack was resolved!" />
<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 38bf9b4

Please sign in to comment.