From 91ba01788d4d83475fec3aea7c830376e08585da Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 27 Jul 2021 17:53:55 -0700 Subject: [wasm] Fix Publish for Blazorwasm projects on VS17 (#56433) TL;dr `publish` fails on any blazorwasm project with VS17 A recent commit[1] moved initializing `$(_WasmIntermediateOutputPath)` from a target, to project level `PropertyGroup`. It is set as: `<_WasmIntermediateOutputPath>$([MSBuild]::NormalizeDirectory($(IntermediateOutputPath), 'wasm'))` The `NormalizeDirectory` call converts this to a full path, presumably using the current directory. Because we are setting `$(_WasmIntermediateOutputPath)` at the project level, it gets evaluated during the evaluation phase. And the current directory doesn't seem to be set to the project directory at that point in VS. So, `$(_WasmIntermediateOutputPath)` gets a wrong path like: `C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\obj\Release\net6.0\wasm`. And then when actually publishing, it fails to create this directory with: `Unable to create directory "C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\obj\Release\net6.0\wasm\". Access to the path 'C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\obj\Release\net6.0\wasm\' is denied.` Fix: Set the property in `_InitializeCommonProperties` *target*, at which point the current directory is correctly set. Note: - This doesn't seem to be reproducible outside VS - It happens only on `publish`, because that's when the wasm targets come into play. -- 1. ``` commit d574b032793ae752387d32b97ff9840de17420a2 Author: Ankit Jain Date: Mon Jul 19 01:02:01 2021 -0400 [wasm] Add support for using custom native libraries (#55797) ``` Co-authored-by: Ankit Jain --- src/mono/wasm/build/WasmApp.Native.targets | 2 -- src/mono/wasm/build/WasmApp.targets | 9 +++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/mono/wasm/build/WasmApp.Native.targets b/src/mono/wasm/build/WasmApp.Native.targets index 85d301885db..3f8ddf4d97c 100644 --- a/src/mono/wasm/build/WasmApp.Native.targets +++ b/src/mono/wasm/build/WasmApp.Native.targets @@ -39,8 +39,6 @@ - - <_WasmAssembliesInternal Remove="@(_WasmAssembliesInternal)" /> <_WasmAssembliesInternal Include="@(WasmAssembliesToBundle->Distinct())" /> diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index 534caf9025b..1ed9fb15892 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -81,8 +81,6 @@ false - - <_WasmIntermediateOutputPath>$([MSBuild]::NormalizeDirectory($(IntermediateOutputPath), 'wasm')) <_BeforeWasmBuildAppDependsOn /> @@ -96,6 +94,7 @@ + %(ResolvedRuntimePack.PackageDirectory) @@ -105,11 +104,14 @@ <_WasmRuntimePackIncludeDir>$([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackRidNativeDir), 'include')) <_WasmRuntimePackSrcDir>$([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackRidNativeDir), 'src')) + + <_WasmIntermediateOutputPath>$([MSBuild]::NormalizeDirectory($(IntermediateOutputPath), 'wasm')) + + - @@ -121,7 +123,6 @@ $([MSBuild]::NormalizeDirectory($(WasmAppDir))) - <_WasmAssembliesInternal Include="@(WasmAssembliesToBundle->Distinct())" /> -- cgit v1.2.3