Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to build when Microsoft.WindowsAppSDK 1.6 referenced through secondary nuget package #4807

Open
kjean667 opened this issue Oct 16, 2024 · 3 comments

Comments

@kjean667
Copy link

Describe the bug

With the latest WindowsAppSDK 1.6.240923002 it is impossible for a class library to consume a nuget package that references the WindowsAppSDK 1.6.240923002 nuget package.

Reproduction example code

The example consists of three projects:

  • WebView2LoaderBug.Lib -
    A class library that uses the WindowsAppSDK 1.6.240923002 as a nuget reference and in itself builds a nuget package named WebView2LoaderBugLibrary.
  • WebView2LoaderBug.LibWrapper -
    A class library that references the WebView2LoaderBugLibrary nuget package built by the WebView2LoaderBug.Lib project.
  • WebView2LoaderBug.App -
    A WinUI 3 desktop application that references the WebView2LoaderBug.LibWrapper project.

The project fails to build the WebView2LoaderBug.Lib project with the following compiler error output:

1>------ Rebuild All started: Project: WebView2LoaderBug.Lib, Configuration: Debug Any CPU ------
Restored C:\Users\my-user\Documents\Develop\lab\WebView2LoaderBug\WebView2LoaderBug.LibWrapper\WebView2LoaderBug.LibWrapper.csproj (in 51 ms).
Restored C:\Users\my-user\Documents\Develop\lab\WebView2LoaderBug\WebView2LoaderBug.App\WebView2LoaderBug.App.csproj (in 70 ms).
Restored C:\Users\my-user\Documents\Develop\lab\WebView2LoaderBug\WebView2LoaderBug.Lib\WebView2LoaderBug.Lib.csproj (in 88 ms).
1>WebView2LoaderBug.Lib -> C:\Users\my-user\Documents\Develop\lab\WebView2LoaderBug\WebView2LoaderBug.Lib\bin\Debug\net8.0-windows10.0.22621\WebView2LoaderBug.Lib.dll
1>The package WebView2LoaderBugLibrary.1.0.0 is missing a readme. Go to https://aka.ms/nuget/authoring-best-practices/readme to learn why package readmes are important.
1>Successfully created package 'C:\Users\my-user\Documents\Develop\lab\WebView2LoaderBug\WebView2LoaderBug.Lib\bin\WebView2LoaderBugLibrary.1.0.0.nupkg'.
2>------ Rebuild All started: Project: WebView2LoaderBug.LibWrapper, Configuration: Debug Any CPU ------
2>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(5321,5): error MSB3030: Could not copy the file "C:\Users\my-user\.nuget\packages\webview2loaderbuglibrary\1.0.0\lib\net8.0-windows10.0.22621\WebView2LoaderBug.Lib\runtimes\win-arm64\native\WebView2Loader.dll" because it was not found.
2>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(5321,5): error MSB3030: Could not copy the file "C:\Users\my-user\.nuget\packages\webview2loaderbuglibrary\1.0.0\lib\net8.0-windows10.0.22621\WebView2LoaderBug.Lib\runtimes\win-x64\native\WebView2Loader.dll" because it was not found.
2>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(5321,5): error MSB3030: Could not copy the file "C:\Users\my-user\.nuget\packages\webview2loaderbuglibrary\1.0.0\lib\net8.0-windows10.0.22621\WebView2LoaderBug.Lib\runtimes\win-x86\native\WebView2Loader.dll" because it was not found.
2>Done building project "WebView2LoaderBug.LibWrapper.csproj" -- FAILED.
3>------ Rebuild All started: Project: WebView2LoaderBug.App, Configuration: Debug x86 ------
3>C:\Users\my-user\Documents\Develop\lab\WebView2LoaderBug\WebView2LoaderBug.App\WebView2LoaderBug.App.csproj : XamlCompiler error WMC1006: Cannot resolve Assembly or Windows Metadata file 'C:\Users\my-user\Documents\Develop\lab\WebView2LoaderBug\WebView2LoaderBug.LibWrapper\bin\Debug\net8.0-windows10.0.22621\WebView2LoaderBug.LibWrapper.dll'
3>CSC : error CS0006: Metadata file 'C:\Users\my-user\Documents\Develop\lab\WebView2LoaderBug\WebView2LoaderBug.LibWrapper\bin\Debug\net8.0-windows10.0.22621\WebView2LoaderBug.LibWrapper.dll' could not be found
3>Done building project "WebView2LoaderBug.App.csproj" -- FAILED.
========== Rebuild All: 1 succeeded, 2 failed, 0 skipped ==========

The reason for using a class library wrapper to consume the nuget package is because of bug microsoft/microsoft-ui-xaml#6429.

Steps to reproduce the bug

Try to compile the given reproduction example code.

Expected behavior

The solution shall compile without any errors.

Screenshots

No response

NuGet package version

Windows App SDK 1.6.1: 1.6.240923002

Packaging type

Packaged (MSIX)

Windows version

Windows 11 version 22H2 (22621, 2022 Update)

IDE

Visual Studio 2022

Additional context

This is a regression since Microsoft.WindowsAppSDK 1.5.241001000, using .NET 7.
Reproduction example project uses .NET 8.

@oggy22
Copy link

oggy22 commented Oct 21, 2024

Hi @kjean667 ! It may be a WebView2 issue. The new WebView2 packages has been just published today. Can you try with these new versions?
https://www.nuget.org/packages/Microsoft.Web.WebView2/1.0.2849.39
https://www.nuget.org/packages/Microsoft.Web.WebView2/1.0.2895-prerelease

@kjean667
Copy link
Author

@oggy22 I tried all five permutations of adding WebView2 10.0.2849.39 and 1.0.2895-prerelease to WebView2LoaderBug.Lib and WebView2LoaderBug.LibWrapper but it did not change anything. Still same problem.

@DCorrBECare
Copy link

@kjean667 I just had the same issue as well, this workaround worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants