CommunityToolkit / Microsoft.Toolkit.Win32

ARCHIVE - This repository contained XAML Islands wrapper controls and tooling for XAML Islands with WinUI 2, see readme for more info about XAML Islands with WinUI 3 and the WindowsAppSDK.
https://aka.ms/windowsappsdk
Other
383 stars 89 forks source link

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

Open Lohnegrim opened 4 years ago

Lohnegrim commented 4 years ago

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.

ghost commented 4 years ago

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 commented 4 years ago

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.

michael-hawker commented 4 years ago

@azchohfi I'd assume this is expected?

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

azchohfi commented 4 years ago

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.

Lohnegrim commented 4 years ago

@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.

carlossanlop commented 4 years ago

@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?

azchohfi commented 4 years ago

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.

Lohnegrim commented 4 years ago

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