From 468a4d549a51a86aa2ea0a3c67bf7c18abd20915 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Mon, 18 Oct 2021 12:03:59 -0400 Subject: [PATCH 1/4] [blazorwasm] Fix publishing project with lazy loaded assembly A blazorwasm project referencing a razorclasslib project, which is to be lazy loaded, fails to publish with: `error BLAZORSDK1001: Unable to find '[lazy load assembly name].dll' to be lazy loaded later. Confirm that project or package references are included and the reference is used in the project.` - This only happens when the `wasm-tools` workload is installed, irrespective of AOT. - That is because when the workload is installed, `publish+Release` defaults to relinking the runtime - The failure happens during a nested publish. 1. For the nested publish, we essentially run `Publish` target, and then the wasm native targets run 2. during the `Publish` part of it: a. we get to `ProcessPublishFilesForBlazor`, which currently we skip for the nested publish case (`$(WasmBuildingForNestedPublish)`) - and this target populates `@(StaticWebAsset)`, when run b. Then we get to `GeneratePublishBlazorBootJson`, which fails because it doesn't have the `StaticWebAssets` correctly populated, and thus can't find the lazy loaded assembly This commit fixes it by: 1. Making the nested publish run after *ComputeFilesToPublish* instead of a full `Publish`[1] 2. Disable certain targets related to static web assets, and compression, since those are not really needed for the nested publish. .. which essentially means that we run a reduced set of targets as part of the "nested publish", and don't trigger some unncessary ones. In future, this will be cleaned up. Co-authored by: @javiercn Fixes https://github.com/dotnet/runtime/issues/60479 --- 1. this needs a corresponding change in the wasm targets to enable using `ComputeFilesToPublish`, instead of `Publish`. --- .../Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets b/src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets index e17cce88b7b0..f4230c9affc5 100644 --- a/src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets +++ b/src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets @@ -72,7 +72,9 @@ Copyright (c) .NET Foundation. All rights reserved. true true false - ComputeFilesToPublish;_GatherWasmFilesToPublish;$(WasmNestedPublishAppDependsOn) + _GatherWasmFilesToPublish;$(WasmNestedPublishAppDependsOn) + false + ComputeFilesToPublish @@ -93,14 +95,14 @@ Copyright (c) .NET Foundation. All rights reserved. $(StaticWebAssetsPrepareForRunDependsOn) - + $(ResolvePublishStaticWebAssetsDependsOn); ProcessPublishFilesForBlazor; ComputeBlazorExtensions; _AddPublishBlazorBootJsonToStaticWebAssets; - + $(GenerateStaticWebAssetsPublishManifestDependsOn); GeneratePublishBlazorBootJson; From a1864acfeac89c4ce5facd9ec257658953630d2c Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Mon, 18 Oct 2021 20:50:38 +0000 Subject: [PATCH 2/4] Update src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets Co-authored-by: Larry Ewing --- .../Targets/Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets b/src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets index f4230c9affc5..61522d0ce4f5 100644 --- a/src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets +++ b/src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets @@ -102,7 +102,7 @@ Copyright (c) .NET Foundation. All rights reserved. _AddPublishBlazorBootJsonToStaticWebAssets; - + $(GenerateStaticWebAssetsPublishManifestDependsOn); GeneratePublishBlazorBootJson; From 5c3303cb9ab460383a246805cc62249e7e2b22ff Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Mon, 18 Oct 2021 20:50:46 +0000 Subject: [PATCH 3/4] Update src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets Co-authored-by: Larry Ewing --- .../Targets/Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets b/src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets index 61522d0ce4f5..838246c532ba 100644 --- a/src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets +++ b/src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets @@ -73,7 +73,7 @@ Copyright (c) .NET Foundation. All rights reserved. true false _GatherWasmFilesToPublish;$(WasmNestedPublishAppDependsOn) - false + false ComputeFilesToPublish From 25c7ac629e392c62234c03627fbbe2b6d69bbd4b Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Mon, 18 Oct 2021 21:03:52 +0000 Subject: [PATCH 4/4] Update src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets Co-authored-by: Larry Ewing --- .../Targets/Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets b/src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets index 838246c532ba..bfe6f0e4dd4c 100644 --- a/src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets +++ b/src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets @@ -74,7 +74,7 @@ Copyright (c) .NET Foundation. All rights reserved. false _GatherWasmFilesToPublish;$(WasmNestedPublishAppDependsOn) false - ComputeFilesToPublish + <_WasmNestedPublishAppPreTarget>ComputeFilesToPublish