Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Copyright (c) .NET Foundation. All rights reserved.
<DebuggerSupport Condition="'$(DebuggerSupport)' == '' and '$(Configuration)' != 'Debug'">false</DebuggerSupport>
<BlazorCacheBootResources Condition="'$(BlazorCacheBootResources)' == ''">true</BlazorCacheBootResources>
<WasmFingerprintDotnetJs>true</WasmFingerprintDotnetJs>
<WasmFingerprintDotnetJs Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals('$(TargetFrameworkVersion)', '8.0'))">false</WasmFingerprintDotnetJs>

<!-- Don't generate a NETSDK1151 error if a non self-contained Exe references a Blazor Exe -->
<ShouldBeValidatedAsExecutableReference>false</ShouldBeValidatedAsExecutableReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -879,8 +879,6 @@
"${OutputPath}\\wwwroot\\_framework\\de\\Microsoft.CodeAnalysis.resources.dll.gz",
"${OutputPath}\\wwwroot\\_framework\\dotnet.js",
"${OutputPath}\\wwwroot\\_framework\\dotnet.js.gz",
"${OutputPath}\\wwwroot\\_framework\\dotnet.js",
"${OutputPath}\\wwwroot\\_framework\\dotnet.js.gz",
"${OutputPath}\\wwwroot\\_framework\\dotnet.wasm",
"${OutputPath}\\wwwroot\\_framework\\dotnet.wasm.gz",
"${OutputPath}\\wwwroot\\_framework\\es-ES\\classlibrarywithsatelliteassemblies.resources.dll",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -791,8 +791,6 @@
"${OutputPath}\\wwwroot\\_framework\\blazorwasm-minimal.pdb.gz",
"${OutputPath}\\wwwroot\\_framework\\dotnet.js",
"${OutputPath}\\wwwroot\\_framework\\dotnet.js.gz",
"${OutputPath}\\wwwroot\\_framework\\dotnet.js",
"${OutputPath}\\wwwroot\\_framework\\dotnet.js.gz",
"${OutputPath}\\wwwroot\\_framework\\dotnet.wasm",
"${OutputPath}\\wwwroot\\_framework\\dotnet.wasm.gz",
"${OutputPath}\\wwwroot\\_framework\\icudt.dat",
Expand Down
44 changes: 27 additions & 17 deletions src/WasmSdk/Tasks/ComputeWasmBuildAssets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,34 +106,44 @@ public override bool Execute()
continue;
}

if (candidate.GetMetadata("FileName") == "dotnet" && candidate.GetMetadata("Extension") == ".js" && FingerprintDotNetJs)
if (candidate.GetMetadata("FileName") == "dotnet" && candidate.GetMetadata("Extension") == ".js")
{
string newDotnetJSFileName = null;
string newDotNetJSFullPath = null;
if (FingerprintDotNetJs)
{
var itemHash = FileHasher.GetFileHash(candidate.ItemSpec);
var cacheBustedDotNetJSFileName = $"dotnet.{candidate.GetMetadata("NuGetPackageVersion")}.{itemHash}.js";
newDotnetJSFileName = $"dotnet.{candidate.GetMetadata("NuGetPackageVersion")}.{itemHash}.js";

var originalFileFullPath = Path.GetFullPath(candidate.ItemSpec);
var originalFileDirectory = Path.GetDirectoryName(originalFileFullPath);

var cacheBustedDotNetJSFullPath = Path.Combine(originalFileDirectory, cacheBustedDotNetJSFileName);

var newDotNetJs = new TaskItem(cacheBustedDotNetJSFullPath, candidate.CloneCustomMetadata());
newDotNetJs.SetMetadata("OriginalItemSpec", candidate.ItemSpec);

var newRelativePath = $"_framework/{cacheBustedDotNetJSFileName}";
newDotNetJs.SetMetadata("RelativePath", newRelativePath);

newDotNetJs.SetMetadata("AssetTraitName", "WasmResource");
newDotNetJs.SetMetadata("AssetTraitValue", "native");

assetCandidates.Add(newDotNetJs);
continue;
newDotNetJSFullPath = Path.Combine(originalFileDirectory, newDotnetJSFileName);
}
else
{
string relativePath = AssetsComputingHelper.GetCandidateRelativePath(candidate);
candidate.SetMetadata("RelativePath", relativePath);
newDotNetJSFullPath = candidate.ItemSpec;
newDotnetJSFileName = Path.GetFileName(newDotNetJSFullPath);
}

var newDotNetJs = new TaskItem(newDotNetJSFullPath, candidate.CloneCustomMetadata());
newDotNetJs.SetMetadata("OriginalItemSpec", candidate.ItemSpec);

var newRelativePath = $"_framework/{newDotnetJSFileName}";
newDotNetJs.SetMetadata("RelativePath", newRelativePath);

newDotNetJs.SetMetadata("AssetTraitName", "WasmResource");
newDotNetJs.SetMetadata("AssetTraitValue", "native");

assetCandidates.Add(newDotNetJs);
continue;
}
else
{
string relativePath = AssetsComputingHelper.GetCandidateRelativePath(candidate);
candidate.SetMetadata("RelativePath", relativePath);
}

// Workaround for https://github.com/dotnet/aspnetcore/issues/37574.
// For items added as "Reference" in project references, the OriginalItemSpec is incorrect.
// Ignore it, and use the FullPath instead.
Expand Down