Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[browser] Use StaticWebAssets fingerprinting in Wasm SDK #103755

Merged
merged 63 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from 60 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
5485ef0
Build and publish integration
maraf Jun 20, 2024
2c0d21f
Make fingerpring work at runtime for assemblies
maraf Jun 20, 2024
da8f2ec
Make fingerpring work at runtime for icu
maraf Jun 20, 2024
a923583
Remove version fingerprint check
maraf Jun 20, 2024
00695e7
Check core assembly extension
maraf Jun 20, 2024
7eb15d6
Merge branch 'main' into BrowserFingerprinting
lewing Jun 21, 2024
de7ab09
Typescript nits
maraf Jun 21, 2024
99d9b6a
JSModules and SatelliteAssemblies
maraf Jun 21, 2024
163fe82
DEBUG require newer SDK for testing
maraf Jun 21, 2024
bfbb518
Fix fingerprint for new publish assets
maraf Jun 21, 2024
574d899
Lazy loading and FP mapping boot json
maraf Jun 21, 2024
a650967
Merge branch 'main' into BrowserFingerprinting
maraf Jul 9, 2024
8848871
WBT file on disk checks
maraf Jul 9, 2024
e40c14e
WBT file on disk checks
maraf Jul 9, 2024
fd8b240
WBT file on disk checks
maraf Jul 9, 2024
d642b3c
WBT testmain no fingerprint
maraf Jul 10, 2024
4d3c657
WBT revert debug message
maraf Jul 11, 2024
a2eac11
AOT
maraf Jul 11, 2024
5cbda67
WBT fix ordering
maraf Jul 11, 2024
71f7fa3
Fingerprinting without webcil
maraf Jul 11, 2024
f25f7de
Fix GenerateWasmBootJson when FP is off
maraf Jul 11, 2024
b2e1ffa
NoFingerprint WBT variant
maraf Jul 11, 2024
a411302
DEBUG try to run WBT without fingerprinting
maraf Jul 12, 2024
fd55a18
WBT make entry comparison order agnostic
maraf Jul 12, 2024
1e88e55
WBT smoke tests for no-fingerprinting
maraf Jul 12, 2024
a3fd46a
Update sendtohelix-browser.targets
maraf Jul 12, 2024
5f662b2
Remove debug log
maraf Jul 12, 2024
1cd4de4
Fix typo
maraf Jul 16, 2024
754b5f2
Fix regex matching
maraf Jul 16, 2024
1c11007
Remove test for dotnet.js FP since we don't support that anymore
maraf Jul 16, 2024
d3a8ba1
Fix check for System.Private.CoreLib
maraf Jul 16, 2024
653643a
FP for dotnet.globalization.js
maraf Jul 16, 2024
90de8b7
Fingerprinting pdbs
maraf Jul 16, 2024
2637a00
Merge remote-tracking branch 'upstream/main' into BrowserFingerprinting
maraf Jul 16, 2024
57f1c0f
WBT fix file check
maraf Jul 16, 2024
1f880a4
Fingerprint segmentation-rules.json
maraf Jul 17, 2024
08e443a
Fix loading pdb for fingerprinted lazy assembly
maraf Jul 17, 2024
12bb74c
Ensure lazy pdb is loaded
maraf Jul 18, 2024
2b8ccb1
Remove non-WasmSDK tests from non-FP category
maraf Jul 18, 2024
51cd688
Revert drop for dotnet.js finterprinting
maraf Jul 18, 2024
a531dc8
Compute non-Fingerprinted virtualPath for pdb and resource as well
maraf Jul 18, 2024
31d1a73
Make debugger working with fingerprinted assemblies and pdbs
maraf Jul 18, 2024
dc91e20
DEBUG latest SDK for WBT
maraf Jul 18, 2024
c0d3d62
DEBUG fix wbt installation
maraf Jul 18, 2024
907ce2c
Add WorkloadBuildTasks to WasmBuild.sln
maraf Jul 18, 2024
e367713
Fix WBT
maraf Jul 19, 2024
4738dac
Merge branch 'main' into BrowserFingerprinting
maraf Jul 19, 2024
b78497f
Revert escaping URL in debugger
maraf Jul 19, 2024
7ff25a5
Merge branch 'main' into BrowserFingerprinting
maraf Jul 19, 2024
768af43
Fix lazy loading test and message emit in release config
maraf Jul 19, 2024
0e705fa
Fixes for MT after merge
maraf Jul 19, 2024
5db6c0e
Skip WBT without workloads and without fingerprinting
maraf Jul 19, 2024
79283fb
Merge branch 'main' into BrowserFingerprinting
lewing Jul 21, 2024
46cb7b3
Turn off fingerprinting when targeting downlevel versions
maraf Jul 22, 2024
dc1f048
Merge remote-tracking branch 'upstream/main' into BrowserFingerprinting
maraf Jul 22, 2024
c8a645c
Git ignore *.d.ts.sha256
maraf Jul 22, 2024
d076290
Fix
maraf Jul 22, 2024
bef50ee
Update source-build-reference-packages to latest
lewing Jul 22, 2024
05a3854
Revert "Update source-build-reference-packages to latest"
lewing Jul 23, 2024
f673b26
Fix the references
lewing Jul 23, 2024
ac0a52d
Update Versions.props
lewing Jul 23, 2024
5d8917a
Update Versions.props
lewing Jul 23, 2024
3e0efe6
Merge branch 'main' into BrowserFingerprinting
maraf Jul 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -386,14 +386,14 @@
<Sha>cada394f99c521861c39e2a5334678e6aba1ac62</Sha>
<SourceBuild RepoName="roslyn" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.DotNet.ApiCompat.Task" Version="9.0.100-preview.7.24358.3">
<Dependency Name="Microsoft.DotNet.ApiCompat.Task" Version="9.0.100-preview.7.24371.4">
<Uri>https://github.com/dotnet/sdk</Uri>
<Sha>5e03abbcf74bdef38ca67f04fbd4982e333d1f58</Sha>
<Sha>29904b25a99c8984bacb86473df7d98735fb3207</Sha>
</Dependency>
<!-- Intermediate is necessary for source build. -->
<Dependency Name="Microsoft.SourceBuild.Intermediate.sdk" Version="9.0.100-preview.7.24358.3">
<Dependency Name="Microsoft.SourceBuild.Intermediate.sdk" Version="9.0.100-preview.7.24371.4">
<Uri>https://github.com/dotnet/sdk</Uri>
<Sha>5e03abbcf74bdef38ca67f04fbd4982e333d1f58</Sha>
<Sha>29904b25a99c8984bacb86473df7d98735fb3207</Sha>
<SourceBuild RepoName="sdk" ManagedOnly="true" />
</Dependency>
<Dependency Name="optimization.windows_nt-arm64.MIBC.Runtime" Version="1.0.0-prerelease.24223.3">
Expand Down
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
<PropertyGroup>
<StaticCsVersion>0.2.0</StaticCsVersion>
<!-- SDK dependencies (also used in wasm build tests -->
<MicrosoftDotNetApiCompatTaskVersion>9.0.100-preview.7.24358.3</MicrosoftDotNetApiCompatTaskVersion>
<MicrosoftDotNetApiCompatTaskVersion>9.0.100-preview.7.24368.3</MicrosoftDotNetApiCompatTaskVersion>
<!-- Arcade dependencies -->
<MicrosoftDotNetBuildTasksFeedVersion>9.0.0-beta.24360.4</MicrosoftDotNetBuildTasksFeedVersion>
<MicrosoftDotNetCodeAnalysisVersion>9.0.0-beta.24360.4</MicrosoftDotNetCodeAnalysisVersion>
Expand Down
1 change: 1 addition & 0 deletions src/libraries/sendtohelix-browser.targets
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
<BuildWasmAppsJobsList>$(RepositoryEngineeringDir)testing\scenarios\BuildWasmAppsJobsList.txt</BuildWasmAppsJobsList>
<_XUnitTraitArg Condition="'$(TestUsingWorkloads)' == 'true'">-notrait category=no-workload</_XUnitTraitArg>
<_XUnitTraitArg Condition="'$(TestUsingWorkloads)' != 'true'">-trait category=no-workload</_XUnitTraitArg>
<_XUnitTraitArg Condition="'$(TestUsingFingerprinting)' == 'false'">$(_XUnitTraitArg) -trait category=no-fingerprinting</_XUnitTraitArg>
</PropertyGroup>

<PropertyGroup>
Expand Down
5 changes: 3 additions & 2 deletions src/libraries/sendtohelix-wasm.targets
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<WorkItemPrefix Condition="'$(TestUsingWorkloads)' == 'true'">Workloads-</WorkItemPrefix>
<WorkItemPrefix Condition="'$(TestUsingWorkloads)' != 'true'">NoWorkload-</WorkItemPrefix>
<WorkItemPrefix Condition="'$(TestUsingWebcil)' == 'false'">$(WorkItemPrefix)NoWebcil-</WorkItemPrefix>
<WorkItemPrefix Condition="'$(TestUsingFingerprinting)' == 'false'">$(WorkItemPrefix)NoFingerprint-</WorkItemPrefix>
<WorkItemPrefix Condition="'$(WasmEnableThreads)' != 'true'">$(WorkItemPrefix)ST-</WorkItemPrefix>
<WorkItemPrefix Condition="'$(WasmEnableThreads)' == 'true'">$(WorkItemPrefix)MT-</WorkItemPrefix>
</PropertyGroup>
Expand Down Expand Up @@ -49,15 +50,15 @@

<!-- for testing with workloads, we use separate items -->
<ItemGroup>
<HelixWorkItem Include="@(BuildWasmApps_PerJobList->'$(WorkItemPrefix)%(Identity)')" Condition="'$(TestUsingWorkloads)' == 'true'">
<HelixWorkItem Include="@(BuildWasmApps_PerJobList->'$(WorkItemPrefix)%(Identity)')" Condition="'$(TestUsingWorkloads)' == 'true' and '$(TestUsingFingerprinting)' == 'true'">
<PayloadArchive>$(_BuildWasmAppsPayloadArchive)</PayloadArchive>
<PreCommands Condition="'$(OS)' == 'Windows_NT'">set &quot;HELIX_XUNIT_ARGS=-class %(Identity)&quot;</PreCommands>
<PreCommands Condition="'$(OS)' != 'Windows_NT'">export &quot;HELIX_XUNIT_ARGS=-class %(Identity)&quot;</PreCommands>
<Command>$(HelixCommand)</Command>
<Timeout>$(_workItemTimeout)</Timeout>
</HelixWorkItem>

<HelixWorkItem Include="$(WorkItemPrefix)Wasm.Build.Tests" Condition="'$(TestUsingWorkloads)' != 'true'">
<HelixWorkItem Include="$(WorkItemPrefix)Wasm.Build.Tests" Condition="'$(TestUsingWorkloads)' != 'true' or '$(TestUsingFingerprinting)' != 'true'">
<PayloadArchive>$(_BuildWasmAppsPayloadArchive)</PayloadArchive>
<Command>$(HelixCommand)</Command>
<Timeout>$(_workItemTimeout)</Timeout>
Expand Down
11 changes: 9 additions & 2 deletions src/libraries/sendtohelix.proj
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,24 @@
<ItemGroup Condition="'@(_Scenarios -> AnyHaveMetadataValue('Identity', 'buildwasmapps'))' == 'true'">
<_TestUsingWorkloadsValues Include="true;false" />
<_TestUsingWebcilValues Include="true;false" Condition="'$(TargetOS)' == 'browser'" />
<_TestUsingFingerprintingValues Include="true;false" Condition="'$(TargetOS)' == 'browser'" />

<!-- now make the cartesian product of true and false values for two categories -->
<_TestUsingCrossProductValuesTemp Include="@(_TestUsingWorkloadsValues)">
<Workloads>%(_TestUsingWorkloadsValues.Identity)</Workloads>
</_TestUsingCrossProductValuesTemp>
<_TestUsingCrossProductValues Include="@(_TestUsingCrossProductValuesTemp)">
<_TestUsingCrossProductValuesTemp2 Include="@(_TestUsingCrossProductValuesTemp)">
<Webcil>%(_TestUsingWebcilValues.Identity)</Webcil>
</_TestUsingCrossProductValuesTemp2>
<_TestUsingCrossProductValues Include="@(_TestUsingCrossProductValuesTemp2)">
<Fingerprinting>%(_TestUsingFingerprintingValues.Identity)</Fingerprinting>
</_TestUsingCrossProductValues>

<!-- There no tests without fingerprinting and without workloads -->
<_TestUsingCrossProductValues Remove="@(_TestUsingCrossProductValues)" Condition="'%(_TestUsingCrossProductValues.Workloads)' == 'false' and '%(_TestUsingCrossProductValues.Fingerprinting)' == 'false'" />

<_BuildWasmAppsProjectsToBuild Include="$(PerScenarioProjectFile)">
<AdditionalProperties>$(_PropertiesToPass);Scenario=BuildWasmApps;TestArchiveRuntimeFile=$(TestArchiveRuntimeFile);TestUsingWorkloads=%(_TestUsingCrossProductValues.Workloads);TestUsingWebcil=%(_TestUsingCrossProductValues.Webcil)</AdditionalProperties>
<AdditionalProperties>$(_PropertiesToPass);Scenario=BuildWasmApps;TestArchiveRuntimeFile=$(TestArchiveRuntimeFile);TestUsingWorkloads=%(_TestUsingCrossProductValues.Workloads);TestUsingWebcil=%(_TestUsingCrossProductValues.Webcil);TestUsingFingerprinting=%(_TestUsingCrossProductValues.Fingerprinting)</AdditionalProperties>
<AdditionalProperties Condition="'$(NeedsToBuildWasmAppsOnHelix)' != ''">%(_BuildWasmAppsProjectsToBuild.AdditionalProperties);NeedsToBuildWasmAppsOnHelix=$(NeedsToBuildWasmAppsOnHelix)</AdditionalProperties>
</_BuildWasmAppsProjectsToBuild>
</ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/libraries/sendtohelixhelp.proj
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
<HelixCommandPrefixEnvVarItem Include="DOTNET_CLI_TELEMETRY_OPTOUT=1" />
<HelixCommandPrefixEnvVarItem Condition="'$(TestUsingWorkloads)' == 'true'" Include="TEST_USING_WORKLOADS=true" />
<HelixCommandPrefixEnvVarItem Condition="'$(TestUsingWebcil)' == 'false'" Include="TEST_USING_WEBCIL=false" />
<HelixCommandPrefixEnvVarItem Condition="'$(TestUsingFingerprinting)' == 'false'" Include="TEST_USING_FINGERPRINTING=false" />
<HelixCommandPrefixEnvVarItem Condition="'$(WorkloadsTestPreviousVersions)' == 'true'" Include="WORKLOADS_TEST_PREVIOUS_VERSIONS=true" />
</ItemGroup>

Expand Down Expand Up @@ -346,7 +347,7 @@
<Target Name="PrintHelixQueues">
<Message Importance="High" Text="Using Queues: $(HelixTargetQueues)" />
<Message Condition="'$(Scenario)' == 'BuildWasmApps'" Importance="High"
Text="Scenario: $(Scenario), TestUsingWorkloads: $(TestUsingWorkloads), TestUsingWebcil: $(TestUsingWebcil)" />
Text="Scenario: $(Scenario), TestUsingWorkloads: $(TestUsingWorkloads), TestUsingWebcil: $(TestUsingWebcil), TestUsingFingerprinting: $(TestUsingFingerprinting)" />
</Target>

<Target Name="PrintBuildTargetFramework">
Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
.stamp-wasm-install-and-select*
emsdk

runtime/dotnet.d.ts.sha256
runtime/*.d.ts.sha256
22 changes: 18 additions & 4 deletions src/mono/browser/debugger/BrowserDebugProxy/DebugStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1683,6 +1683,9 @@ public async IAsyncEnumerable<SourceFile> Load(SessionId id, string[] loaded_fil
var asm_files = new List<string>();
List<DebugItem> steps = new List<DebugItem>();

// Use System.Private.CoreLib to determine if we have a fingerprinted assemblies or not.
bool isFingerprinted = Path.GetFileNameWithoutExtension(loaded_files.FirstOrDefault(f => f.Contains("System.Private.CoreLib"))) != "System.Private.CoreLib";

if (!useDebuggerProtocol)
{
var pdb_files = new List<string>();
Expand All @@ -1698,8 +1701,17 @@ public async IAsyncEnumerable<SourceFile> Load(SessionId id, string[] loaded_fil
{
try
{
string candidate_pdb = Path.ChangeExtension(url, "pdb");
string pdb = pdb_files.FirstOrDefault(n => n == candidate_pdb);
string pdb;
if (isFingerprinted)
{
string noFingerprintPdbFileName = string.Concat(Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(url)), ".pdb");
pdb = pdb_files.FirstOrDefault(n => string.Concat(Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(n)), Path.GetExtension(n)) == noFingerprintPdbFileName);
}
else
{
string candidate_pdb = Path.ChangeExtension(url, "pdb");
pdb = pdb_files.FirstOrDefault(n => n == candidate_pdb);
}

steps.Add(
new DebugItem
Expand All @@ -1722,12 +1734,14 @@ public async IAsyncEnumerable<SourceFile> Load(SessionId id, string[] loaded_fil
continue;
try
{
string unescapedFileName = Uri.UnescapeDataString(file_name);
string unescapedFileName = Path.GetFileName(Uri.UnescapeDataString(file_name));
if (isFingerprinted)
unescapedFileName = string.Concat(Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(unescapedFileName)), Path.GetExtension(unescapedFileName));
steps.Add(
new DebugItem
{
Url = file_name,
DataTask = context.SdbAgent.GetDataFromAssemblyAndPdbAsync(Path.GetFileName(unescapedFileName), false, token)
DataTask = context.SdbAgent.GetDataFromAssemblyAndPdbAsync(unescapedFileName, false, token)
});
}
catch (Exception e)
Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/diagnostics-mock.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ interface MockEnvironment {
expectAdvertise: FilterPredicate;
}

export { MockEnvironment, MockScriptConnection, PromiseAndController };
export type { MockEnvironment, MockScriptConnection, PromiseAndController };
1 change: 0 additions & 1 deletion src/mono/browser/runtime/diagnostics-mock.d.ts.sha256

This file was deleted.

5 changes: 4 additions & 1 deletion src/mono/browser/runtime/dotnet.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ type ResourceExtensions = {
};
interface ResourceGroups {
hash?: string;
fingerprinting?: {
[name: string]: string;
};
coreAssembly?: ResourceList;
assembly?: ResourceList;
lazyAssembly?: ResourceList;
Expand Down Expand Up @@ -692,4 +695,4 @@ declare global {
}
declare const createDotnetRuntime: CreateDotnetRuntimeType;

export { AssetBehaviors, AssetEntry, CreateDotnetRuntimeType, DotnetHostBuilder, DotnetModuleConfig, EmscriptenModule, GlobalizationMode, IMemoryView, ModuleAPI, MonoConfig, RuntimeAPI, createDotnetRuntime as default, dotnet, exit };
export { type AssetBehaviors, type AssetEntry, type CreateDotnetRuntimeType, type DotnetHostBuilder, type DotnetModuleConfig, type EmscriptenModule, GlobalizationMode, type IMemoryView, type ModuleAPI, type MonoConfig, type RuntimeAPI, createDotnetRuntime as default, dotnet, exit };
30 changes: 28 additions & 2 deletions src/mono/browser/runtime/lazyLoading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,23 @@ import { AssetEntry } from "./types";

export async function loadLazyAssembly (assemblyNameToLoad: string): Promise<boolean> {
const resources = loaderHelpers.config.resources!;
const originalAssemblyName = assemblyNameToLoad;
const lazyAssemblies = resources.lazyAssembly;
if (!lazyAssemblies) {
throw new Error("No assemblies have been marked as lazy-loadable. Use the 'BlazorWebAssemblyLazyLoad' item group in your project file to enable lazy loading an assembly.");
}

if (loaderHelpers.config.resources!.fingerprinting) {
const map = loaderHelpers.config.resources!.fingerprinting;
for (const fingerprintedName in map) {
const nonFingerprintedName = map[fingerprintedName];
if (nonFingerprintedName == assemblyNameToLoad) {
assemblyNameToLoad = fingerprintedName;
break;
}
}
}

if (!lazyAssemblies[assemblyNameToLoad]) {
throw new Error(`${assemblyNameToLoad} must be marked with 'BlazorWebAssemblyLazyLoad' item group in your project file to allow lazy-loading.`);
}
Expand All @@ -26,8 +38,22 @@ export async function loadLazyAssembly (assemblyNameToLoad: string): Promise<boo
return false;
}

const pdbNameToLoad = changeExtension(dllAsset.name, ".pdb");
const shouldLoadPdb = loaderHelpers.config.debugLevel != 0 && loaderHelpers.isDebuggingSupported() && Object.prototype.hasOwnProperty.call(lazyAssemblies, pdbNameToLoad);
let pdbNameToLoad = changeExtension(originalAssemblyName, ".pdb");
let shouldLoadPdb = false;
if (loaderHelpers.config.debugLevel != 0 && loaderHelpers.isDebuggingSupported()) {
shouldLoadPdb = Object.prototype.hasOwnProperty.call(lazyAssemblies, pdbNameToLoad);
if (loaderHelpers.config.resources!.fingerprinting) {
const map = loaderHelpers.config.resources!.fingerprinting;
for (const fingerprintedName in map) {
const nonFingerprintedName = map[fingerprintedName];
if (nonFingerprintedName == pdbNameToLoad) {
pdbNameToLoad = fingerprintedName;
shouldLoadPdb = true;
break;
}
}
}
}

const dllBytesPromise = loaderHelpers.retrieve_asset_download(dllAsset);

Expand Down
14 changes: 13 additions & 1 deletion src/mono/browser/runtime/loader/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@ export function prepareAssets () {
}

const addAsset = (asset: AssetEntryInternal, isCore: boolean) => {
if (resources.fingerprinting && (asset.behavior == "assembly" || asset.behavior == "pdb" || asset.behavior == "resource")) {
asset.virtualPath = getNonFingerprintedAssetName(asset.name);
}
if (isCore) {
asset.isCore = true;
coreAssetsToLoad.push(asset);
Expand Down Expand Up @@ -418,7 +421,7 @@ export function prepareAssets () {
behavior: "icu",
loadRemote: true
});
} else if (name === "segmentation-rules.json") {
} else if (name.startsWith("segmentation-rules") && name.endsWith(".json")) {
assetsToLoad.push({
name,
hash: resources.icu[name],
Expand Down Expand Up @@ -460,6 +463,15 @@ export function prepareAssets () {
config.assets = [...coreAssetsToLoad, ...assetsToLoad, ...modulesAssets];
}

export function getNonFingerprintedAssetName (assetName: string) {
const fingerprinting = loaderHelpers.config.resources?.fingerprinting;
if (fingerprinting && fingerprinting[assetName]) {
return fingerprinting[assetName];
}

return assetName;
}

export function prepareAssetsWorker () {
const config = loaderHelpers.config;
mono_assert(config.assets, "config.assets must be defined");
Expand Down
16 changes: 14 additions & 2 deletions src/mono/browser/runtime/loader/icu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { mono_log_error } from "./logging";
import { GlobalizationMode, MonoConfig } from "../types";
import { ENVIRONMENT_IS_WEB, loaderHelpers } from "./globals";
import { mono_log_info, mono_log_debug } from "./logging";
import { getNonFingerprintedAssetName } from "./assets";

export function init_globalization () {
loaderHelpers.preferredIcuAsset = getIcuResourceName(loaderHelpers.config);
Expand Down Expand Up @@ -51,6 +52,17 @@ export function getIcuResourceName (config: MonoConfig): string | null {
const culture = config.applicationCulture || (ENVIRONMENT_IS_WEB ? (globalThis.navigator && globalThis.navigator.languages && globalThis.navigator.languages[0]) : Intl.DateTimeFormat().resolvedOptions().locale);

const icuFiles = Object.keys(config.resources.icu);
const fileMapping: {
[k: string]: string
} = {};
for (let index = 0; index < icuFiles.length; index++) {
const icuFile = icuFiles[index];
if (config.resources.fingerprinting) {
fileMapping[getNonFingerprintedAssetName(icuFile)] = icuFile;
} else {
fileMapping[icuFile] = icuFile;
}
}

let icuFile = null;
if (config.globalizationMode === GlobalizationMode.Custom) {
Expand All @@ -65,8 +77,8 @@ export function getIcuResourceName (config: MonoConfig): string | null {
icuFile = getShardedIcuResourceName(culture);
}

if (icuFile && icuFiles.includes(icuFile)) {
return icuFile;
if (icuFile && fileMapping[icuFile]) {
return fileMapping[icuFile];
}
}

Expand Down
1 change: 1 addition & 0 deletions src/mono/browser/runtime/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ export type ResourceExtensions = { [extensionName: string]: ResourceList };

export interface ResourceGroups {
hash?: string;
fingerprinting?: { [name: string]: string },
maraf marked this conversation as resolved.
Show resolved Hide resolved
coreAssembly?: ResourceList; // nullable only temporarily
assembly?: ResourceList; // nullable only temporarily
lazyAssembly?: ResourceList; // nullable only temporarily
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Copyright (c) .NET Foundation. All rights reserved.
<StaticWebAssetsGetPublishAssetsTargets>ComputeFilesToPublish;GetCurrentProjectPublishStaticWebAssetItems</StaticWebAssetsGetPublishAssetsTargets>
<StaticWebAssetsAdditionalPublishProperties>$(StaticWebAssetsAdditionalPublishProperties);BuildProjectReferences=false;ResolveAssemblyReferencesFindRelatedSatellites=true</StaticWebAssetsAdditionalPublishProperties>
<StaticWebAssetsAdditionalPublishPropertiesToRemove>$(StaticWebAssetsAdditionalPublishPropertiesToRemove);NoBuild;RuntimeIdentifier</StaticWebAssetsAdditionalPublishPropertiesToRemove>
<StaticWebAssetStandaloneHosting Condition="'$(StaticWebAssetStandaloneHosting)' == '' and '$(StaticWebAssetProjectMode)' == 'Root'">true</StaticWebAssetStandaloneHosting>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading
Loading