2 ***********************************************************************************************
3 Microsoft.NET.Sdk.WebAssembly.targets
5 WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
6 created a backup copy. Incorrect changes to this file will make it
7 impossible to load or build your projects from the command-line or the IDE.
9 Copyright (c) .NET Foundation. All rights reserved.
10 ***********************************************************************************************
12 <Project ToolsVersion="14.0">
15 <_UseBlazorDevServer>$(RunArguments.Contains('blazor-devserver.dll').ToString().ToLower())</_UseBlazorDevServer>
17 <PropertyGroup Condition="'$(_WebAssemblyUserRunParameters)' == '' and '$(_UseBlazorDevServer)' == 'false'">
18 <RunCommand Condition="'$(DOTNET_HOST_PATH)' != '' and Exists($(DOTNET_HOST_PATH))">$(DOTNET_HOST_PATH)</RunCommand>
19 <RunCommand Condition="'$(RunCommand)' == ''">dotnet</RunCommand>
21 <WasmAppHostDir>$([MSBuild]::NormalizeDirectory($(MSBuildThisFileDirectory), '..', 'WasmAppHost'))</WasmAppHostDir>
22 <_RuntimeConfigJsonPath>$([MSBuild]::NormalizePath($(OutputPath), '$(AssemblyName).runtimeconfig.json'))</_RuntimeConfigJsonPath>
23 <RunArguments>exec "$([MSBuild]::NormalizePath($(WasmAppHostDir), 'WasmAppHost.dll'))" --use-staticwebassets --runtime-config "$(_RuntimeConfigJsonPath)" $(WasmHostArguments)</RunArguments>
24 <RunWorkingDirectory>$(OutputPath)</RunWorkingDirectory>
28 <EnableDefaultContentItems Condition=" '$(EnableDefaultContentItems)' == '' ">true</EnableDefaultContentItems>
30 <!-- Trimmer defaults that depend on user-definable settings.
31 This must be configured before it's initialized in the .NET SDK targets (which are imported by the Razor SDK). -->
32 <SuppressTrimAnalysisWarnings Condition="'$(SuppressTrimAnalysisWarnings)' == '' And '$(TrimmerDefaultAction)' != 'link'">true</SuppressTrimAnalysisWarnings>
36 Targets supporting Razor MSBuild integration. Contain support for generating C# code using Razor
37 and including the generated code in the project lifecycle, including compiling, publishing and producing
42 <!-- Paths to tools, tasks, and extensions are calculated relative to the WebAssemblySdkDirectoryRoot. This can be modified to test a local build. -->
43 <WebAssemblySdkDirectoryRoot Condition="'$(WebAssemblySdkDirectoryRoot)'==''">$(MSBuildThisFileDirectory)..\</WebAssemblySdkDirectoryRoot>
44 <_WebAssemblySdkTasksTFM Condition=" '$(MSBuildRuntimeType)' == 'Core'">net8.0</_WebAssemblySdkTasksTFM>
45 <_WebAssemblySdkTasksTFM Condition=" '$(MSBuildRuntimeType)' != 'Core'">net472</_WebAssemblySdkTasksTFM>
46 <_WebAssemblySdkTasksAssembly>$(WebAssemblySdkDirectoryRoot)tools\$(_WebAssemblySdkTasksTFM)\Microsoft.NET.Sdk.WebAssembly.Pack.Tasks.dll</_WebAssemblySdkTasksAssembly>
49 <CompressionIncludePatterns>$(CompressionIncludePatterns);_framework\**</CompressionIncludePatterns>
50 <DisableBuildCompression Condition="'$(WasmBuildingForNestedPublish)' == 'true'">true</DisableBuildCompression>
53 <UsingTask TaskName="Microsoft.NET.Sdk.WebAssembly.GenerateWasmBootJson" AssemblyFile="$(_WebAssemblySdkTasksAssembly)" />
54 <UsingTask TaskName="Microsoft.NET.Sdk.WebAssembly.ComputeWasmBuildAssets" AssemblyFile="$(_WebAssemblySdkTasksAssembly)" />
55 <UsingTask TaskName="Microsoft.NET.Sdk.WebAssembly.ComputeWasmPublishAssets" AssemblyFile="$(_WebAssemblySdkTasksAssembly)" />
56 <UsingTask TaskName="Microsoft.NET.Sdk.WebAssembly.ConvertDllsToWebCil" AssemblyFile="$(_WebAssemblySdkTasksAssembly)" />
59 <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
61 <!-- Runtime feature defaults to trim unnecessary code -->
62 <InvariantGlobalization Condition="'$(InvariantGlobalization)' == ''">false</InvariantGlobalization>
63 <InvariantTimezone Condition="'$(BlazorEnableTimeZoneSupport)' == 'false'">true</InvariantTimezone>
64 <InvariantTimezone Condition="'$(InvariantTimezone)' == ''">false</InvariantTimezone>
65 <EventSourceSupport Condition="'$(EventSourceSupport)' == ''">false</EventSourceSupport>
66 <UseSystemResourceKeys Condition="'$(UseSystemResourceKeys)' == ''">true</UseSystemResourceKeys>
67 <EnableUnsafeUTF7Encoding Condition="'$(EnableUnsafeUTF7Encoding)' == ''">false</EnableUnsafeUTF7Encoding>
68 <HttpActivityPropagationSupport Condition="'$(HttpActivityPropagationSupport)' == ''">false</HttpActivityPropagationSupport>
69 <NullabilityInfoContextSupport Condition="'$(NullabilityInfoContextSupport)' == ''">false</NullabilityInfoContextSupport>
70 <_AggressiveAttributeTrimming Condition="'$(_AggressiveAttributeTrimming)' == ''">true</_AggressiveAttributeTrimming>
71 <DebuggerSupport Condition="'$(DebuggerSupport)' == '' and '$(Configuration)' != 'Debug'">false</DebuggerSupport>
72 <BlazorCacheBootResources Condition="'$(BlazorCacheBootResources)' == ''">true</BlazorCacheBootResources>
73 <WasmFingerprintDotnetJs Condition="'$(WasmFingerprintDotnetJs)' == ''">false</WasmFingerprintDotnetJs>
75 <!-- Turn off parts of the build that do not apply to WASM projects -->
76 <GenerateDependencyFile>false</GenerateDependencyFile>
77 <PreserveCompilationContext>false</PreserveCompilationContext>
78 <PreserveCompilationReferences>false</PreserveCompilationReferences>
79 <IsWebConfigTransformDisabled>true</IsWebConfigTransformDisabled>
82 <!-- We disable the manifest generation because we are going to inline the modules in the blazor.boot.json manifest -->
83 <GenerateJSModuleManifest>false</GenerateJSModuleManifest>
85 <EnableDefaultWasmAssembliesToBundle>false</EnableDefaultWasmAssembliesToBundle>
86 <WasmNestedPublishAppDependsOn>_GatherWasmFilesToPublish;$(WasmNestedPublishAppDependsOn)</WasmNestedPublishAppDependsOn>
87 <_WasmNestedPublishAppPreTarget>ComputeFilesToPublish</_WasmNestedPublishAppPreTarget>
91 <!-- Configuration for the platform compatibility analyzer. See https://github.com/dotnet/designs/blob/main/accepted/2020/platform-exclusion/platform-exclusion.md#build-configuration-for-platforms -->
92 <SupportedPlatform Remove="@(SupportedPlatform)" />
93 <SupportedPlatform Include="browser" />
96 <!-- Wire-up static web assets -->
98 <!-- Static Web Assets -->
99 <ResolveStaticWebAssetsInputsDependsOn>
100 $(ResolveStaticWebAssetsInputsDependsOn);
101 _AddWasmStaticWebAssets;
102 </ResolveStaticWebAssetsInputsDependsOn>
103 <StaticWebAssetsPrepareForRunDependsOn>
104 _GenerateBuildWasmBootJson;
105 $(StaticWebAssetsPrepareForRunDependsOn)
106 </StaticWebAssetsPrepareForRunDependsOn>
107 <ResolvePublishStaticWebAssetsDependsOn Condition="'$(WasmBuildingForNestedPublish)' != 'true'">
108 $(ResolvePublishStaticWebAssetsDependsOn);
109 ProcessPublishFilesForWasm;
110 ComputeWasmExtensions;
111 _AddPublishWasmBootJsonToStaticWebAssets;
112 </ResolvePublishStaticWebAssetsDependsOn>
113 <GenerateStaticWebAssetsPublishManifestDependsOn Condition="'$(WasmBuildingForNestedPublish)' != 'true'">
114 $(GenerateStaticWebAssetsPublishManifestDependsOn);
115 GeneratePublishWasmBootJson;
116 </GenerateStaticWebAssetsPublishManifestDependsOn>
119 <ResolveCompressedFilesDependsOn>
120 $(ResolveCompressedFilesDependsOn);
122 _AddWasmStaticWebAssets;
123 </ResolveCompressedFilesDependsOn>
124 <ResolveCompressedFilesForPublishDependsOn>
125 $(ResolveCompressedFilesForPublishDependsOn);
126 ProcessPublishFilesForWasm;
127 ComputeWasmExtensions;
128 _AddPublishWasmBootJsonToStaticWebAssets;
129 </ResolveCompressedFilesForPublishDependsOn>
130 <CompressFilesDependsOn>
131 $(CompressFilesDependsOn)
132 _GenerateBuildWasmBootJson;
133 </CompressFilesDependsOn>
134 <CompressFilesForPublishDependsOn>
135 $(CompressFilesForPublishDependsOn);
136 GeneratePublishWasmBootJson;
137 </CompressFilesForPublishDependsOn>
140 <AddWasmStaticWebAssetsDependsOn>
141 $(AddWasmStaticWebAssetsDependsOn);
143 </AddWasmStaticWebAssetsDependsOn>
144 <GenerateBuildWasmBootJsonDependsOn>
145 $(GenerateBuildWasmBootJsonDependsOn);
146 ResolveStaticWebAssetsInputs;
147 </GenerateBuildWasmBootJsonDependsOn>
148 <GeneratePublishWasmBootJsonDependsOn>
149 $(GeneratePublishWasmBootJsonDependsOn);
150 </GeneratePublishWasmBootJsonDependsOn>
153 <Target Name="_WasmNativeForBuild" DependsOnTargets="_GatherWasmFilesToBuild;WasmBuildApp" Condition="'$(UsingBrowserRuntimeWorkload)' == 'true'" />
155 <Target Name="_GatherWasmFilesToBuild">
157 <WasmAssembliesToBundle Remove="@(WasmAssembliesToBundle)" />
158 <WasmAssembliesToBundle Include="@(IntermediateAssembly)" />
159 <WasmAssembliesToBundle Include="@(ReferenceCopyLocalPaths)" Condition="'%(ReferenceCopyLocalPaths.Extension)' == '.dll'" />
163 <Target Name="_ResolveGlobalizationConfiguration">
164 <Error Condition="'$(BlazorIcuDataFileName)' != '' AND !$([System.IO.Path]::GetFileName('$(BlazorIcuDataFileName)').StartsWith('icudt'))" Text="File name in %24(BlazorIcuDataFileName) has to start with 'icudt'." />
165 <Warning Condition="'$(InvariantGlobalization)' == 'true' AND '$(BlazorWebAssemblyLoadAllGlobalizationData)' == 'true'" Text="%24(BlazorWebAssemblyLoadAllGlobalizationData) has no effect when %24(InvariantGlobalization) is set to true." />
166 <Warning Condition="'$(HybridGlobalization)' == 'true' AND '$(BlazorWebAssemblyLoadAllGlobalizationData)' == 'true'" Text="%24(BlazorWebAssemblyLoadAllGlobalizationData) has no effect when %24(HybridGlobalization) is set to true." />
167 <Warning Condition="'$(InvariantGlobalization)' == 'true' AND '$(BlazorIcuDataFileName)' != ''" Text="%24(BlazorIcuDataFileName) has no effect when %24(InvariantGlobalization) is set to true." />
168 <Warning Condition="'$(BlazorWebAssemblyLoadAllGlobalizationData)' == 'true' AND '$(BlazorIcuDataFileName)' != ''" Text="%24(BlazorIcuDataFileName) has no effect when %24(BlazorWebAssemblyLoadAllGlobalizationData) is set to true." />
169 <Warning Condition="'$(InvariantGlobalization)' == 'true' AND '$(HybridGlobalization)' == 'true'" Text="%24(HybridGlobalization) has no effect when %24(InvariantGlobalization) is set to true." />
170 <Warning Condition="'$(BlazorIcuDataFileName)' != '' AND '$(HybridGlobalization)' == 'true'" Text="%24(HybridGlobalization) has no effect when %24(BlazorIcuDataFileName) is set." />
172 <HybridGlobalization Condition="'$(BlazorIcuDataFileName)' != ''">false</HybridGlobalization>
173 <_BlazorWebAssemblyLoadAllGlobalizationData Condition="'$(InvariantGlobalization)' != 'true' AND '$(HybridGlobalization)' != 'true'">$(BlazorWebAssemblyLoadAllGlobalizationData)</_BlazorWebAssemblyLoadAllGlobalizationData>
174 <_BlazorWebAssemblyLoadAllGlobalizationData Condition="'$(_BlazorWebAssemblyLoadAllGlobalizationData)' == ''">false</_BlazorWebAssemblyLoadAllGlobalizationData>
175 <_IsHybridGlobalization>$(HybridGlobalization)</_IsHybridGlobalization>
176 <_IsHybridGlobalization Condition="'$(InvariantGlobalization)' == 'true' OR '$(HybridGlobalization)' == ''">false</_IsHybridGlobalization>
177 <_BlazorIcuDataFileName Condition="'$(InvariantGlobalization)' != 'true' AND '$(BlazorWebAssemblyLoadAllGlobalizationData)' != 'true' AND '$(HybridGlobalization)' != 'true'">$(BlazorIcuDataFileName)</_BlazorIcuDataFileName>
178 <_LoadCustomIcuData>false</_LoadCustomIcuData>
179 <_LoadCustomIcuData Condition="'$(_BlazorIcuDataFileName)' != ''">true</_LoadCustomIcuData>
183 <Target Name="_ResolveWasmConfiguration" DependsOnTargets="_ResolveGlobalizationConfiguration">
185 <_TargetingNET80OrLater>false</_TargetingNET80OrLater>
186 <_TargetingNET80OrLater Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals('$(TargetFrameworkVersion)', '8.0'))">true</_TargetingNET80OrLater>
188 <_BlazorEnableTimeZoneSupport>$(BlazorEnableTimeZoneSupport)</_BlazorEnableTimeZoneSupport>
189 <_BlazorEnableTimeZoneSupport Condition="'$(_BlazorEnableTimeZoneSupport)' == ''">true</_BlazorEnableTimeZoneSupport>
190 <_WasmInvariantGlobalization>$(InvariantGlobalization)</_WasmInvariantGlobalization>
191 <_WasmInvariantGlobalization Condition="'$(_WasmInvariantGlobalization)' == ''">true</_WasmInvariantGlobalization>
192 <_WasmCopyOutputSymbolsToOutputDirectory>$(CopyOutputSymbolsToOutputDirectory)</_WasmCopyOutputSymbolsToOutputDirectory>
193 <_WasmCopyOutputSymbolsToOutputDirectory Condition="'$(_WasmCopyOutputSymbolsToOutputDirectory)'==''">true</_WasmCopyOutputSymbolsToOutputDirectory>
194 <_WasmEnableThreads>$(WasmEnableThreads)</_WasmEnableThreads>
195 <_WasmEnableThreads Condition="'$(_WasmEnableThreads)' == ''">false</_WasmEnableThreads>
197 <_WasmEnableWebcil>$(WasmEnableWebcil)</_WasmEnableWebcil>
198 <_WasmEnableWebcil Condition="'$(_TargetingNET80OrLater)' != 'true'">false</_WasmEnableWebcil>
199 <_WasmEnableWebcil Condition="'$(_WasmEnableWebcil)' == ''">true</_WasmEnableWebcil>
200 <_BlazorWebAssemblyStartupMemoryCache>$(BlazorWebAssemblyStartupMemoryCache)</_BlazorWebAssemblyStartupMemoryCache>
201 <_BlazorWebAssemblyJiterpreter>$(BlazorWebAssemblyJiterpreter)</_BlazorWebAssemblyJiterpreter>
202 <_BlazorWebAssemblyRuntimeOptions>$(BlazorWebAssemblyRuntimeOptions)</_BlazorWebAssemblyRuntimeOptions>
203 <_WasmDebugLevel>$(WasmDebugLevel)</_WasmDebugLevel>
204 <_WasmDebugLevel Condition="'$(_WasmDebugLevel)' == ''">0</_WasmDebugLevel>
205 <_WasmDebugLevel Condition="'$(_WasmDebugLevel)' == '0' and ('$(DebuggerSupport)' == 'true' or '$(Configuration)' == 'Debug')">-1</_WasmDebugLevel>
207 <!-- Workaround for https://github.com/dotnet/sdk/issues/12114-->
208 <PublishDir Condition="'$(AppendRuntimeIdentifierToOutputPath)' != 'true' AND '$(PublishDir)' == '$(OutputPath)$(RuntimeIdentifier)\$(PublishDirName)\'">$(OutputPath)$(PublishDirName)\</PublishDir>
212 <Target Name="ResolveWasmOutputs" DependsOnTargets="_ResolveWasmOutputs" />
214 <Target Name="_GetWasmRuntimePackVersion">
216 <_WasmRuntimePackVersion>%(ResolvedRuntimePack.NuGetPackageVersion)</_WasmRuntimePackVersion>
219 <Error Code="WASM0005" Message="Unnable to resolve WebAssembly runtime pack version" Condition="'$(_WasmRuntimePackVersion)' == ''" />
222 <Target Name="_ResolveWasmOutputs" DependsOnTargets="ResolveReferences;PrepareResourceNames;ComputeIntermediateSatelliteAssemblies;_ResolveWasmConfiguration;_WasmNativeForBuild;_GetWasmRuntimePackVersion">
224 <_WasmConfigFileCandidates Include="@(StaticWebAsset)" Condition="'%(SourceType)' == 'Discovered'" />
226 <!-- Remove dotnet.js/wasm from runtime pack, in favor of the relinked ones in @(WasmNativeAsset) -->
227 <ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)"
228 Condition="@(WasmNativeAsset->Count()) > 0 and ( '%(FileName)' == 'dotnet' or '%(FileName)' == 'dotnet.native' ) and ('%(Extension)' == '.wasm' or '%(Extension)' == '.js')" />
232 <_WasmEmitSourceMapBuild>$(WasmEmitSourceMap)</_WasmEmitSourceMapBuild>
233 <_WasmEmitSourceMapBuild Condition="'$(_WasmEmitSourceMapBuild)' == ''">true</_WasmEmitSourceMapBuild>
236 <ComputeWasmBuildAssets
237 Candidates="@(ReferenceCopyLocalPaths->Distinct());@(WasmNativeAsset)"
238 CustomIcuCandidate="$(_BlazorIcuDataFileName)"
239 ProjectAssembly="@(IntermediateAssembly)"
240 ProjectDebugSymbols="@(_DebugSymbolsIntermediatePath)"
241 SatelliteAssemblies="@(ReferenceSatellitePaths)"
242 ProjectSatelliteAssemblies="@(IntermediateSatelliteAssembliesWithTargetPath)"
243 TimeZoneSupport="$(_BlazorEnableTimeZoneSupport)"
244 InvariantGlobalization="$(_WasmInvariantGlobalization)"
245 HybridGlobalization="$(_IsHybridGlobalization)"
246 LoadFullICUData="$(_BlazorWebAssemblyLoadAllGlobalizationData)"
247 DotNetJsVersion="$(_WasmRuntimePackVersion)"
248 CopySymbols="$(_WasmCopyOutputSymbolsToOutputDirectory)"
249 OutputPath="$(OutputPath)"
250 FingerprintDotNetJs="$(WasmFingerprintDotnetJs)"
251 EnableThreads="$(_WasmEnableThreads)"
252 EmitSourceMap="$(_WasmEmitSourceMapBuild)"
254 <Output TaskParameter="AssetCandidates" ItemName="_BuildAssetsCandidates" />
255 <Output TaskParameter="FilesToRemove" ItemName="_WasmBuildFilesToRemove" />
256 </ComputeWasmBuildAssets>
259 <_WasmBuildWebCilPath>$([MSBuild]::NormalizeDirectory($(IntermediateOutputPath), 'webcil'))</_WasmBuildWebCilPath>
260 <_WasmBuildTmpWebCilPath>$([MSBuild]::NormalizeDirectory($(IntermediateOutputPath), 'tmp-webcil'))</_WasmBuildTmpWebCilPath>
263 <ConvertDllsToWebCil Candidates="@(_BuildAssetsCandidates)" IntermediateOutputPath="$(_WasmBuildTmpWebCilPath)" OutputPath="$(_WasmBuildWebCilPath)" IsEnabled="$(_WasmEnableWebcil)">
264 <Output TaskParameter="WebCilCandidates" ItemName="_WebCilAssetsCandidates" />
265 <Output TaskParameter="FileWrites" ItemName="FileWrites" />
266 </ConvertDllsToWebCil>
268 <DefineStaticWebAssets
269 CandidateAssets="@(_WebCilAssetsCandidates)"
270 SourceId="$(PackageId)"
271 SourceType="Computed"
274 CopyToOutputDirectory="PreserveNewest"
275 CopyToPublishDirectory="Never"
276 ContentRoot="$(OutputPath)wwwroot"
277 BasePath="$(StaticWebAssetBasePath)"
279 <Output TaskParameter="Assets" ItemName="WasmStaticWebAsset" />
280 </DefineStaticWebAssets>
282 <DefineStaticWebAssets
283 CandidateAssets="@(_WasmConfigFileCandidates)"
284 AssetTraitName="WasmResource"
285 AssetTraitValue="settings"
286 RelativePathFilter="appsettings*.json"
288 <Output TaskParameter="Assets" ItemName="_WasmJsConfigStaticWebAsset" />
289 </DefineStaticWebAssets>
292 <!-- Update the boot config static web asset since we've given it a trait -->
293 <StaticWebAsset Remove="@(_WasmJsConfigStaticWebAsset)" />
294 <StaticWebAsset Include="@(_WasmJsConfigStaticWebAsset)" />
296 <ReferenceCopyLocalPaths Remove="@(_WasmBuildFilesToRemove)" />
300 <_WasmBuildBootJsonPath>$(IntermediateOutputPath)blazor.boot.json</_WasmBuildBootJsonPath>
305 Include="$(_WasmBuildBootJsonPath)"
306 RelativePath="_framework/blazor.boot.json" />
309 <DefineStaticWebAssets
310 CandidateAssets="@(_BuildWasmBootJson)"
311 SourceId="$(PackageId)"
312 SourceType="Computed"
315 AssetTraitName="WasmResource"
316 AssetTraitValue="manifest"
317 CopyToOutputDirectory="PreserveNewest"
318 CopyToPublishDirectory="Never"
319 ContentRoot="$(OutDir)wwwroot"
320 BasePath="$(StaticWebAssetBasePath)"
322 <Output TaskParameter="Assets" ItemName="_BuildWasmBootJsonStaticWebAsset" />
323 </DefineStaticWebAssets>
326 <Target Name="_AddWasmStaticWebAssets" DependsOnTargets="$(AddWasmStaticWebAssetsDependsOn)">
328 <StaticWebAsset Include="@(WasmStaticWebAsset)" />
329 <StaticWebAsset Include="@(_BuildWasmBootJsonStaticWebAsset)" />
333 <Target Name="_GenerateBuildWasmBootJson" DependsOnTargets="$(GenerateBuildWasmBootJsonDependsOn)">
335 <_WasmBuildBootJsonPath>$(IntermediateOutputPath)blazor.boot.json</_WasmBuildBootJsonPath>
339 <_WasmJsModuleCandidatesForBuild
340 Include="@(StaticWebAsset)"
341 Condition="'%(StaticWebAsset.AssetTraitName)' == 'JSModule' and '%(StaticWebAsset.AssetTraitValue)' == 'JSLibraryModule' and '%(AssetKind)' != 'Publish'" />
344 <GetFileHash Files="@(WasmStaticWebAsset->'%(OriginalItemSpec)')" Algorithm="SHA256" HashEncoding="base64">
345 <Output TaskParameter="Items" ItemName="_WasmOutputWithHash" />
348 <ComputeStaticWebAssetsTargetPaths
349 Assets="@(_WasmJsModuleCandidatesForBuild)"
351 UseAlternatePathDirectorySeparator="true"
353 <Output TaskParameter="AssetsWithTargetPath" ItemName="_WasmJsModuleCandidatesForBuildWithTargetPath" />
354 </ComputeStaticWebAssetsTargetPaths>
356 <GetFileHash Files="@(_WasmJsModuleCandidatesForBuildWithTargetPath)" Algorithm="SHA256" HashEncoding="base64">
357 <Output TaskParameter="Items" ItemName="_WasmOutputWithHash" />
360 <GenerateWasmBootJson
361 AssemblyPath="@(IntermediateAssembly)"
362 Resources="@(_WasmOutputWithHash)"
364 DebugLevel="$(_WasmDebugLevel)"
365 LinkerEnabled="false"
366 CacheBootResources="$(BlazorCacheBootResources)"
367 OutputPath="$(_WasmBuildBootJsonPath)"
368 ConfigurationFiles="@(_WasmJsConfigStaticWebAsset)"
369 LazyLoadedAssemblies="@(BlazorWebAssemblyLazyLoad)"
370 InvariantGlobalization="$(InvariantGlobalization)"
371 LoadCustomIcuData="$(_LoadCustomIcuData)"
372 IsHybridGlobalization="$(_IsHybridGlobalization)"
373 LoadFullICUData="$(_BlazorWebAssemblyLoadAllGlobalizationData)"
374 StartupMemoryCache="$(_BlazorWebAssemblyStartupMemoryCache)"
375 Jiterpreter="$(_BlazorWebAssemblyJiterpreter)"
376 RuntimeOptions="$(_BlazorWebAssemblyRuntimeOptions)"
377 Extensions="@(WasmBootConfigExtension)"
378 TargetFrameworkVersion="$(TargetFrameworkVersion)"
379 ModuleAfterConfigLoaded="@(WasmModuleAfterConfigLoaded)"
380 ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)" />
383 <FileWrites Include="$(_WasmBuildBootJsonPath)" />
387 <!-- Publish starts here -->
389 <!-- Make sure that ResolveAssemblyReferences runs early enough to ensure satellite assemblies are populated in the ResolvedFilesToPublish -->
390 <Target Name="_WasmPrepareForPublish"
391 DependsOnTargets="PrepareResourceNames;ComputeIntermediateSatelliteAssemblies;ResolveAssemblyReferences"
392 BeforeTargets="PrepareForPublish" />
394 <!-- Wasm's Nested publish is run just to build the native bits. We don't need to run blazor targets for that -->
395 <Target Name="ProcessPublishFilesForWasm" DependsOnTargets="_ResolveWasmConfiguration;LoadStaticWebAssetsBuildManifest;_GetWasmRuntimePackVersion" AfterTargets="ILLink" Condition="'$(WasmBuildingForNestedPublish)' != 'true'">
396 <!-- The list of static web assets already contains all the assets from the build. We want to correct certain assets that might
397 have changed as part of the publish process. We are going to do so as follows:
398 * We will update Blazor runtime asset dlls if we are running PublishTrimmed
399 * We will update Blazor native runtime resources if we are using Aot
400 Other than that, we'll filter the unwanted assets from the list of resolved files to publish in the same way we did during the build.
404 <_WasmPublishPrefilteredAssets
405 Include="@(StaticWebAsset)"
406 Condition="'%(StaticWebAsset.AssetTraitName)' == 'WasmResource' or '%(StaticWebAsset.AssetTraitName)' == 'Culture' or '%(AssetRole)' == 'Alternative'" />
410 <_WasmEmitSourceMapPublish>$(WasmEmitSourceMap)</_WasmEmitSourceMapPublish>
411 <_WasmEmitSourceMapPublish Condition="'$(_WasmEmitSourceMapPublish)' == ''">false</_WasmEmitSourceMapPublish>
414 <ComputeWasmPublishAssets
415 ResolvedFilesToPublish="@(ResolvedFileToPublish)"
416 CustomIcuCandidate="$(_BlazorIcuDataFileName)"
417 TimeZoneSupport="$(_BlazorEnableTimeZoneSupport)"
418 PublishPath="$(PublishDir)"
419 WasmAotAssets="@(WasmNativeAsset)"
420 InvariantGlobalization="$(_WasmInvariantGlobalization)"
421 HybridGlobalization="$(_IsHybridGlobalization)"
422 LoadFullICUData="$(_BlazorWebAssemblyLoadAllGlobalizationData)"
423 CopySymbols="$(CopyOutputSymbolsToPublishDirectory)"
424 ExistingAssets="@(_WasmPublishPrefilteredAssets)"
425 DotNetJsVersion="$(_WasmRuntimePackVersion)"
426 FingerprintDotNetJs="$(WasmFingerprintDotnetJs)"
427 EnableThreads="$(_WasmEnableThreads)"
428 EmitSourceMap="$(_WasmEmitSourceMapPublish)"
429 IsWebCilEnabled="$(_WasmEnableWebcil)"
431 <Output TaskParameter="NewCandidates" ItemName="_NewWasmPublishStaticWebAssets" />
432 <Output TaskParameter="FilesToRemove" ItemName="_PublishResolvedFilesToRemove" />
433 </ComputeWasmPublishAssets>
436 <_WasmPublishWebCilPath>$([MSBuild]::NormalizeDirectory($(IntermediateOutputPath), 'webcil', 'publish'))</_WasmPublishWebCilPath>
437 <_WasmPublishTmpWebCilPath>$([MSBuild]::NormalizeDirectory($(IntermediateOutputPath), 'tmp-webcil', 'publish'))</_WasmPublishTmpWebCilPath>
440 <ConvertDllsToWebCil Candidates="@(_NewWasmPublishStaticWebAssets)" IntermediateOutputPath="$(_WasmPublishTmpWebCilPath)" OutputPath="$(_WasmPublishWebCilPath)" IsEnabled="$(_WasmEnableWebcil)">
441 <Output TaskParameter="WebCilCandidates" ItemName="_NewWebCilPublishStaticWebAssets" />
442 <Output TaskParameter="FileWrites" ItemName="FileWrites" />
443 </ConvertDllsToWebCil>
446 <ResolvedFileToPublish Remove="@(_PublishResolvedFilesToRemove)" />
447 <StaticWebAsset Include="@(_NewWebCilPublishStaticWebAssets)" />
449 <!-- TODO: Probably doesn't do anything as of now, original https://github.com/dotnet/aspnetcore/pull/34798 -->
450 <PublishBlazorBootStaticWebAsset
451 Include="@(StaticWebAsset)"
452 Condition="'%(AssetKind)' != 'Build' and
453 (('%(StaticWebAsset.AssetTraitName)' == 'WasmResource' and '%(StaticWebAsset.AssetTraitValue)' != 'manifest' and '%(StaticWebAsset.AssetTraitValue)' != 'boot') or
454 '%(StaticWebAsset.AssetTraitName)' == 'Culture')" />
459 Name="ComputeWasmExtensions"
460 AfterTargets="ProcessPublishFilesForWasm"
461 DependsOnTargets="$(ComputeBlazorExtensionsDependsOn)" >
463 <_BlazorExtensionsCandidate Include="@(BlazorPublishExtension->'%(FullPath)')">
464 <SourceId>$(PackageId)</SourceId>
465 <SourceType>Computed</SourceType>
466 <ContentRoot>$(PublishDir)wwwroot</ContentRoot>
467 <BasePath>$(StaticWebAssetBasePath)</BasePath>
468 <RelativePath>%(BlazorPublishExtension.RelativePath)</RelativePath>
469 <AssetKind>Publish</AssetKind>
470 <AssetMode>All</AssetMode>
471 <AssetRole>Primary</AssetRole>
472 <AssetTraitName>WasmResource</AssetTraitName>
473 <AssetTraitValue>extension:%(BlazorPublishExtension.ExtensionName)</AssetTraitValue>
474 <CopyToOutputDirectory>Never</CopyToOutputDirectory>
475 <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
476 <OriginalItemSpec>%(BlazorPublishExtension.Identity)</OriginalItemSpec>
477 </_BlazorExtensionsCandidate>
480 <DefineStaticWebAssets CandidateAssets="@(_BlazorExtensionsCandidate)">
481 <Output TaskParameter="Assets" ItemName="StaticWebAsset" />
482 <Output TaskParameter="Assets" ItemName="_BlazorExtensionsCandidatesForPublish" />
483 <Output TaskParameter="Assets" ItemName="AssetToCompress" />
484 </DefineStaticWebAssets>
487 <Target Name="_AddWasmWebConfigFile" AfterTargets="ILLink">
488 <ItemGroup Condition="'@(ResolvedFileToPublish->AnyHaveMetadataValue('RelativePath', 'web.config'))' != 'true'">
489 <ResolvedFileToPublish
490 Include="$(MSBuildThisFileDirectory)Wasm.web.config"
491 ExcludeFromSingleFile="true"
492 CopyToPublishDirectory="PreserveNewest"
493 RelativePath="web.config" />
497 <Target Name="_AddPublishWasmBootJsonToStaticWebAssets">
499 <_PublishWasmBootJson
500 Include="$(IntermediateOutputPath)blazor.publish.boot.json"
501 RelativePath="_framework/blazor.boot.json" />
504 <DefineStaticWebAssets
505 CandidateAssets="@(_PublishWasmBootJson)"
506 SourceId="$(PackageId)"
507 SourceType="Computed"
510 AssetTraitName="WasmResource"
511 AssetTraitValue="manifest"
512 CopyToOutputDirectory="Never"
513 CopyToPublishDirectory="PreserveNewest"
514 ContentRoot="$(PublishDir)wwwroot"
515 BasePath="$(StaticWebAssetBasePath)"
517 <Output TaskParameter="Assets" ItemName="StaticWebAsset" />
518 </DefineStaticWebAssets>
521 <Target Name="GeneratePublishWasmBootJson" DependsOnTargets="$(GeneratePublishWasmBootJsonDependsOn)">
525 Include="@(StaticWebAsset)"
526 Condition="'%(AssetKind)' != 'Build' and '%(StaticWebAsset.AssetTraitValue)' != 'manifest' and ('%(StaticWebAsset.AssetTraitName)' == 'WasmResource' or '%(StaticWebAsset.AssetTraitName)' == 'Culture') and '%(StaticWebAsset.AssetTraitValue)' != 'boot'" />
528 <_WasmPublishConfigFile
529 Include="@(StaticWebAsset)"
530 Condition="'%(StaticWebAsset.AssetTraitName)' == 'WasmResource' and '%(StaticWebAsset.AssetTraitValue)' == 'settings'"/>
532 <_WasmJsModuleCandidatesForPublish
533 Include="@(StaticWebAsset)"
534 Condition="'%(StaticWebAsset.AssetTraitName)' == 'JSModule' and '%(StaticWebAsset.AssetTraitValue)' == 'JSLibraryModule' and '%(AssetKind)' != 'Build'" />
536 <!-- We remove the extensions since they are added to the list of static web assets but we need to compute the target path for them -->
537 <_WasmPublishAsset Remove="@(_BlazorExtensionsCandidatesForPublish)" />
541 <ComputeStaticWebAssetsTargetPaths
542 Assets="@(_WasmJsModuleCandidatesForPublish);@(_BlazorExtensionsCandidatesForPublish)"
544 UseAlternatePathDirectorySeparator="true"
546 <Output TaskParameter="AssetsWithTargetPath" ItemName="_WasmCandidatesForPublishWithTargetPath" />
547 </ComputeStaticWebAssetsTargetPaths>
549 <GetFileHash Files="@(_WasmPublishAsset);@(_WasmCandidatesForPublishWithTargetPath)" Algorithm="SHA256" HashEncoding="base64">
550 <Output TaskParameter="Items" ItemName="_WasmPublishBootResourceWithHash" />
553 <GenerateWasmBootJson
554 AssemblyPath="@(IntermediateAssembly)"
555 Resources="@(_WasmPublishBootResourceWithHash)"
557 DebugLevel="$(_WasmDebugLevel)"
558 LinkerEnabled="$(PublishTrimmed)"
559 CacheBootResources="$(BlazorCacheBootResources)"
560 OutputPath="$(IntermediateOutputPath)blazor.publish.boot.json"
561 ConfigurationFiles="@(_WasmPublishConfigFile)"
562 LazyLoadedAssemblies="@(BlazorWebAssemblyLazyLoad)"
563 InvariantGlobalization="$(InvariantGlobalization)"
564 LoadCustomIcuData="$(_LoadCustomIcuData)"
565 IsHybridGlobalization="$(_IsHybridGlobalization)"
566 LoadFullICUData="$(_BlazorWebAssemblyLoadAllGlobalizationData)"
567 StartupMemoryCache="$(_BlazorWebAssemblyStartupMemoryCache)"
568 Jiterpreter="$(_BlazorWebAssemblyJiterpreter)"
569 RuntimeOptions="$(_BlazorWebAssemblyRuntimeOptions)"
570 Extensions="@(WasmBootConfigExtension)"
571 TargetFrameworkVersion="$(TargetFrameworkVersion)"
572 ModuleAfterConfigLoaded="@(WasmModuleAfterConfigLoaded)"
573 ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)" />
576 <FileWrites Include="$(IntermediateOutputPath)blazor.publish.boot.json" />
581 <Target Name="_WasmNative"
582 DependsOnTargets="_EnsureWasmRuntimeWorkload;WasmTriggerPublishApp"
583 BeforeTargets="ProcessPublishFilesForWasm"
584 Condition="'$(UsingBrowserRuntimeWorkload)' == 'true'" />
586 <Target Name="_EnsureWasmRuntimeWorkload" Condition="'$(UsingBlazorAOTWorkloadManifest)' != 'true'">
588 Text="Publishing with AOT enabled requires the .NET WebAssembly AOT workload to be installed. To learn more, visit https://aka.ms/AAb4uzl."
589 Code="BLAZORSDK1002" />
592 <Target Name="_GatherWasmFilesToPublish">
594 <WasmAssembliesToBundle Remove="@(WasmAssembliesToBundle)" />
595 <WasmAssembliesToBundle Include="%(ResolvedFileToPublish.FullPath)" Exclude="@(_Exclude)" Condition="%(Extension) == '.dll'" />