From 017484d6ab8005de2fec684c88e453f94075dc4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Wed, 22 Apr 2026 16:00:07 +0000 Subject: [PATCH] Add _WasmFrameworkCopyToOutputDirectory property to control framework asset copy Introduce a private MSBuild property _WasmFrameworkCopyToOutputDirectory that switches CopyToOutputDirectory between 'Never' (default) and 'PreserveNewest' for WASM framework/webcil static web assets in Microsoft.NET.Sdk.WebAssembly.Browser.targets. Enable it with 'PreserveNewest' in eng/testing/tests.browser.targets so library tests that run from bin/ without the static web assets middleware can still find the framework files. Fixes the regression from #126407 tracked in #127257. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- eng/testing/tests.browser.targets | 4 ++++ .../Microsoft.NET.Sdk.WebAssembly.Browser.targets | 12 +++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/eng/testing/tests.browser.targets b/eng/testing/tests.browser.targets index 794064b9e9eb28..cefc5b3b52caae 100644 --- a/eng/testing/tests.browser.targets +++ b/eng/testing/tests.browser.targets @@ -51,6 +51,10 @@ false true true + + + <_WasmFrameworkCopyToOutputDirectory>PreserveNewest true diff --git a/src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets b/src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets index bd63688adeed59..52d869fca3df6a 100644 --- a/src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets +++ b/src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets @@ -354,6 +354,12 @@ Copyright (c) .NET Foundation. All rights reserved. <_WasmBuildWebcilPath>$([MSBuild]::NormalizeDirectory($(IntermediateOutputPath), 'webcil')) <_WasmBuildTmpWebcilPath>$([MSBuild]::NormalizeDirectory($(IntermediateOutputPath), 'tmp-webcil')) + + <_WasmFrameworkCopyToOutputDirectory Condition="'$(_WasmFrameworkCopyToOutputDirectory)' == ''">Never @@ -387,7 +393,7 @@ Copyright (c) .NET Foundation. All rights reserved. SourceType="Computed" AssetKind="Build" AssetRole="Primary" - CopyToOutputDirectory="Never" + CopyToOutputDirectory="$(_WasmFrameworkCopyToOutputDirectory)" CopyToPublishDirectory="Never" FingerprintCandidates="$(_WasmFingerprintAssets)" FingerprintPatterns="@(FingerprintPatterns);@(_WasmFingerprintPatterns)" @@ -406,7 +412,7 @@ Copyright (c) .NET Foundation. All rights reserved. SourceType="Framework" AssetKind="Build" AssetRole="Primary" - CopyToOutputDirectory="Never" + CopyToOutputDirectory="$(_WasmFrameworkCopyToOutputDirectory)" CopyToPublishDirectory="Never" FingerprintCandidates="$(_WasmFingerprintAssets)" FingerprintPatterns="@(FingerprintPatterns);@(_WasmFingerprintPatterns)" @@ -435,7 +441,7 @@ Copyright (c) .NET Foundation. All rights reserved. during dotnet run — they are not copied to bin/wwwroot/_framework/ at build time. --> <_WasmMaterializedFrameworkAssets Update="@(_WasmMaterializedFrameworkAssets)" - AssetMode="All" CopyToOutputDirectory="Never" /> + AssetMode="All" CopyToOutputDirectory="$(_WasmFrameworkCopyToOutputDirectory)" />