Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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 @@ -157,9 +157,6 @@ Copyright (c) .NET Foundation. All rights reserved.
<!-- Remove dotnet.js/wasm from runtime pack, in favor of the relinked ones in @(WasmNativeAsset) -->
<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)"
Condition="@(WasmNativeAsset->Count()) > 0 and '%(FileName)' == 'dotnet' and ('%(Extension)' == '.wasm' or '%(Extension)' == '.js')" />

<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)"
Condition="@(WasmNativeAsset->Count()) > 0 and '%(FileName)' == 'dotnet-crypto-worker' and '%(Extension)' == '.js'" />
</ItemGroup>

<ComputeBlazorBuildAssets
Expand Down Expand Up @@ -406,7 +403,6 @@ Copyright (c) .NET Foundation. All rights reserved.

<ItemGroup>
<_DotNetJsItem Include="@(ResolvedFileToPublish)" Condition="'%(ResolvedFileToPublish.DestinationSubPath)' == 'dotnet.js' AND '%(ResolvedFileToPublish.AssetType)' == 'native'" />
<_DotNetJsItem Include="@(ResolvedFileToPublish)" Condition="'%(ResolvedFileToPublish.DestinationSubPath)' == 'dotnet-crypto-worker.js' AND '%(ResolvedFileToPublish.AssetType)' == 'native'" />
</ItemGroup>

<PropertyGroup>
Expand Down
24 changes: 1 addition & 23 deletions src/BlazorWasmSdk/Tasks/ComputeBlazorBuildAssets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,28 +118,6 @@ public override bool Execute()
assetCandidates.Add(newDotNetJs);
continue;
}
else if (candidate.GetMetadata("FileName") == "dotnet-crypto-worker" && candidate.GetMetadata("Extension") == ".js")
{
var itemHash = FileHasher.GetFileHash(candidate.ItemSpec);
var cacheBustedDotNetCryptoWorkerJSFileName = $"dotnet-crypto-worker.{candidate.GetMetadata("NuGetPackageVersion")}.{itemHash}.js";

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

var cacheBustedDotNetCryptoWorkerJSFullPath = Path.Combine(originalFileDirectory, cacheBustedDotNetCryptoWorkerJSFileName);

var newDotnetCryptoWorkerJs = new TaskItem(cacheBustedDotNetCryptoWorkerJSFullPath, candidate.CloneCustomMetadata());
newDotnetCryptoWorkerJs.SetMetadata("OriginalItemSpec", candidate.ItemSpec);

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

newDotnetCryptoWorkerJs.SetMetadata("AssetTraitName", "BlazorWebAssemblyResource");
newDotnetCryptoWorkerJs.SetMetadata("AssetTraitValue", "js-module-crypto");

assetCandidates.Add(newDotnetCryptoWorkerJs);
continue;
}
else if (string.IsNullOrEmpty(destinationSubPath))
{
var relativePath = candidate.GetMetadata("FileName") + candidate.GetMetadata("Extension");
Expand Down Expand Up @@ -303,7 +281,7 @@ public static bool ShouldFilterCandidate(
".json" when fromMonoPackage && (fileName == "emcc-props" || fileName == "package") => $"{fileName}{extension} is not used by Blazor",
".ts" when fromMonoPackage && fileName == "dotnet.d" => "dotnet type definition is not used by Blazor",
".ts" when fromMonoPackage && fileName == "dotnet-legacy.d" => "dotnet type definition is not used by Blazor",
".js" when assetType == "native" && fileName != "dotnet" && fileName != "dotnet-crypto-worker" => $"{fileName}{extension} is not used by Blazor",
".js" when assetType == "native" && fileName != "dotnet" => $"{fileName}{extension} is not used by Blazor",
".pdb" when !copySymbols => "copying symbols is disabled",
".symbols" when fromMonoPackage => "extension .symbols is not required.",
_ => null
Expand Down
38 changes: 2 additions & 36 deletions src/BlazorWasmSdk/Tasks/ComputeBlazorPublishAssets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,8 @@ private List<ITaskItem> ProcessNativeAssets(
var key = kvp.Key;
var asset = kvp.Value;
var isDotNetJs = IsDotNetJs(key);
var isDotNetCryptoJs = IsDotNetCryptoJs(key);
var isDotNetWasm = IsDotNetWasm(key);
if (!isDotNetJs && !isDotNetWasm && !isDotNetCryptoJs)
if (!isDotNetJs && !isDotNetWasm)
{
if (resolvedNativeAssetToPublish.TryGetValue(Path.GetFileName(asset.GetMetadata("OriginalItemSpec")), out var existing))
{
Expand Down Expand Up @@ -216,34 +215,6 @@ private List<ITaskItem> ProcessNativeAssets(
continue;
}

if (isDotNetCryptoJs)
{
var aotDotNetCryptoJs = WasmAotAssets.SingleOrDefault(a => $"{a.GetMetadata("FileName")}{a.GetMetadata("Extension")}" == "dotnet-crypto-worker.js");
ITaskItem newDotNetCryptoJs = null;
if (aotDotNetCryptoJs != null)
{
newDotNetCryptoJs = new TaskItem(Path.GetFullPath(aotDotNetCryptoJs.ItemSpec), asset.CloneCustomMetadata());
newDotNetCryptoJs.SetMetadata("OriginalItemSpec", aotDotNetCryptoJs.ItemSpec);
newDotNetCryptoJs.SetMetadata("RelativePath", $"_framework/{$"dotnet-crypto-worker.{DotNetJsVersion}.{FileHasher.GetFileHash(aotDotNetCryptoJs.ItemSpec)}.js"}");

updateMap.Add(asset.ItemSpec, newDotNetCryptoJs);
Log.LogMessage(MessageImportance.Low, "Replacing asset '{0}' with AoT version '{1}'", asset.ItemSpec, newDotNetCryptoJs.ItemSpec);
}
else
{
newDotNetCryptoJs = new TaskItem(asset);
Log.LogMessage(MessageImportance.Low, "Promoting asset '{0}' to Publish asset.", asset.ItemSpec);
}

ApplyPublishProperties(newDotNetCryptoJs);
nativeStaticWebAssets.Add(newDotNetCryptoJs);
if (resolvedNativeAssetToPublish.TryGetValue("dotnet-crypto-worker.js", out var resolved))
{
filesToRemove.Add(resolved);
}
continue;
}

if (isDotNetWasm)
{
var aotDotNetWasm = WasmAotAssets.SingleOrDefault(a => $"{a.GetMetadata("FileName")}{a.GetMetadata("Extension")}" == "dotnet.wasm");
Expand Down Expand Up @@ -285,11 +256,6 @@ static bool IsDotNetJs(string key)
return fileName.StartsWith("dotnet.", StringComparison.Ordinal) && fileName.EndsWith(".js", StringComparison.Ordinal) && !fileName.Contains("worker");
}

static bool IsDotNetCryptoJs(string key)
{
var fileName = Path.GetFileName(key);
return fileName.StartsWith("dotnet-crypto-worker.", StringComparison.Ordinal) && fileName.EndsWith(".js", StringComparison.Ordinal);
}
static bool IsDotNetWasm(string key) => string.Equals("dotnet.wasm", Path.GetFileName(key), StringComparison.Ordinal);
}

Expand Down Expand Up @@ -638,7 +604,7 @@ private void GroupResolvedFilesToPublish(
}
}

private static bool IsNativeAsset(string traitValue) => string.Equals(traitValue, "native", StringComparison.Ordinal) || string.Equals(traitValue, "js-module-crypto", StringComparison.Ordinal);
private static bool IsNativeAsset(string traitValue) => string.Equals(traitValue, "native", StringComparison.Ordinal);

private static bool IsRuntimeAsset(string traitValue) => string.Equals(traitValue, "runtime", StringComparison.Ordinal);
private static bool IsSymbolAsset(string traitValue) => string.Equals(traitValue, "symbol", StringComparison.Ordinal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,6 @@ public void WriteBootJson(Stream output, string entryAssemblyName)
AddResourceToList(resource, resourceList, targetPath);
continue;
}
else if(string.Equals(assetTraitName, "BlazorWebAssemblyResource", StringComparison.OrdinalIgnoreCase) &&
string.Equals(assetTraitValue, "js-module-crypto", StringComparison.OrdinalIgnoreCase))
{
behavior = assetTraitValue;
}
else if (string.Equals("BlazorWebAssemblyResource", assetTraitName, StringComparison.OrdinalIgnoreCase) &&
assetTraitValue.StartsWith("extension:", StringComparison.OrdinalIgnoreCase))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3297,23 +3297,6 @@
"CopyToPublishDirectory": "Never",
"OriginalItemSpec": "obj\\Debug\\${Tfm}\\blazorwasm-minimal.pdb"
},
{
"Identity": "${ProjectRoot}\\bin\\Debug\\${Tfm}\\wwwroot\\_framework\\dotnet-crypto-worker.${RuntimeVersion}.[[hash]].js",
"SourceId": "blazorwasm-minimal",
"SourceType": "Computed",
"ContentRoot": "${ProjectRoot}\\bin\\Debug\\${Tfm}\\wwwroot\\",
"BasePath": "/",
"RelativePath": "_framework/dotnet-crypto-worker.${RuntimeVersion}.[[hash]].js",
"AssetKind": "Build",
"AssetMode": "All",
"AssetRole": "Primary",
"RelatedAsset": "",
"AssetTraitName": "BlazorWebAssemblyResource",
"AssetTraitValue": "js-module-crypto",
"CopyToOutputDirectory": "PreserveNewest",
"CopyToPublishDirectory": "Never",
"OriginalItemSpec": "${RestorePath}\\microsoft.netcore.app.runtime.mono.browser-wasm\\${RuntimeVersion}\\runtimes\\browser-wasm\\native\\dotnet-crypto-worker.js"
},
{
"Identity": "${ProjectRoot}\\bin\\Debug\\${Tfm}\\wwwroot\\_framework\\dotnet.${RuntimeVersion}.[[hash]].js",
"SourceId": "blazorwasm-minimal",
Expand Down Expand Up @@ -6731,23 +6714,6 @@
"CopyToPublishDirectory": "Never",
"OriginalItemSpec": "${ProjectRoot}\\bin\\Debug\\${Tfm}\\wwwroot\\_framework\\blazorwasm-minimal.pdb"
},
{
"Identity": "${ProjectRoot}\\obj\\Debug\\${Tfm}\\build-gz\\[[_framework/dotnet-crypto-worker.${RuntimeVersion}.[[hash]].js.gz]]",
"SourceId": "blazorwasm-minimal",
"SourceType": "Computed",
"ContentRoot": "${ProjectRoot}\\bin\\Debug\\${Tfm}\\wwwroot\\",
"BasePath": "/",
"RelativePath": "_framework/dotnet-crypto-worker.${RuntimeVersion}.[[hash]].js.gz",
"AssetKind": "Build",
"AssetMode": "All",
"AssetRole": "Alternative",
"RelatedAsset": "${ProjectRoot}\\bin\\Debug\\${Tfm}\\wwwroot\\_framework\\dotnet-crypto-worker.${RuntimeVersion}.[[hash]].js",
"AssetTraitName": "Content-Encoding",
"AssetTraitValue": "gzip",
"CopyToOutputDirectory": "PreserveNewest",
"CopyToPublishDirectory": "Never",
"OriginalItemSpec": "${ProjectRoot}\\bin\\Debug\\${Tfm}\\wwwroot\\_framework\\dotnet-crypto-worker.${RuntimeVersion}.[[hash]].js"
},
{
"Identity": "${ProjectRoot}\\obj\\Debug\\${Tfm}\\build-gz\\[[_framework/dotnet.${RuntimeVersion}.[[hash]].js.gz]]",
"SourceId": "blazorwasm-minimal",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,6 @@
"${ProjectPath}\\blazorwasm\\bin\\Debug\\${Tfm}\\wwwroot\\_framework\\de\\Microsoft.CodeAnalysis.CSharp.resources.dll.gz",
"${ProjectPath}\\blazorwasm\\bin\\Debug\\${Tfm}\\wwwroot\\_framework\\de\\Microsoft.CodeAnalysis.resources.dll",
"${ProjectPath}\\blazorwasm\\bin\\Debug\\${Tfm}\\wwwroot\\_framework\\de\\Microsoft.CodeAnalysis.resources.dll.gz",
"${ProjectPath}\\blazorwasm\\bin\\Debug\\${Tfm}\\wwwroot\\_framework\\dotnet-crypto-worker.${RuntimeVersion}.[[hash]].js",
"${ProjectPath}\\blazorwasm\\bin\\Debug\\${Tfm}\\wwwroot\\_framework\\dotnet-crypto-worker.${RuntimeVersion}.[[hash]].js.gz",
"${ProjectPath}\\blazorwasm\\bin\\Debug\\${Tfm}\\wwwroot\\_framework\\dotnet.${RuntimeVersion}.[[hash]].js",
"${ProjectPath}\\blazorwasm\\bin\\Debug\\${Tfm}\\wwwroot\\_framework\\dotnet.${RuntimeVersion}.[[hash]].js.gz",
"${ProjectPath}\\blazorwasm\\bin\\Debug\\${Tfm}\\wwwroot\\_framework\\dotnet.timezones.blat",
Expand Down Expand Up @@ -676,7 +674,6 @@
"${ProjectPath}\\blazorwasm\\obj\\Debug\\${Tfm}\\build-gz\\[[_framework/cs/Microsoft.CodeAnalysis.resources.dll.gz]]",
"${ProjectPath}\\blazorwasm\\obj\\Debug\\${Tfm}\\build-gz\\[[_framework/de/Microsoft.CodeAnalysis.CSharp.resources.dll.gz]]",
"${ProjectPath}\\blazorwasm\\obj\\Debug\\${Tfm}\\build-gz\\[[_framework/de/Microsoft.CodeAnalysis.resources.dll.gz]]",
"${ProjectPath}\\blazorwasm\\obj\\Debug\\${Tfm}\\build-gz\\[[_framework/dotnet-crypto-worker.${RuntimeVersion}.[[hash]].js.gz]]",
"${ProjectPath}\\blazorwasm\\obj\\Debug\\${Tfm}\\build-gz\\[[_framework/dotnet.${RuntimeVersion}.[[hash]].js.gz]]",
"${ProjectPath}\\blazorwasm\\obj\\Debug\\${Tfm}\\build-gz\\[[_framework/dotnet.timezones.blat.gz]]",
"${ProjectPath}\\blazorwasm\\obj\\Debug\\${Tfm}\\build-gz\\[[_framework/dotnet.wasm.gz]]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3531,23 +3531,6 @@
"CopyToPublishDirectory": "Never",
"OriginalItemSpec": "${RestorePath}\\microsoft.codeanalysis.common\\[[CustomPackageVersion]]\\lib\\netstandard2.0\\de\\Microsoft.CodeAnalysis.resources.dll"
},
{
"Identity": "${ProjectRoot}\\blazorwasm\\bin\\Debug\\${Tfm}\\wwwroot\\_framework\\dotnet-crypto-worker.${RuntimeVersion}.[[hash]].js",
"SourceId": "blazorwasm",
"SourceType": "Computed",
"ContentRoot": "${ProjectRoot}\\blazorwasm\\bin\\Debug\\${Tfm}\\wwwroot\\",
"BasePath": "/",
"RelativePath": "_framework/dotnet-crypto-worker.${RuntimeVersion}.[[hash]].js",
"AssetKind": "Build",
"AssetMode": "All",
"AssetRole": "Primary",
"RelatedAsset": "",
"AssetTraitName": "BlazorWebAssemblyResource",
"AssetTraitValue": "js-module-crypto",
"CopyToOutputDirectory": "PreserveNewest",
"CopyToPublishDirectory": "Never",
"OriginalItemSpec": "${RestorePath}\\microsoft.netcore.app.runtime.mono.browser-wasm\\${RuntimeVersion}\\runtimes\\browser-wasm\\native\\dotnet-crypto-worker.js"
},
{
"Identity": "${ProjectRoot}\\blazorwasm\\bin\\Debug\\${Tfm}\\wwwroot\\_framework\\dotnet.${RuntimeVersion}.[[hash]].js",
"SourceId": "blazorwasm",
Expand Down Expand Up @@ -7543,23 +7526,6 @@
"CopyToPublishDirectory": "Never",
"OriginalItemSpec": "${ProjectRoot}\\blazorwasm\\bin\\Debug\\${Tfm}\\wwwroot\\_framework\\de\\Microsoft.CodeAnalysis.resources.dll"
},
{
"Identity": "${ProjectRoot}\\blazorwasm\\obj\\Debug\\${Tfm}\\build-gz\\[[_framework/dotnet-crypto-worker.${RuntimeVersion}.[[hash]].js.gz]]",
"SourceId": "blazorwasm",
"SourceType": "Computed",
"ContentRoot": "${ProjectRoot}\\blazorwasm\\bin\\Debug\\${Tfm}\\wwwroot\\",
"BasePath": "/",
"RelativePath": "_framework/dotnet-crypto-worker.${RuntimeVersion}.[[hash]].js.gz",
"AssetKind": "Build",
"AssetMode": "All",
"AssetRole": "Alternative",
"RelatedAsset": "${ProjectRoot}\\blazorwasm\\bin\\Debug\\${Tfm}\\wwwroot\\_framework\\dotnet-crypto-worker.${RuntimeVersion}.[[hash]].js",
"AssetTraitName": "Content-Encoding",
"AssetTraitValue": "gzip",
"CopyToOutputDirectory": "PreserveNewest",
"CopyToPublishDirectory": "Never",
"OriginalItemSpec": "${ProjectRoot}\\blazorwasm\\bin\\Debug\\${Tfm}\\wwwroot\\_framework\\dotnet-crypto-worker.${RuntimeVersion}.[[hash]].js"
},
{
"Identity": "${ProjectRoot}\\blazorwasm\\obj\\Debug\\${Tfm}\\build-gz\\[[_framework/dotnet.${RuntimeVersion}.[[hash]].js.gz]]",
"SourceId": "blazorwasm",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3378,23 +3378,6 @@
"CopyToPublishDirectory": "Never",
"OriginalItemSpec": "obj\\Debug\\${Tfm}\\blazorwasm.pdb"
},
{
"Identity": "${ProjectRoot}\\blazorwasm\\bin\\Debug\\${Tfm}\\wwwroot\\_framework\\dotnet-crypto-worker.${RuntimeVersion}.[[hash]].js",
"SourceId": "blazorwasm",
"SourceType": "Project",
"ContentRoot": "${ProjectRoot}\\blazorwasm\\bin\\Debug\\${Tfm}\\wwwroot\\",
"BasePath": "/",
"RelativePath": "_framework/dotnet-crypto-worker.${RuntimeVersion}.[[hash]].js",
"AssetKind": "Build",
"AssetMode": "All",
"AssetRole": "Primary",
"RelatedAsset": "",
"AssetTraitName": "BlazorWebAssemblyResource",
"AssetTraitValue": "js-module-crypto",
"CopyToOutputDirectory": "PreserveNewest",
"CopyToPublishDirectory": "Never",
"OriginalItemSpec": "${RestorePath}\\microsoft.netcore.app.runtime.mono.browser-wasm\\${RuntimeVersion}\\runtimes\\browser-wasm\\native\\dotnet-crypto-worker.js"
},
{
"Identity": "${ProjectRoot}\\blazorwasm\\bin\\Debug\\${Tfm}\\wwwroot\\_framework\\dotnet.${RuntimeVersion}.[[hash]].js",
"SourceId": "blazorwasm",
Expand Down Expand Up @@ -6846,23 +6829,6 @@
"CopyToPublishDirectory": "Never",
"OriginalItemSpec": "${ProjectRoot}\\blazorwasm\\bin\\Debug\\${Tfm}\\wwwroot\\_framework\\blazorwasm.pdb"
},
{
"Identity": "${ProjectRoot}\\blazorwasm\\obj\\Debug\\${Tfm}\\build-gz\\[[_framework/dotnet-crypto-worker.${RuntimeVersion}.[[hash]].js.gz]]",
"SourceId": "blazorwasm",
"SourceType": "Project",
"ContentRoot": "${ProjectRoot}\\blazorwasm\\bin\\Debug\\${Tfm}\\wwwroot\\",
"BasePath": "/",
"RelativePath": "_framework/dotnet-crypto-worker.${RuntimeVersion}.[[hash]].js.gz",
"AssetKind": "Build",
"AssetMode": "All",
"AssetRole": "Alternative",
"RelatedAsset": "${ProjectRoot}\\blazorwasm\\bin\\Debug\\${Tfm}\\wwwroot\\_framework\\dotnet-crypto-worker.${RuntimeVersion}.[[hash]].js",
"AssetTraitName": "Content-Encoding",
"AssetTraitValue": "gzip",
"CopyToOutputDirectory": "PreserveNewest",
"CopyToPublishDirectory": "Never",
"OriginalItemSpec": "${ProjectRoot}\\blazorwasm\\bin\\Debug\\${Tfm}\\wwwroot\\_framework\\dotnet-crypto-worker.${RuntimeVersion}.[[hash]].js"
},
{
"Identity": "${ProjectRoot}\\blazorwasm\\obj\\Debug\\${Tfm}\\build-gz\\[[_framework/dotnet.${RuntimeVersion}.[[hash]].js.gz]]",
"SourceId": "blazorwasm",
Expand Down
Loading