microsoft / WindowsAppSDK

The Windows App SDK empowers all Windows desktop apps with modern Windows UI, APIs, and platform features, including back-compat support, shipped via NuGet.
https://docs.microsoft.com/windows/apps/windows-app-sdk/
MIT License
3.77k stars 317 forks source link

Unable to Update ClassLibrary to v1.6-exp2: Could not copy the file "...native_uap\Microsoft.Web.WebView2.Core.dll" because it was not found #4567

Closed ghost1372 closed 1 day ago

ghost1372 commented 1 month ago

Describe the bug

after updating my project to WASDK 1.6-exp2 i get following error in classlibrary:

MSB3030 Could not copy the file "E:\Cache\.nuget\packages\microsoft.web.webview2\1.0.2646-prerelease\build\..\\runtimes\win-anycpu\native_uap\Microsoft.Web.WebView2.Core.dll" because it was not found.

Steps to reproduce the bug

1.Update Current Project to exp2

Expected behavior

No response

Screenshots

No response

NuGet package version

Windows App SDK 1.6 Experimental 2: 1.6.240701003-experimental2

Packaging type

Packaged (MSIX), Unpackaged

Windows version

Windows 11 version 22H2 (22621, 2022 Update)

IDE

Visual Studio 2022-preview, Visual Studio 2022

Additional context

No response

DarranRowe commented 1 month ago

Well, this doesn't happen with C++ class libraries. Given the NuGet path that it is in the provided message, I am assuming that this is a C# project. Is the C# class library building as AnyCpu? Does the error go away if you build for a specific platform?

ghost1372 commented 1 month ago

Well, this doesn't happen with C++ class libraries. Given the NuGet path that it is in the provided message, I am assuming that this is a C# project. Is the C# class library building as AnyCpu? Does the error go away if you build for a specific platform?

Yes this is a c# project, No, Changing the platform has no effect and I still get the error

hippieZhou commented 1 month ago

I also met this error when I upgraded to v1.6-exp2, my solution is:

  1. install the Microsoft.Web.WebView2 package:
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2646-prerelease" />
  1. delete bin and obj folders
  2. rebuild your project
ghost1372 commented 1 month ago
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2646-prerelease" />

not worked for me

DarranRowe commented 1 month ago

Well, this doesn't happen with C++ class libraries. Given the NuGet path that it is in the provided message, I am assuming that this is a C# project. Is the C# class library building as AnyCpu? Does the error go away if you build for a specific platform?

Yes this is a c# project, No, Changing the platform has no effect and I still get the error

That wasn't quite what I asked.

When you create the C# Class Library, the project is initially configured for Any CPU.

Screenshot 2024-07-16 213209

What I was asking was, if you configure the project to use an actual platform, would it help with your problem.

Since I was in a position to test. First, I configured the class library to build as a specific platform, not Any CPU:

Screenshot 2024-07-16 214116

After doing this, the entire solution builds successfully.

Screenshot 2024-07-16 214254

But I would definitely think that this is an issue with the WebView2 NuGet package. It seems to be attempting to copy the projection and runtime unconditionally.

ghost1372 commented 1 month ago

Well, this doesn't happen with C++ class libraries. Given the NuGet path that it is in the provided message, I am assuming that this is a C# project. Is the C# class library building as AnyCpu? Does the error go away if you build for a specific platform?

Yes this is a c# project, No, Changing the platform has no effect and I still get the error

That wasn't quite what I asked.

When you create the C# Class Library, the project is initially configured for Any CPU.

What I was asking was, if you configure the project to use an actual platform, would it help with your problem.

Since I was in a position to test. First, I configured the class library to build as a specific platform, not Any CPU:

After doing this, the entire solution builds successfully.

But I would definitely think that this is an issue with the WebView2 NuGet package. It seems to be attempting to copy the projection and runtime unconditionally.

@DarranRowe @hippieZhou Tnx i was doing wrong, after adding X86 Platform, Class Library Builds successfully, however this should be fixed, exp1 does not have this problem

DarranRowe commented 1 month ago

@ghost1372 Experimental 1 doesn't have this problem because WebView2 was still part of the Windows App SDK. It is 1.6 Experimental 2 where it was removed from the Windows App SDK and referenced via a NuGet package reference. It is also understandable why WebView2 was removed from the Windows App SDK package.

And also, to quote my own post:

But I would definitely think that this is an issue with the WebView2 NuGet package. It seems to be attempting to copy the projection and runtime unconditionally.

I totally believe that this should be fixed too. The action of adding the platforms to the class library project served two purposes. The first was to track down the issue. The second is to provide a temporary workaround to this problem. It allows you to evaluate the changes and you are always able to change the class library back to Any CPU when the issue is fixed.

ghost1372 commented 1 week ago

This issue exist in v1.6-preview1, however we can fix it by installing Microsoft.Web.WebView2 nuget package version 1.0.2651.64 anyway this issue should be fixed

ghost1372 commented 1 day ago

issue fixed in v1.6-preview2 so i am closing this issue