From cfc0a8d8849176e095beb2892115fd5c832bd9e9 Mon Sep 17 00:00:00 2001 From: Jerome Laban Date: Sat, 14 Sep 2024 23:22:52 -0400 Subject: [PATCH 1/9] fix: Adjust static assets generation sequence --- .../build/Uno.Wasm.Bootstrap.targets | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets b/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets index c9b9772e3..0baa4ed9c 100644 --- a/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets +++ b/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets @@ -237,7 +237,7 @@ @@ -287,11 +287,32 @@ WasmShellMode="$(WasmShellMode)" WebAppBasePath="$(WasmShellWebAppBasePath)" > - + + + + + + + + + $(_FilteredAotProfile) From cd3458f903c5c8475966e035ababf993ee019f72 Mon Sep 17 00:00:00 2001 From: Jerome Laban Date: Sun, 15 Sep 2024 12:30:30 -0400 Subject: [PATCH 2/9] chore: Use RelativePath and TargetPath --- src/Uno.Wasm.Bootstrap/ShellTask.cs | 24 ++++++++++++------- .../build/Uno.Wasm.Bootstrap.targets | 2 +- src/Uno.Wasm.Sample/Uno.Wasm.Sample.projitems | 8 +++---- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/Uno.Wasm.Bootstrap/ShellTask.cs b/src/Uno.Wasm.Bootstrap/ShellTask.cs index ececf6965..6e5890491 100644 --- a/src/Uno.Wasm.Bootstrap/ShellTask.cs +++ b/src/Uno.Wasm.Bootstrap/ShellTask.cs @@ -209,25 +209,31 @@ private void Cleanup() private (string fullPath, string relativePath) GetFilePaths(ITaskItem item) { - // This is for project-local defined content - var baseSourceFile = item.GetMetadata("DefiningProjectDirectory"); + if (item.GetMetadata("RelativePath") is { } relativePath && !string.IsNullOrEmpty(relativePath)) + { + Log.LogMessage(MessageImportance.Low, $"RelativePath '{relativePath}' for full path '{item.GetMetadata("FullPath")}' (ItemSpec: {item.ItemSpec})"); - if (item.GetMetadata("TargetPath") is { } targetPath && !string.IsNullOrEmpty(targetPath)) + // This case is mainly for shared projects and files out of the baseSourceFile path + return (item.GetMetadata("FullPath"), relativePath); + } + else if (item.GetMetadata("TargetPath") is { } targetPath && !string.IsNullOrEmpty(targetPath)) { - var fullPath = Path.IsPathRooted(item.ItemSpec) ? item.ItemSpec : Path.Combine(baseSourceFile, item.ItemSpec); + Log.LogMessage(MessageImportance.Low, $"TargetPath '{targetPath}' for full path '{item.GetMetadata("FullPath")}' (ItemSpec: {item.ItemSpec})"); // This is used for item remapping - return (fullPath, targetPath); + return (item.GetMetadata("FullPath"), targetPath); } else if (item.GetMetadata("Link") is { } link && !string.IsNullOrEmpty(link)) { - var fullPath = Path.IsPathRooted(item.ItemSpec) ? item.ItemSpec : Path.Combine(baseSourceFile, item.ItemSpec); + Log.LogMessage(MessageImportance.Low, $"Link '{link}' for full path '{item.GetMetadata("FullPath")}' (ItemSpec: {item.ItemSpec})"); // This case is mainly for shared projects and files out of the baseSourceFile path - return (fullPath, link); + return (item.GetMetadata("FullPath"), link); } else if (item.GetMetadata("FullPath") is { } fullPath && File.Exists(fullPath)) { + Log.LogMessage(MessageImportance.Low, $"FullPath '{fullPath}' (ItemSpec: {item.ItemSpec})"); + var sourceFilePath = item.ItemSpec; if (sourceFilePath.StartsWith(CurrentProjectPath)) @@ -242,7 +248,9 @@ private void Cleanup() } else { - return (Path.Combine(baseSourceFile, item.ItemSpec), item.ItemSpec); + Log.LogMessage(MessageImportance.Low, $"Without metadata '{item.GetMetadata("FullPath")}' (ItemSpec: {item.ItemSpec})"); + + return (item.GetMetadata("FullPath"), item.ItemSpec); } } diff --git a/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets b/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets index 0baa4ed9c..968f669df 100644 --- a/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets +++ b/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets @@ -259,7 +259,7 @@ AotProfile="$(WasmAotProfilePath)" Assembly="$(IntermediateOutputPath)$(TargetFileName)" AssemblyName="$(AssemblyName)" - Assets="@(Content);@(_UnoWasmCopyToOutputAssets)" + Assets="@(ContentWithTargetPath);@(_UnoWasmCopyToOutputAssets)" ContentExtensionsToExclude="$(WasmShellContentExtensionsToExclude)" CSPConfiguration="$(WasmShellCSPConfiguration)" CurrentProjectPath="$(MSBuildProjectDirectory)" diff --git a/src/Uno.Wasm.Sample/Uno.Wasm.Sample.projitems b/src/Uno.Wasm.Sample/Uno.Wasm.Sample.projitems index 8d930d462..0ad10c512 100644 --- a/src/Uno.Wasm.Sample/Uno.Wasm.Sample.projitems +++ b/src/Uno.Wasm.Sample/Uno.Wasm.Sample.projitems @@ -37,11 +37,11 @@ - + Package - - - + + + \ No newline at end of file From d82bc61063404242b60407a31ed31b03738b11b6 Mon Sep 17 00:00:00 2001 From: Jerome Laban Date: Sun, 15 Sep 2024 14:20:12 -0400 Subject: [PATCH 3/9] chore: Adjust pwa manifest inclusion --- src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets b/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets index 968f669df..7abb5d788 100644 --- a/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets +++ b/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets @@ -252,7 +252,10 @@ Include="@(_AllChildProjectItemsWithTargetPath)" Condition=" '%(_AllChildProjectItemsWithTargetPath.CopyToOutputDirectory)' == 'PreserveNewest' OR '%(_AllChildProjectItemsWithTargetPath.CopyToOutputDirectory)' == 'Always' " /> - + + + + Date: Sun, 15 Sep 2024 14:20:38 -0400 Subject: [PATCH 4/9] chore: Adjust mixed mode sample build --- src/Uno.Wasm.MixedModeSample/Uno.Wasm.MixedModeSample.csproj | 4 ---- src/Uno.Wasm.MixedModeSample/wwwroot/dummy.json | 3 +++ 2 files changed, 3 insertions(+), 4 deletions(-) create mode 100644 src/Uno.Wasm.MixedModeSample/wwwroot/dummy.json diff --git a/src/Uno.Wasm.MixedModeSample/Uno.Wasm.MixedModeSample.csproj b/src/Uno.Wasm.MixedModeSample/Uno.Wasm.MixedModeSample.csproj index 5331fcf43..85c1f2a1f 100644 --- a/src/Uno.Wasm.MixedModeSample/Uno.Wasm.MixedModeSample.csproj +++ b/src/Uno.Wasm.MixedModeSample/Uno.Wasm.MixedModeSample.csproj @@ -10,10 +10,6 @@ InterpreterAndAOT - - - - diff --git a/src/Uno.Wasm.MixedModeSample/wwwroot/dummy.json b/src/Uno.Wasm.MixedModeSample/wwwroot/dummy.json new file mode 100644 index 000000000..0db3279e4 --- /dev/null +++ b/src/Uno.Wasm.MixedModeSample/wwwroot/dummy.json @@ -0,0 +1,3 @@ +{ + +} From 9c150ff27af83c712f0af6f0a8f0138159f192c7 Mon Sep 17 00:00:00 2001 From: Jerome Laban Date: Sun, 15 Sep 2024 20:48:52 -0400 Subject: [PATCH 5/9] chore: Ensure execution before wasm stage init --- src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets b/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets index 7abb5d788..0f8551115 100644 --- a/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets +++ b/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets @@ -237,7 +237,7 @@ From 45430861e8b57b4160d376a5f802bebe60ad1579 Mon Sep 17 00:00:00 2001 From: Jerome Laban Date: Sun, 15 Sep 2024 21:13:16 -0400 Subject: [PATCH 6/9] chore: Adjust long path --- src/Uno.Wasm.Bootstrap/ShellTask.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Uno.Wasm.Bootstrap/ShellTask.cs b/src/Uno.Wasm.Bootstrap/ShellTask.cs index 6e5890491..12192ef91 100644 --- a/src/Uno.Wasm.Bootstrap/ShellTask.cs +++ b/src/Uno.Wasm.Bootstrap/ShellTask.cs @@ -145,7 +145,7 @@ public partial class ShellTask_v0 : Task public override bool Execute() { - IntermediateOutputPath = TryConvertLongPath(IntermediateOutputPath); + IntermediateOutputPath = IntermediateOutputPath; _intermediateAssetsPath = Path.Combine(IntermediateOutputPath, "unowwwrootassets"); Directory.CreateDirectory(_intermediateAssetsPath); From 3e6f64af2283b392ec3f9a45d03db4d685c57bf2 Mon Sep 17 00:00:00 2001 From: Jerome Laban Date: Sun, 15 Sep 2024 21:34:43 -0400 Subject: [PATCH 7/9] chore: Adjust static assets ordering --- src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets b/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets index 0f8551115..007e3298c 100644 --- a/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets +++ b/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets @@ -237,7 +237,7 @@ @@ -253,9 +253,6 @@ Condition=" '%(_AllChildProjectItemsWithTargetPath.CopyToOutputDirectory)' == 'PreserveNewest' OR '%(_AllChildProjectItemsWithTargetPath.CopyToOutputDirectory)' == 'Always' " /> - - - Date: Sun, 15 Sep 2024 22:18:14 -0400 Subject: [PATCH 8/9] chore: Adjust for duplicate static assets --- src/Uno.Wasm.Bootstrap/ShellTask.cs | 22 +++++++++++++++++++ .../build/Uno.Wasm.Bootstrap.targets | 1 + 2 files changed, 23 insertions(+) diff --git a/src/Uno.Wasm.Bootstrap/ShellTask.cs b/src/Uno.Wasm.Bootstrap/ShellTask.cs index 12192ef91..0939f13eb 100644 --- a/src/Uno.Wasm.Bootstrap/ShellTask.cs +++ b/src/Uno.Wasm.Bootstrap/ShellTask.cs @@ -79,6 +79,7 @@ public partial class ShellTask_v0 : Task [Required] public string WasmShellMode { get; set; } = ""; + public ITaskItem[] ExistingStaticWebAsset { get; set; } = []; public ITaskItem[] EmbeddedResources { get; set; } = []; @@ -161,6 +162,7 @@ public override bool Execute() GenerateIndexHtml(); GenerateEmbeddedJs(); GenerateConfig(); + RemoveDuplicateAssets(); } finally { @@ -170,6 +172,26 @@ public override bool Execute() return true; } + private void RemoveDuplicateAssets() + { + // Remove duplicate assets from the list to be exported. + // They might have been imported from the build pass. + + var existingAssets = StaticWebContent + .Where(s => ExistingStaticWebAsset.Any(e => e.ItemSpec == s.ItemSpec || e.GetMetadata("FullPath") == s.GetMetadata("FullPath"))) + .ToArray(); + + foreach (var existingAsset in existingAssets) + { + Log.LogMessage(MessageImportance.Low, $"Existing asset to remove [{existingAsset.ItemSpec}]"); + } + + // remove existingAssets from StaticWebContent + StaticWebContent = StaticWebContent + .Where(s => !existingAssets.Contains(s)) + .ToArray(); + } + private void GeneratedAOTProfile() { var useAotProfile = !GenerateAOTProfile && UseAotProfile; diff --git a/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets b/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets index 007e3298c..38cf47f61 100644 --- a/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets +++ b/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets @@ -282,6 +282,7 @@ PWAManifestFile="$(WasmPWAManifestFile)" ReferencePath="@(_UnoWasmBootstrapAssembliesForReferenceCopyLocalPaths)" RunAOTCompilation="$(RunAOTCompilation)" + ExistingStaticWebAsset="@(StaticWebAsset)" Optimize="$(Optimize)" WasmBuildNative="$(WasmBuildNative)" WasmShellMode="$(WasmShellMode)" From 7da38331e5743db2046271a63667662b37334409 Mon Sep 17 00:00:00 2001 From: Jerome Laban Date: Sun, 15 Sep 2024 23:14:55 -0400 Subject: [PATCH 9/9] chore: Adjust embedded resources lookup --- src/Uno.Wasm.Bootstrap/ShellTask.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Uno.Wasm.Bootstrap/ShellTask.cs b/src/Uno.Wasm.Bootstrap/ShellTask.cs index 0939f13eb..c24fdeaad 100644 --- a/src/Uno.Wasm.Bootstrap/ShellTask.cs +++ b/src/Uno.Wasm.Bootstrap/ShellTask.cs @@ -361,9 +361,9 @@ private void ExtractAdditionalJS() { var (fullSourcePath, relativePath) = GetFilePaths(projectResource); - if (relativePath.Contains("WasmScripts")) + if (fullSourcePath.Contains("WasmScripts")) { - var scriptName = Path.GetFileName(relativePath); + var scriptName = Path.GetFileName(fullSourcePath); Log.LogMessage($"Embedded resources JS {scriptName}"); @@ -398,9 +398,9 @@ private void ExtractAdditionalCSS() { var (fullSourcePath, relativePath) = GetFilePaths(projectResource); - if (relativePath.Contains("WasmCSS")) + if (fullSourcePath.Contains("WasmCSS")) { - var cssName = Path.GetFileName(relativePath); + var cssName = Path.GetFileName(fullSourcePath); Log.LogMessage($"Embedded CSS {cssName}");