Skip to content

Commit 8a8a1ac

Browse files
committed
Fixups
1 parent 4e57d1b commit 8a8a1ac

File tree

6 files changed

+73
-5
lines changed

6 files changed

+73
-5
lines changed

src/Components/Web.JS/dist/Release/blazor.webassembly.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Components/Web.JS/src/Platform/Mono/MonoPlatform.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,6 @@ function createEmscriptenModuleInstance(resourceLoader: WebAssemblyResourceLoade
256256
`_framework/${icuDataResourceName}`,
257257
resourceLoader.bootConfig.resources.runtime[icuDataResourceName],
258258
'globalization');
259-
} else {
260-
// Use invariant culture if the app does not carry icu data.
261-
MONO.mono_wasm_setenv("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT", "1");
262259
}
263260

264261
// Override the mechanism for fetching the main wasm file so we can connect it to our cache
@@ -288,6 +285,9 @@ function createEmscriptenModuleInstance(resourceLoader: WebAssemblyResourceLoade
288285

289286
if (icuDataResource) {
290287
loadICUData(icuDataResource);
288+
} else {
289+
// Use invariant culture if the app does not carry icu data.
290+
MONO.mono_wasm_setenv("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT", "1");
291291
}
292292

293293
// Fetch the assemblies and PDBs in the background, telling Mono to wait until they are loaded

src/Components/WebAssembly/Sdk/integrationtests/WasmBuildIntegrationTest.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,35 @@ public async Task Build_WithBlazorEnableTimeZoneSupportDisabled_DoesNotCopyTimeZ
199199
Assert.FileDoesNotExist(result, buildOutputDirectory, "wwwroot", "_framework", "dotnet.timezones.blat");
200200
}
201201

202+
[Fact]
203+
public async Task Build_WithInvariantGlobalizationEnabled_DoesNotCopyGlobalizationData()
204+
{
205+
// Arrange
206+
using var project = ProjectDirectory.Create("blazorwasm-minimal");
207+
project.AddProjectFileContent(
208+
@"
209+
<PropertyGroup>
210+
<InvariantGlobalization>true</InvariantGlobalization>
211+
</PropertyGroup>");
212+
213+
var result = await MSBuildProcessManager.DotnetMSBuild(project);
214+
215+
Assert.BuildPassed(result);
216+
217+
var buildOutputDirectory = project.BuildOutputDirectory;
218+
219+
var bootJsonPath = Path.Combine(buildOutputDirectory, "wwwroot", "_framework", "blazor.boot.json");
220+
var bootJsonData = ReadBootJsonData(result, bootJsonPath);
221+
222+
var runtime = bootJsonData.resources.runtime.Keys;
223+
Assert.Contains("dotnet.wasm", runtime);
224+
Assert.Contains("dotnet.timezones.blat", runtime);
225+
Assert.DoesNotContain("icudt.dat", runtime);
226+
227+
Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "dotnet.wasm");
228+
Assert.FileDoesNotExist(result, buildOutputDirectory, "wwwroot", "_framework", "icudt.dat");
229+
}
230+
202231
[Fact]
203232
public async Task Build_Hosted_Works()
204233
{

src/Components/WebAssembly/Sdk/integrationtests/WasmPublishIntegrationTest.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,34 @@ private static void AssertRIDPublishOuput(ProjectDirectory project, MSBuildResul
823823
assetsManifestPath: "custom-service-worker-assets.js");
824824
}
825825

826+
[Fact]
827+
public async Task Publish_WithInvariantGlobalizationEnabled_DoesNotCopyGlobalizationData()
828+
{
829+
// Arrange
830+
using var project = ProjectDirectory.Create("blazorwasm-minimal");
831+
project.AddProjectFileContent(
832+
@"
833+
<PropertyGroup>
834+
<InvariantGlobalization>true</InvariantGlobalization>
835+
</PropertyGroup>");
836+
837+
var result = await MSBuildProcessManager.DotnetMSBuild(project, "Publish");
838+
839+
Assert.BuildPassed(result);
840+
841+
var publishOutputDirectory = project.PublishOutputDirectory;
842+
843+
var bootJsonPath = Path.Combine(publishOutputDirectory, "wwwroot", "_framework", "blazor.boot.json");
844+
var bootJsonData = ReadBootJsonData(result, bootJsonPath);
845+
846+
var runtime = bootJsonData.resources.runtime.Keys;
847+
Assert.Contains("dotnet.wasm", runtime);
848+
Assert.DoesNotContain("icudt.dat", runtime);
849+
850+
Assert.FileExists(result, publishOutputDirectory, "wwwroot", "_framework", "dotnet.wasm");
851+
Assert.FileDoesNotExist(result, publishOutputDirectory, "wwwroot", "_framework", "icudt.dat");
852+
}
853+
826854
private static void AddWasmProjectContent(ProjectDirectory project, string content)
827855
{
828856
var path = Path.Combine(project.SolutionPath, "blazorwasm", "blazorwasm.csproj");

src/Components/WebAssembly/Sdk/src/targets/Microsoft.NET.Sdk.BlazorWebAssembly.Current.targets

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,11 @@ Copyright (c) .NET Foundation. All rights reserved.
123123
<!-- Clear out temporary build artifacts that the runtime packages -->
124124
<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)" Condition="'%(ReferenceCopyLocalPaths.Extension)' == '.a'" />
125125

126-
<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)" Condition="'$(BlazorEnableTimeZoneSupport)' == 'false' AND '%(ReferenceCopyLocalPaths.FileName)' == 'dotnet.timezones'" />
126+
<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)"
127+
Condition="'$(BlazorEnableTimeZoneSupport)' == 'false' AND '%(ReferenceCopyLocalPaths.FileName)%(ReferenceCopyLocalPaths.Extension)' == 'dotnet.timezones.blat'" />
128+
129+
<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)"
130+
Condition="'$(InvariantGlobalization)' == 'true' AND '%(ReferenceCopyLocalPaths.FileName)%(ReferenceCopyLocalPaths.Extension)' == 'icudt.dat'" />
127131

128132
<!--
129133
ReferenceCopyLocalPaths includes satellite assemblies from referenced projects but are inexpicably missing
@@ -432,6 +436,12 @@ Copyright (c) .NET Foundation. All rights reserved.
432436

433437
<ResolvedFileToPublish Remove="@(ResolvedFileToPublish)" Condition="'%(Extension)' == '.a'" />
434438

439+
<ResolvedFileToPublish Remove="@(ResolvedFileToPublish)"
440+
Condition="'$(BlazorEnableTimeZoneSupport)' == 'false' AND '%(ResolvedFileToPublish.FileName)%(ResolvedFileToPublish.Extension)' == 'dotnet.timezones.blat'" />
441+
442+
<ResolvedFileToPublish Remove="@(ResolvedFileToPublish)"
443+
Condition="'$(InvariantGlobalization)' == 'true' AND '%(ResolvedFileToPublish.FileName)%(ResolvedFileToPublish.Extension)' == 'icudt.dat'" />
444+
435445
<!-- Remove dotnet.js from publish output -->
436446
<ResolvedFileToPublish Remove="@(ResolvedFileToPublish)" Condition="'%(ResolvedFileToPublish.RelativePath)' == 'dotnet.js'" />
437447

src/Components/WebAssembly/Sdk/testassets/Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<RazorSdkCurrentVersionTargets>$(RepoRoot)src\Razor\Microsoft.NET.Sdk.Razor\src\build\netstandard2.0\Sdk.Razor.CurrentVersion.targets</RazorSdkCurrentVersionTargets>
2121
<RazorSdkArtifactsDirectory>$(RepoRoot)artifacts\bin\Microsoft.NET.Sdk.Razor\</RazorSdkArtifactsDirectory>
2222
<BlazorWebAssemblySdkArtifactsDirectory>$(RepoRoot)artifacts\bin\Microsoft.NET.Sdk.BlazorWebAssembly\</BlazorWebAssemblySdkArtifactsDirectory>
23+
<_BlazorWebAssemblyTargetsFile>$(RepoRoot)src\Components\WebAssembly\Sdk\src\targets\Microsoft.NET.Sdk.BlazorWebAssembly.Current.targets</_BlazorWebAssemblyTargetsFile>
2324
<BlazorWebAssemblyJSPath>$(MSBuildThisFileDirectory)blazor.webassembly.js</BlazorWebAssemblyJSPath>
2425
</PropertyGroup>
2526

0 commit comments

Comments
 (0)