Microsoft.Toolkit.Win32 icon indicating copy to clipboard operation
Microsoft.Toolkit.Win32 copied to clipboard

Build Error NETSDK1130 when using .Net 5.0 and NuGet-Package 'Microsoft.Toolkit.Forms.UI.Controls.WebView'

Open Lohnegrim opened this issue 4 years ago • 8 comments

Compiling with .Net 5.0 Preview 6 raises this Error when then NuGet-Package 'Microsoft.Toolkit.Forms.UI.Controls.WebView' (Tested with Version 6.1.1) is referenced: error NETSDK1130: Referencing a Windows Metadata component directly when targeting .NETCoreApp,Version=v5.0 is not supported. Use the C#/WinRT projection tool (https://aka.ms/cswinrt) or a provided projection for this target.

Lohnegrim avatar Jul 17 '20 16:07 Lohnegrim

Hello Lohnegrim, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌

ghost avatar Jul 17 '20 16:07 ghost

This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.

ghost avatar Aug 01 '20 17:08 ghost

@azchohfi I'd assume this is expected?

@Lohnegrim please try using WebView2 instead here, that's the supported path moving forward.

michael-hawker avatar Aug 05 '20 16:08 michael-hawker

Yes, this is expected. This package will not work as-is on DotNet5, as the old projections for winmds were removed in favor of cswinrt.

azchohfi avatar Aug 05 '20 17:08 azchohfi

@michael-hawker I tryed to create a new project with WebView2 as explained in this Link: https://docs.microsoft.com/en-us/microsoft-edge/webview2/gettingstarted/winforms but didn't get the Webview2 Control in the Toolbox. Not sure whats wrong, because I also tryed to replace 'Microsoft.Toolkit.Forms.UI.Controls.WebView' with 'Microsoft.Web.WebView2', in the project I used before, but it also didn't work (didn't find WebView2). NuGet shows the that WebView2 is installed, but everywhere else I don't see it.

Remark: The Version I installed is 0.9.579 I restarted VS multiple times, rebuild multiple times opened and closed the Designer multiple times but I don't see the WebView2.

Lohnegrim avatar Aug 05 '20 19:08 Lohnegrim

@azchohfi I think I'm seeing a similar issue to the one @Lohnegrim is seeing.

I'm trying to upgrade an old .NET Framework WinForms project to .NET 5.0. I already managed to make it successfully build after changing the csproj to consume .NET 5.0, but I want to stop using the old WebBrowser type which shows Internet Explorer. So I followed the instructions for WebView2, but after downloading the nuget package, I am unable to add the using and consume the WebView2 type.

What information would you need from me to help investigate the problem?

Edit: I think I found the problem. The documentation clearly says:

Important! Ensure you check Include prerelease, select a prerelease package in Version, and then choose Install.

While I had originally selected the checkbox "Include prerelease", I didn't specifically install a package that contained the keyword "prerelease" in its version, I installed 0.9.579, which is the one that didn't work. So after installing 0.9.579-prerelease:

  <ItemGroup>
    <PackageReference Include="Microsoft.Web.WebView2" Version="0.9.579-prerelease" />
  </ItemGroup>

WebView2 showed up in the toolbox and all the references started resolving.

Hope that helps you too, @Lohnegrim.

I have a question, @azchohfi - Why isn't the latest stable release working?

carlossanlop avatar Sep 05 '20 23:09 carlossanlop

That is a good question. Have you tried it with the new version that we shipped ~5 days ago? https://www.nuget.org/packages/Microsoft.Web.WebView2/0.9.622.11 Maybe it was fixed.

azchohfi avatar Sep 15 '20 23:09 azchohfi

Hi @azchohfi I think this may be a different issue, but I just tryed this with a new project in the latest VS2019 Version, and it didn't work. At least till I unloaded the new project and loaded it again. So I only got NuGet to Work after unloading and reloading the project, not sure why. But even so I only worked with The Preview Version, and not with the Version you linked

Lohnegrim avatar Sep 16 '20 07:09 Lohnegrim