Skip to content

Commit 32850b7

Browse files
authored
Merge pull request #1029 from unoplatform/dev/jela/fingerprint-adjust
fix: Adjust for publish incorrect rename of dotnet.js fingerprint
2 parents 7ba215b + 0089747 commit 32850b7

File tree

7 files changed

+139
-4
lines changed

7 files changed

+139
-4
lines changed

build/ci/stage-build-linux-tests.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ jobs:
4545
OverWrite: false
4646
flattenFolders: false
4747

48+
## Validate dotnet.js fingerprint matches actual file
49+
- bash: |
50+
$(build.sourcesdirectory)/build/scripts/validate-dotnetjs-fingerprint.sh \
51+
"$(build.sourcesdirectory)/src/Uno.Wasm.Sample.RayTracer/bin/Release/net10.0/publish/wwwroot"
52+
displayName: Validate dotnet.js fingerprint (RayTracer)
53+
4854
## Raytracer validation
4955
- bash: |
5056
$(build.sourcesdirectory)/build/scripts/run-tests.sh \
@@ -102,6 +108,12 @@ jobs:
102108
OverWrite: false
103109
flattenFolders: false
104110

111+
## Validate dotnet.js fingerprint matches actual file (SWA build)
112+
- bash: |
113+
$(build.sourcesdirectory)/build/scripts/validate-dotnetjs-fingerprint.sh \
114+
"$(build.sourcesdirectory)/src/Uno.Wasm.Sample.RayTracer/bin/Release/net10.0/publish/wwwroot"
115+
displayName: Validate dotnet.js fingerprint (SWA)
116+
105117
- bash: |
106118
$(build.sourcesdirectory)/build/scripts/run-tests-swa.sh \
107119
"$(build.sourcesdirectory)/src/Uno.Wasm.Sample.RayTracer/bin/Release/net10.0/publish/wwwroot" \

build/ci/stage-build-macos-tests.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ jobs:
3333
dotnet publish -c Release /m:1 /p:DISABLE_CLIHOST_NET6=true /p:WasmShellEmccLinkOptimization=false /p:WasmShellILLinkerEnabled=false /bl:$(build.artifactstagingdirectory)/SampleNet5-nolinker-macos.binlog
3434
displayName: Build StaticLinking.Interpreter Sample (net5 without linker)
3535
36+
## Validate dotnet.js fingerprint matches actual file
37+
- bash: |
38+
$(build.sourcesdirectory)/build/scripts/validate-dotnetjs-fingerprint.sh \
39+
"$(build.sourcesdirectory)/src/Uno.Wasm.StaticLinking.Interpreter/bin/Release/net10.0/publish/wwwroot"
40+
displayName: Validate dotnet.js fingerprint (StaticLinking.Interpreter)
41+
3642
- bash: |
3743
$(build.sourcesdirectory)/build/scripts/run-tests.sh \
3844
"$(build.sourcesdirectory)/src/Uno.Wasm.StaticLinking.Interpreter/bin/Release/net10.0/publish/wwwroot" \

build/ci/stage-build-windows-tests.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,16 @@ jobs:
6666
6767
- pwsh: |
6868
cd $(build.sourcesdirectory)/src/Uno.Wasm.Sample.RayTracer
69-
dotnet clean -c Release
69+
dotnet clean -c Release
7070
dotnet publish -c Release /m:1 /p:WasmShellEmccLinkOptimization=false /bl:$(build.artifactstagingdirectory)/SampleNet5-win.binlog
7171
displayName: Build Raytracer Sample
7272
73+
## Validate dotnet.js fingerprint matches actual file
74+
- pwsh: |
75+
$(build.sourcesdirectory)\build\scripts\validate-dotnetjs-fingerprint.ps1 `
76+
-PublishPath "$(build.sourcesdirectory)\src\Uno.Wasm.Sample.RayTracer\bin\Release\net10.0\publish\wwwroot"
77+
displayName: Validate dotnet.js fingerprint (RayTracer)
78+
7379
- pwsh: |
7480
$(build.sourcesdirectory)\build\scripts\run-tests-windows.ps1 `
7581
"$(build.sourcesdirectory)\src\Uno.Wasm.Sample.RayTracer\bin\Release\net10.0\publish\wwwroot" `
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Validates that uno-config.js references a dotnet.js fingerprint that matches an actual file
2+
param(
3+
[Parameter(Mandatory=$true)]
4+
[string]$PublishPath
5+
)
6+
7+
$ErrorActionPreference = "Stop"
8+
9+
Write-Host "Validating dotnet.js fingerprint in: $PublishPath"
10+
11+
# Find uno-config.js (it could be in a package_* subdirectory)
12+
$unoConfig = Get-ChildItem -Path $PublishPath -Recurse -Filter "uno-config.js" | Select-Object -First 1
13+
14+
if (-not $unoConfig) {
15+
Write-Host "ERROR: uno-config.js not found in $PublishPath"
16+
exit 1
17+
}
18+
19+
Write-Host "Found uno-config.js: $($unoConfig.FullName)"
20+
21+
# Read the content and extract the fingerprint
22+
$content = Get-Content -Path $unoConfig.FullName -Raw
23+
$match = [regex]::Match($content, 'dotnet\.([a-z0-9]+)\.js')
24+
25+
if (-not $match.Success) {
26+
Write-Host "ERROR: Could not extract dotnet.js fingerprint from uno-config.js"
27+
Write-Host "Content of uno-config.js:"
28+
Write-Host $content
29+
exit 1
30+
}
31+
32+
$fingerprint = $match.Groups[1].Value
33+
Write-Host "Fingerprint in uno-config.js: $fingerprint"
34+
35+
# Check if the fingerprinted dotnet.js file exists
36+
$frameworkPath = Join-Path $PublishPath "_framework"
37+
$dotnetJsFile = Join-Path $frameworkPath "dotnet.$fingerprint.js"
38+
39+
if (-not (Test-Path $dotnetJsFile)) {
40+
Write-Host "ERROR: Fingerprint mismatch!"
41+
Write-Host " uno-config.js references: dotnet.$fingerprint.js"
42+
Write-Host " But this file does not exist in: $frameworkPath"
43+
Write-Host ""
44+
Write-Host "Available dotnet.*.js files in _framework:"
45+
Get-ChildItem -Path $frameworkPath -Filter "dotnet.*.js" -ErrorAction SilentlyContinue | ForEach-Object { Write-Host " $($_.Name)" }
46+
exit 1
47+
}
48+
49+
Write-Host "SUCCESS: dotnet.$fingerprint.js exists in _framework"
50+
Write-Host "Fingerprint validation passed!"
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
# Validates that uno-config.js references a dotnet.js fingerprint that matches an actual file
3+
set -e
4+
5+
PUBLISH_PATH=$1
6+
7+
if [ -z "$PUBLISH_PATH" ]; then
8+
echo "Usage: validate-dotnetjs-fingerprint.sh <publish-wwwroot-path>"
9+
exit 1
10+
fi
11+
12+
echo "Validating dotnet.js fingerprint in: $PUBLISH_PATH"
13+
14+
# Find uno-config.js (it could be in a package_* subdirectory)
15+
UNO_CONFIG=$(find "$PUBLISH_PATH" -name "uno-config.js" -type f | head -1)
16+
17+
if [ -z "$UNO_CONFIG" ]; then
18+
echo "ERROR: uno-config.js not found in $PUBLISH_PATH"
19+
exit 1
20+
fi
21+
22+
echo "Found uno-config.js: $UNO_CONFIG"
23+
24+
# Extract the fingerprint from uno-config.js (portable across GNU and BSD grep/sed)
25+
FINGERPRINT=$(sed -n 's/.*dotnet\.\([a-z0-9]*\)\.js.*/\1/p' "$UNO_CONFIG" | head -1)
26+
27+
if [ -z "$FINGERPRINT" ]; then
28+
echo "ERROR: Could not extract dotnet.js fingerprint from uno-config.js"
29+
echo "Content of uno-config.js:"
30+
cat "$UNO_CONFIG"
31+
exit 1
32+
fi
33+
34+
echo "Fingerprint in uno-config.js: $FINGERPRINT"
35+
36+
# Check if the fingerprinted dotnet.js file exists
37+
FRAMEWORK_PATH="$PUBLISH_PATH/_framework"
38+
DOTNET_JS_FILE="$FRAMEWORK_PATH/dotnet.$FINGERPRINT.js"
39+
40+
if [ ! -f "$DOTNET_JS_FILE" ]; then
41+
echo "ERROR: Fingerprint mismatch!"
42+
echo " uno-config.js references: dotnet.$FINGERPRINT.js"
43+
echo " But this file does not exist in: $FRAMEWORK_PATH"
44+
echo ""
45+
echo "Available dotnet.*.js files in _framework:"
46+
ls -la "$FRAMEWORK_PATH"/dotnet.*.js 2>/dev/null || echo " (none found)"
47+
exit 1
48+
fi
49+
50+
echo "SUCCESS: dotnet.$FINGERPRINT.js exists in _framework"
51+
echo "Fingerprint validation passed!"

src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,15 +452,18 @@
452452
AfterTargets="ResolvePublishStaticWebAssets">
453453

454454
<!-- Find the dotnet.js StaticWebAsset from publish assets and extract its fingerprint.
455-
We look for assets where AssetMode is 'All' or 'Publish' to get the publish-time fingerprint. -->
455+
We look for assets where AssetMode is 'All' or 'Publish' to get the publish-time fingerprint.
456+
During publish, the RelativePath may already be resolved to the actual fingerprinted value
457+
(e.g., '_framework/dotnet.abc123.js') instead of the placeholder pattern, so we match both. -->
456458
<ItemGroup>
457459
<_UnoDotnetJsAssetPublish Include="@(StaticWebAsset)"
458-
Condition="$([System.String]::Copy('%(RelativePath)').StartsWith('_framework/dotnet#[.{fingerprint}]')) AND $([System.String]::Copy('%(RelativePath)').EndsWith('.js')) AND !$([System.String]::Copy('%(RelativePath)').Contains('.native')) AND !$([System.String]::Copy('%(RelativePath)').Contains('.runtime')) AND ('%(AssetMode)' == 'All' OR '%(AssetMode)' == 'Publish' OR '%(AssetMode)' == '')" />
460+
Condition="($([System.String]::Copy('%(RelativePath)').StartsWith('_framework/dotnet#[.{fingerprint}]')) OR $([System.Text.RegularExpressions.Regex]::IsMatch('%(RelativePath)', '^_framework/dotnet\.[a-z0-9]+\.js$'))) AND $([System.String]::Copy('%(RelativePath)').EndsWith('.js')) AND !$([System.String]::Copy('%(RelativePath)').Contains('.native')) AND !$([System.String]::Copy('%(RelativePath)').Contains('.runtime')) AND ('%(AssetMode)' == 'All' OR '%(AssetMode)' == 'Publish' OR '%(AssetMode)' == '')" />
459461
</ItemGroup>
460462

461-
<!-- Get the last fingerprint (which should be the publish one) by using batching -->
463+
<!-- Get the fingerprint from metadata first, then fall back to extracting from RelativePath if empty -->
462464
<PropertyGroup>
463465
<_UnoDotnetJsFingerprintPublish>%(_UnoDotnetJsAssetPublish.Fingerprint)</_UnoDotnetJsFingerprintPublish>
466+
<_UnoDotnetJsFingerprintPublish Condition="'$(_UnoDotnetJsFingerprintPublish)' == ''">$([System.Text.RegularExpressions.Regex]::Match('%(_UnoDotnetJsAssetPublish.RelativePath)', 'dotnet\.([a-z0-9]+)\.js$').Groups[1].Value)</_UnoDotnetJsFingerprintPublish>
464467
<_UnoConfigJsPath>$(IntermediateOutputPath)unowwwrootassets/uno-config.js</_UnoConfigJsPath>
465468
</PropertyGroup>
466469

src/Uno.Wasm.Sample.RayTracer/Uno.Wasm.Sample.RayTracer.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@
5656
<PropertyGroup>
5757
<_appOutput>$(PublishDir)wwwroot/$(WasmShellOutputPackagePath)</_appOutput>
5858
<_unoConfigJsContent>$([System.IO.File]::ReadAllText('$(_appOutput)/uno-config.js'))</_unoConfigJsContent>
59+
<_frameworkPath>$(PublishDir)wwwroot/_framework</_frameworkPath>
60+
<!-- Extract the fingerprint from uno-config.js to verify the file exists -->
61+
<_configDotnetJsFingerprint>$([System.Text.RegularExpressions.Regex]::Match('$(_unoConfigJsContent)', 'dotnet\.([a-z0-9]+)\.js').Groups[1].Value)</_configDotnetJsFingerprint>
5962
</PropertyGroup>
6063

6164
<ItemGroup>
@@ -72,6 +75,10 @@
7275
<Error Condition="$(_unoConfigJsContent.Contains('_framework/dotnet.js'))"
7376
Text="uno-config.js contains non-fingerprinted _framework/dotnet.js reference in offline_files. Expected fingerprinted path like '_framework/dotnet.abc123.js'" />
7477

78+
<!-- Validate that the fingerprinted dotnet.js file referenced in uno-config.js actually exists -->
79+
<Error Condition="'$(_configDotnetJsFingerprint)' != '' AND !Exists('$(_frameworkPath)/dotnet.$(_configDotnetJsFingerprint).js')"
80+
Text="Fingerprint mismatch: uno-config.js references dotnet.$(_configDotnetJsFingerprint).js but this file does not exist in $(_frameworkPath). The publish-time fingerprint update may have failed." />
81+
7582
<Message Importance="high" Text="Output dist validated" />
7683
</Target>
7784

0 commit comments

Comments
 (0)