Skip to content

Commit

Permalink
Update BlazorWebAssembly targets to work with updated wasm targets
Browse files Browse the repository at this point in the history
[This PR](dotnet/runtime#57556) adds support for
relinking the native wasm files during the build (instead of only during
publish).

This required changes to the targets available, and how they can be
used, and thus require changes in the blazor targets to work with that.

The new setup is explained in
https://github.com/radical/runtime/blob/wasm-build/src/mono/wasm/build/README.md .

Forward ports the changes from release/6.0.1xx
  • Loading branch information
radical committed Sep 15, 2021
1 parent 15a28ec commit 6325a67
Showing 1 changed file with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ Copyright (c) .NET Foundation. All rights reserved.
<!-- We disable the manifest generation because we are going to inline the modules in the blazor.boot.json manifest -->
<GenerateJSModuleManifest>false</GenerateJSModuleManifest>

<DisableAutoWasmBuildApp>true</DisableAutoWasmBuildApp>
<DisableAutoWasmPublishApp>true</DisableAutoWasmPublishApp>
<EnableDefaultWasmAssembliesToBundle>false</EnableDefaultWasmAssembliesToBundle>
<WasmNestedPublishAppDependsOn>ComputeFilesToPublish;_GatherWasmFilesToPublish;$(WasmNestedPublishAppDependsOn)</WasmNestedPublishAppDependsOn>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -105,6 +109,16 @@ Copyright (c) .NET Foundation. All rights reserved.

<Import Project="Microsoft.NET.Sdk.BlazorWebAssembly.ServiceWorkerAssetsManifest.targets" Condition="'$(ServiceWorkerAssetsManifest)' != ''" />

<Target Name="_BlazorWasmNativeForBuild" DependsOnTargets="_GatherWasmFilesToBuild;WasmBuildApp" Condition="'$(UsingBrowserRuntimeWorkload)' == 'true'" />

<Target Name="_GatherWasmFilesToBuild">
<ItemGroup>
<WasmAssembliesToBundle Remove="@(WasmAssembliesToBundle)" />
<WasmAssembliesToBundle Include="@(ReferenceCopyLocalPaths);@(MainAssembly)" Condition="'%(ReferenceCopyLocalPaths.Extension)' == '.dll'" />
<WasmAssembliesToBundle Condition="'%(WasmAssembliesToBundle.FileName)' == 'Microsoft.JSInterop.WebAssembly'" AOT_InternalForceToInterpret="true" />
</ItemGroup>
</Target>

<Target Name="_ResolveBlazorWasmConfiguration">
<PropertyGroup>
<_BlazorEnableTimeZoneSupport>$(BlazorEnableTimeZoneSupport)</_BlazorEnableTimeZoneSupport>
Expand All @@ -121,7 +135,7 @@ Copyright (c) .NET Foundation. All rights reserved.
</PropertyGroup>
</Target>

<Target Name="_ResolveBlazorWasmOutputs" DependsOnTargets="ResolveReferences;PrepareResourceNames;ComputeIntermediateSatelliteAssemblies;_ResolveBlazorWasmConfiguration" BeforeTargets="_RazorPrepareForRun">
<Target Name="_ResolveBlazorWasmOutputs" DependsOnTargets="ResolveReferences;PrepareResourceNames;ComputeIntermediateSatelliteAssemblies;_ResolveBlazorWasmConfiguration;_BlazorWasmNativeForBuild" BeforeTargets="_RazorPrepareForRun">
<ItemGroup>
<_BlazorJSFile Include="$(BlazorWebAssemblyJSPath)" />
<_BlazorJSFile Include="$(BlazorWebAssemblyJSMapPath)" Condition="Exists('$(BlazorWebAssemblyJSMapPath)')" />
Expand All @@ -137,10 +151,13 @@ Copyright (c) .NET Foundation. All rights reserved.

<_BlazorConfigFileCandidates Include="@(StaticWebAsset)" Condition="'%(SourceType)' == 'Discovered'" />

<!-- Remove dotnet.js/wasm from runtime pack, in favor of the relinked ones in @(WasmNativeAsset) -->
<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)"
Condition="@(WasmNativeAsset->Count()) > 0 and '%(FileName)' == 'dotnet' and ('%(Extension)' == '.wasm' or '%(Extension)' == '.js')" />
</ItemGroup>

<ComputeBlazorBuildAssets
Candidates="@(ReferenceCopyLocalPaths)"
Candidates="@(ReferenceCopyLocalPaths);@(WasmNativeAsset)"
ProjectAssembly="@(IntermediateAssembly)"
ProjectDebugSymbols="@(_DebugSymbolsIntermediatePath)"
SatelliteAssemblies="@(ReferenceSatellitePaths)"
Expand Down Expand Up @@ -361,7 +378,8 @@ Copyright (c) .NET Foundation. All rights reserved.
</ItemGroup>
</Target>

<Target Name="ProcessPublishFilesForBlazor" DependsOnTargets="_ResolveBlazorWasmConfiguration;LoadStaticWebAssetsBuildManifest" AfterTargets="ILLink">
<!-- Wasm's Nested publish is run just to build the native bits. We don't need to run blazor targets for that -->
<Target Name="ProcessPublishFilesForBlazor" DependsOnTargets="_ResolveBlazorWasmConfiguration;LoadStaticWebAssetsBuildManifest" AfterTargets="ILLink" Condition="'$(WasmBuildingForNestedPublish)' != 'true'">
<PropertyGroup>
<_BlazorAotEnabled>$(UsingBrowserRuntimeWorkload)</_BlazorAotEnabled>
<_BlazorAotEnabled Condition="'$(_BlazorAotEnabled)' == ''">false</_BlazorAotEnabled>
Expand Down Expand Up @@ -521,7 +539,7 @@ Copyright (c) .NET Foundation. All rights reserved.
</Target>

<Target Name="_BlazorWasmNative"
DependsOnTargets="_EnsureWasmRuntimeWorkload;_GatherWasmFilesToBuild;WasmBuildApp"
DependsOnTargets="_EnsureWasmRuntimeWorkload;WasmTriggerPublishApp"
BeforeTargets="ProcessPublishFilesForBlazor"
Condition="'$(UsingBrowserRuntimeWorkload)' == 'true'" />

Expand All @@ -531,9 +549,11 @@ Copyright (c) .NET Foundation. All rights reserved.
Code="BLAZORSDK1002" />
</Target>

<Target Name="_GatherWasmFilesToBuild">
<Target Name="_GatherWasmFilesToPublish">
<ItemGroup>
<WasmAssembliesToBundle Include="%(ResolvedFileToPublish.FullPath)" Exclude="@(_Exclude)" Condition="%(Extension) == '.dll' AND %(FileName) != 'Microsoft.JSInterop.WebAssembly'" />
<WasmAssembliesToBundle Remove="@(WasmAssembliesToBundle)" />
<WasmAssembliesToBundle Include="%(ResolvedFileToPublish.FullPath)" Exclude="@(_Exclude)" Condition="%(Extension) == '.dll'" />
<WasmAssembliesToBundle Condition="'%(WasmAssembliesToBundle.FileName)' == 'Microsoft.JSInterop.WebAssembly'" AOT_InternalForceToInterpret="true" />
</ItemGroup>
</Target>

Expand Down

0 comments on commit 6325a67

Please sign in to comment.