From efebf202a4a9bd78702bf4bf28a027f093e15d89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Fri, 26 Jul 2024 13:36:21 +0200 Subject: [PATCH] [browser] Fix computing destination sub path and publish extension target path in Wasm SDK (#105458) --- .../AssetsComputingHelper.cs | 4 +++- .../GenerateWasmBootJson.cs | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/AssetsComputingHelper.cs b/src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/AssetsComputingHelper.cs index 6885bf62343c7..b7bdbd752edb8 100644 --- a/src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/AssetsComputingHelper.cs +++ b/src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/AssetsComputingHelper.cs @@ -107,7 +107,9 @@ public static string GetCandidateRelativePath(ITaskItem candidate, bool fingerpr { fileName = Path.GetFileNameWithoutExtension(destinationSubPath); extension = Path.GetExtension(destinationSubPath); - subPath = destinationSubPath.Substring(fileName.Length + extension.Length); + subPath = Path.GetDirectoryName(destinationSubPath); + if (!string.IsNullOrEmpty(subPath)) + subPath += "/"; } string relativePath; diff --git a/src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/GenerateWasmBootJson.cs b/src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/GenerateWasmBootJson.cs index 748671aeec898..eaaf55c20ae93 100644 --- a/src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/GenerateWasmBootJson.cs +++ b/src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/GenerateWasmBootJson.cs @@ -336,7 +336,7 @@ public void WriteBootJson(Stream output, string entryAssemblyName) resourceList = new(); resourceData.extensions[extensionName] = resourceList; } - var targetPath = resource.GetMetadata("TargetPath"); + var targetPath = endpointByAsset[resource.ItemSpec].ItemSpec; Debug.Assert(!string.IsNullOrEmpty(targetPath), "Target path for '{0}' must exist.", resource.ItemSpec); AddResourceToList(resource, resourceList, targetPath); continue; @@ -431,7 +431,7 @@ void AddResourceToList(ITaskItem resource, ResourceHashesByNameDictionary resour { if (!resourceList.ContainsKey(resourceKey)) { - Log.LogMessage(MessageImportance.Low, "Added resource '{0}' to the manifest.", resource.ItemSpec); + Log.LogMessage(MessageImportance.Low, "Added resource '{0}' with key '{1}' to the manifest.", resource.ItemSpec, resourceKey); resourceList.Add(resourceKey, $"sha256-{resource.GetMetadata("Integrity")}"); } }