microsoft / microsoft-ui-xaml

Windows UI Library: the latest Windows 10 native controls and Fluent styles for your applications
MIT License
6.29k stars 675 forks source link

Can't build any xaml islands app with 2.7.0-prerelease.210827001 #5793

Closed asklar closed 2 years ago

asklar commented 3 years ago

Describe the bug I upgraded a Win32 C++/WinRT app to WinUI 2.7.0-prerelease.210827001, now I get a cppwinrt error:

Rebuild started...
1>------ Rebuild All started: Project: Playground, Configuration: Debug Win32 ------
1>cppwinrt : error Type 'Microsoft.Web.WebView2.Core.CoreWebView2' could not be found
1> method: CoreWebView2
1> type: Microsoft.UI.Xaml.Controls.IWebView2
1> database: F:\xaml-islands\Playground\packages\Microsoft.UI.Xaml.2.7.0-prerelease.210827001\lib\uap10.0\Microsoft.UI.Xaml.winmd
1>F:\xaml-islands\Playground\packages\Microsoft.Windows.CppWinRT.2.0.210825.3\build\native\Microsoft.Windows.CppWinRT.targets(736,9): error MSB3073: The command ""F:\xaml-islands\Playground\packages\Microsoft.Windows.CppWinRT.2.0.210825.3\build\native\..\..\bin\"cppwinrt @"Debug\Playground.vcxproj.cppwinrt_ref.rsp"" exited with code 1.
1>Done building project "Playground.vcxproj" -- FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

Steps to reproduce the bug Create C++/WinRT app, reference latest winui nuget, build.

Note this does not require me to use WebView2 in my project - the build error happens even before any of my code gets compiled.

Version Info

NuGet package version: Microsoft.UI.Xaml 2.7.0-prerelease.210827001 latest cppwinrt version: 2.0.210825.3 mux brought in webview2 pkg: 1.0.955-prerelease

asklar commented 3 years ago

This works in a uwp cppwinrt app, but for a regular win32 app, something is not passing the webview2 winmd file to cppwinrt

``` CppWinRTMakeReferenceProjection: "F:\xaml-islands\Playground\packages\Microsoft.Windows.CppWinRT.2.0.210825.3\build\native\..\..\bin\"cppwinrt @"Debug\Playground.vcxproj.cppwinrt_ref.rsp" "F:\xaml-islands\Playground\packages\Microsoft.Windows.CppWinRT.2.0.210825.3\build\native\..\..\bin\"cppwinrt @"Debug\Playground.vcxproj.cppwinrt_ref.rsp" tool: F:\xaml-islands\Playground\packages\Microsoft.Windows.CppWinRT.2.0.210825.3\bin\cppwinrt.exe ver: 2.0.210825.3 in: F:\xaml-islands\Playground\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.1.3\lib\uap10.0\Microsoft.Toolkit.Win32.UI.XamlHost.winmd in: F:\xaml-islands\Playground\packages\Microsoft.UI.Xaml.2.7.0-prerelease.210827001\lib\uap10.0\Microsoft.UI.Xaml.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.AI.MachineLearning.MachineLearningContract\2.0.0.0\Windows.AI.MachineLearning.MachineLearningContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.AI.MachineLearning.Preview.MachineLearningPreviewContract\2.0.0.0\Windows.AI.MachineLearning.Preview.MachineLearningPreviewContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.ApplicationModel.Activation.ActivatedEventsContract\1.0.0.0\Windows.ApplicationModel.Activation.ActivatedEventsContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.ApplicationModel.Activation.ActivationCameraSettingsContract\1.0.0.0\Windows.ApplicationModel.Activation.ActivationCameraSettingsContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.ApplicationModel.Activation.ContactActivatedEventsContract\1.0.0.0\Windows.ApplicationModel.Activation.ContactActivatedEventsContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.ApplicationModel.Activation.WebUISearchActivatedEventsContract\1.0.0.0\Windows.ApplicationModel.Activation.WebUISearchActivatedEventsContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.ApplicationModel.Background.BackgroundAlarmApplicationContract\1.0.0.0\Windows.ApplicationModel.Background.BackgroundAlarmApplicationContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.ApplicationModel.Calls.Background.CallsBackgroundContract\2.0.0.0\Windows.ApplicationModel.Calls.Background.CallsBackgroundContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.ApplicationModel.Calls.CallsPhoneContract\5.0.0.0\Windows.ApplicationModel.Calls.CallsPhoneContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.ApplicationModel.Calls.CallsVoipContract\4.0.0.0\Windows.ApplicationModel.Calls.CallsVoipContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.ApplicationModel.Calls.LockScreenCallContract\1.0.0.0\Windows.ApplicationModel.Calls.LockScreenCallContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.ApplicationModel.CommunicationBlocking.CommunicationBlockingContract\2.0.0.0\Windows.ApplicationModel.CommunicationBlocking.CommunicationBlockingContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.ApplicationModel.FullTrustAppContract\1.0.0.0\Windows.ApplicationModel.FullTrustAppContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.ApplicationModel.Preview.InkWorkspace.PreviewInkWorkspaceContract\1.0.0.0\Windows.ApplicationModel.Preview.InkWorkspace.PreviewInkWorkspaceContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.ApplicationModel.Preview.Notes.PreviewNotesContract\2.0.0.0\Windows.ApplicationModel.Preview.Notes.PreviewNotesContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.ApplicationModel.Resources.Management.ResourceIndexerContract\2.0.0.0\Windows.ApplicationModel.Resources.Management.ResourceIndexerContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.ApplicationModel.Search.Core.SearchCoreContract\1.0.0.0\Windows.ApplicationModel.Search.Core.SearchCoreContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.ApplicationModel.Search.SearchContract\1.0.0.0\Windows.ApplicationModel.Search.SearchContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.ApplicationModel.SocialInfo.SocialInfoContract\2.0.0.0\Windows.ApplicationModel.SocialInfo.SocialInfoContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.ApplicationModel.StartupTaskContract\3.0.0.0\Windows.ApplicationModel.StartupTaskContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.ApplicationModel.Wallet.WalletContract\1.0.0.0\Windows.ApplicationModel.Wallet.WalletContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Devices.Custom.CustomDeviceContract\1.0.0.0\Windows.Devices.Custom.CustomDeviceContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Devices.DevicesLowLevelContract\3.0.0.0\Windows.Devices.DevicesLowLevelContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Devices.Portable.PortableDeviceContract\1.0.0.0\Windows.Devices.Portable.PortableDeviceContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Devices.Printers.Extensions.ExtensionsContract\2.0.0.0\Windows.Devices.Printers.Extensions.ExtensionsContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Devices.Printers.PrintersContract\1.0.0.0\Windows.Devices.Printers.PrintersContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Devices.Scanners.ScannerDeviceContract\1.0.0.0\Windows.Devices.Scanners.ScannerDeviceContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Devices.SmartCards.SmartCardBackgroundTriggerContract\3.0.0.0\Windows.Devices.SmartCards.SmartCardBackgroundTriggerContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Devices.SmartCards.SmartCardEmulatorContract\6.0.0.0\Windows.Devices.SmartCards.SmartCardEmulatorContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Devices.Sms.LegacySmsApiContract\1.0.0.0\Windows.Devices.Sms.LegacySmsApiContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Embedded.DeviceLockdown.DeviceLockdownContract\1.0.0.0\Windows.Embedded.DeviceLockdown.DeviceLockdownContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Foundation.FoundationContract\3.0.0.0\Windows.Foundation.FoundationContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Foundation.UniversalApiContract\8.0.0.0\Windows.Foundation.UniversalApiContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Gaming.Input.GamingInputPreviewContract\1.0.0.0\Windows.Gaming.Input.GamingInputPreviewContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Gaming.Preview.GamesEnumerationContract\2.0.0.0\Windows.Gaming.Preview.GamesEnumerationContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Gaming.UI.GameChatOverlayContract\1.0.0.0\Windows.Gaming.UI.GameChatOverlayContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Gaming.UI.GamingUIProviderContract\1.0.0.0\Windows.Gaming.UI.GamingUIProviderContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Gaming.XboxLive.StorageApiContract\1.0.0.0\Windows.Gaming.XboxLive.StorageApiContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Globalization.GlobalizationJapanesePhoneticAnalyzerContract\1.0.0.0\Windows.Globalization.GlobalizationJapanesePhoneticAnalyzerContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Graphics.Printing3D.Printing3DContract\4.0.0.0\Windows.Graphics.Printing3D.Printing3DContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Management.Deployment.Preview.DeploymentPreviewContract\1.0.0.0\Windows.Management.Deployment.Preview.DeploymentPreviewContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Management.Workplace.WorkplaceSettingsContract\1.0.0.0\Windows.Management.Workplace.WorkplaceSettingsContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Media.AppBroadcasting.AppBroadcastingContract\1.0.0.0\Windows.Media.AppBroadcasting.AppBroadcastingContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Media.AppRecording.AppRecordingContract\1.0.0.0\Windows.Media.AppRecording.AppRecordingContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Media.Capture.AppBroadcastContract\2.0.0.0\Windows.Media.Capture.AppBroadcastContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Media.Capture.AppCaptureContract\4.0.0.0\Windows.Media.Capture.AppCaptureContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Media.Capture.AppCaptureMetadataContract\1.0.0.0\Windows.Media.Capture.AppCaptureMetadataContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Media.Capture.CameraCaptureUIContract\1.0.0.0\Windows.Media.Capture.CameraCaptureUIContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Media.Capture.GameBarContract\1.0.0.0\Windows.Media.Capture.GameBarContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Media.Devices.CallControlContract\1.0.0.0\Windows.Media.Devices.CallControlContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Media.MediaControlContract\1.0.0.0\Windows.Media.MediaControlContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Media.Playlists.PlaylistsContract\1.0.0.0\Windows.Media.Playlists.PlaylistsContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Media.Protection.ProtectionRenewalContract\1.0.0.0\Windows.Media.Protection.ProtectionRenewalContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Networking.Connectivity.WwanContract\2.0.0.0\Windows.Networking.Connectivity.WwanContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Networking.NetworkOperators.LegacyNetworkOperatorsContract\1.0.0.0\Windows.Networking.NetworkOperators.LegacyNetworkOperatorsContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Networking.NetworkOperators.NetworkOperatorsFdnContract\1.0.0.0\Windows.Networking.NetworkOperators.NetworkOperatorsFdnContract.WinMD ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Networking.Sockets.ControlChannelTriggerContract\3.0.0.0\Windows.Networking.Sockets.ControlChannelTriggerContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Networking.XboxLive.XboxLiveSecureSocketsContract\1.0.0.0\Windows.Networking.XboxLive.XboxLiveSecureSocketsContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Perception.Automation.Core.PerceptionAutomationCoreContract\1.0.0.0\Windows.Perception.Automation.Core.PerceptionAutomationCoreContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Phone.PhoneContract\1.0.0.0\Windows.Phone.PhoneContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Phone.StartScreen.DualSimTileContract\1.0.0.0\Windows.Phone.StartScreen.DualSimTileContract.WinMD ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Security.EnterpriseData.EnterpriseDataContract\5.0.0.0\Windows.Security.EnterpriseData.EnterpriseDataContract.winmd cppwinrt : error Type 'Microsoft.Web.WebView2.Core.CoreWebView2' could not be found method: CoreWebView2 type: Microsoft.UI.Xaml.Controls.IWebView2 database: F:\xaml-islands\Playground\packages\Microsoft.UI.Xaml.2.7.0-prerelease.210827001\lib\uap10.0\Microsoft.UI.Xaml.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Security.ExchangeActiveSyncProvisioning.EasContract\1.0.0.0\Windows.Security.ExchangeActiveSyncProvisioning.EasContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Services.Maps.GuidanceContract\3.0.0.0\Windows.Services.Maps.GuidanceContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Services.Maps.LocalSearchContract\4.0.0.0\Windows.Services.Maps.LocalSearchContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Services.Store.StoreContract\4.0.0.0\Windows.Services.Store.StoreContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Services.TargetedContent.TargetedContentContract\1.0.0.0\Windows.Services.TargetedContent.TargetedContentContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Storage.Provider.CloudFilesContract\3.0.0.0\Windows.Storage.Provider.CloudFilesContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.System.Profile.ProfileHardwareTokenContract\1.0.0.0\Windows.System.Profile.ProfileHardwareTokenContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.System.Profile.ProfileRetailInfoContract\1.0.0.0\Windows.System.Profile.ProfileRetailInfoContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.System.Profile.ProfileSharedModeContract\2.0.0.0\Windows.System.Profile.ProfileSharedModeContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.System.Profile.SystemManufacturers.SystemManufacturersContract\3.0.0.0\Windows.System.Profile.SystemManufacturers.SystemManufacturersContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.System.SystemManagementContract\6.0.0.0\Windows.System.SystemManagementContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.System.UserProfile.UserProfileContract\2.0.0.0\Windows.System.UserProfile.UserProfileContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.System.UserProfile.UserProfileLockScreenContract\1.0.0.0\Windows.System.UserProfile.UserProfileLockScreenContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.UI.ApplicationSettings.ApplicationsSettingsContract\1.0.0.0\Windows.UI.ApplicationSettings.ApplicationsSettingsContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.UI.Core.AnimationMetrics.AnimationMetricsContract\1.0.0.0\Windows.UI.Core.AnimationMetrics.AnimationMetricsContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.UI.Core.CoreWindowDialogsContract\1.0.0.0\Windows.UI.Core.CoreWindowDialogsContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.UI.Shell.SecurityAppManagerContract\1.0.0.0\Windows.UI.Shell.SecurityAppManagerContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.UI.ViewManagement.ViewManagementViewScalingContract\1.0.0.0\Windows.UI.ViewManagement.ViewManagementViewScalingContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.UI.WebUI.Core.WebUICommandBarContract\1.0.0.0\Windows.UI.WebUI.Core.WebUICommandBarContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.UI.Xaml.Core.Direct.XamlDirectContract\2.0.0.0\Windows.UI.Xaml.Core.Direct.XamlDirectContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.UI.Xaml.Hosting.HostingContract\4.0.0.0\Windows.UI.Xaml.Hosting.HostingContract.winmd ref: C:\Program Files (x86)\Windows Kits\10\References\10.0.18362.0\Windows.Web.Http.Diagnostics.HttpDiagnosticsContract\2.0.0.0\Windows.Web.Http.Diagnostics.HttpDiagnosticsContract.winmd out: F:\xaml-islands\Playground\Debug\Generated Files\ ```
asklar commented 3 years ago

The problem seems to come from the webview2 pkg. In \packages\Microsoft.Web.WebView2.1.0.955-prerelease\build\Common.targets, it says:

  <ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'UAP'">
    <Reference Include="$(MSBuildThisFileDirectory)..\lib\Microsoft.Web.WebView2.Core.winmd">
      <Implementation>Microsoft.Web.WebView2.Core.dll</Implementation>
    </Reference>
    <ReferenceCopyLocalPaths Include="$(MSBuildThisFileDirectory)..\runtimes\win-$(EffectivePlatform)\native_uap\Microsoft.Web.WebView2.Core.dll" />
    <SDKReference Include="Microsoft.VCLibs.Desktop, Version=14.0"/>
  </ItemGroup>

However this won't be evaluated for non-UWP apps like win32 xaml islands apps.

Putting this in the xaml islands project seems to get it building:

  <PropertyGroup>
    <EffectivePlatform>$(Platform)</EffectivePlatform>
    <EffectivePlatform Condition="'$(Platform)' == 'Win32'">x86</EffectivePlatform>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="packages\Microsoft.Web.WebView2.1.0.955-prerelease\lib\Microsoft.Web.WebView2.Core.winmd">
      <Implementation>Microsoft.Web.WebView2.Core.dll</Implementation>
    </Reference>
    <ReferenceCopyLocalPaths Include="packages\Microsoft.Web.WebView2.1.0.955-prerelease\runtimes\win-$(EffectivePlatform)\native_uap\Microsoft.Web.WebView2.Core.dll" />
  </ItemGroup>
jevansaks commented 3 years ago

Thanks @asklar for identifying the issue. I've sent mail to the WebView2 nupkg owners to ask them to fix this.

champnic commented 3 years ago

Hey @asklar - I've opened this issue in the WebView2Feedback repo and will follow-up there. Thanks!

jonthysell commented 2 years ago

It looks like both the official 2.7 and the latest prerelease (https://www.nuget.org/packages/Microsoft.UI.Xaml/2.7.0-prerelease.210913003) no longer directly depend on WebView2 and so this no longer repros (unless you manually add a dependency on a still broken version of WebView2 package)

jonthysell commented 2 years ago

It looks like the latest WebView2 prerelease tries to fix the missing winmd: https://www.nuget.org/packages/Microsoft.Web.WebView2/1.0.1018-prerelease

But you have to specify <WebView2UseWinRT>true</WebView2UseWinRT> in your project files.

champnic commented 2 years ago

@jonthysell Yes that's correct. The intent is to then have the WinUI package default to setting <WebView2UseWinRT>true</WebView2UseWinRT>.

asklar commented 2 years ago

yes. We need to update the docs to explain this. Not sure if this should be in this repo as a note, or in the winui readme that gets created when you add the nuget package to a project, or the xaml islands docs. @jevansaks @champnic thoughts?

jevansaks commented 2 years ago

Now that the property is available, we should just add that property to the WinUI2 nupkg targets. Something like:

<WebView2UseWinRT Condition="'$(WebView2UseWinRT)' ==''">true</WebView2UseWinRT>

@asklar can you hack your WinUI2 targets locally and see if that would address it?

asklar commented 2 years ago

@jevansaks 'tis working. PR here https://github.com/microsoft/microsoft-ui-xaml/pull/5990 (please double check me that the packaging will convert the file the change is in into microsoft.ui.xaml.targets)

jevansaks commented 2 years ago

@jevansaks 'tis working. PR here #5990 (please double check me that the packaging will convert the file the change is in into microsoft.ui.xaml.targets)

Thanks! Yes the nuspec renames it:

https://github.com/microsoft/microsoft-ui-xaml/blob/af57e7f3d206a748796e8311602f01fc667b92b5/build/NuSpecs/MUXControls.nuspec#L36-L37

ghost commented 2 years ago

:tada:This issue was addressed in #5990, which has now been successfully released as Microsoft.UI.Xaml v2.8.0-prerelease.220712001.:tada:

Handy links:

ghost commented 2 years ago

:tada:This issue was addressed in #5990, which has now been successfully released as Microsoft.UI.Xaml v2.8.0.:tada:

Handy links:

sylveon commented 2 years ago

I just hit this while upgrading to 2.8 from 2.7. This issue is not fixed.

asklar commented 2 years ago

I just hit this while upgrading to 2.8 from 2.7. This issue is not fixed.

can you check in the binlog if WebView2UseWinRT is being set to true?

sylveon commented 2 years ago

Yes, it's set to true image

sylveon commented 2 years ago

However, the build still fails

sylveon commented 2 years ago

It's easy to reproduce as well. Simply creating a new C++ console project, then installing C++/WinRT and WinUI 2.8 via NuGet, will produce the following error:

Build started...
1>------ Build started: Project: ConsoleApplication95, Configuration: Debug x64 ------
1>cppwinrt : error Type 'Microsoft.Web.WebView2.Core.CoreWebView2' could not be found
1> method: CoreWebView2
1> type: Microsoft.UI.Xaml.Controls.IWebView2
1> database: T:\Projects\ConsoleApplication95\packages\Microsoft.UI.Xaml.2.8.0\lib\uap10.0\Microsoft.UI.Xaml.winmd
1>T:\Projects\ConsoleApplication95\packages\Microsoft.Windows.CppWinRT.2.0.220608.4\build\native\Microsoft.Windows.CppWinRT.targets(741,9): error MSB3073: The command ""T:\Projects\ConsoleApplication95\packages\Microsoft.Windows.CppWinRT.2.0.220608.4\build\native\..\..\bin\"cppwinrt @"x64\Debug\ConsoleApplication95.vcxproj.cppwinrt_ref.rsp"" exited with code 1.
1>Done building project "ConsoleApplication95.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
champnic commented 2 years ago

@sylveon Which version of WebView2 nuget is being used by your app? If you use an earlier preview 2.8 WinUI version or older WebView2 version does it work, or do you get the same error?

sylveon commented 2 years ago

@champnic My app does not directly use WV2, it is brought in as a transitive dependency of WinUI 2.8

If I install WinUI 2.8 from Visual Studio's package manager, it automatically installs Microsoft.Web.Webview2 version 1.0.1264.42. I cannot install an older version of the WV2 NuGet without VS also forcing me to downgrade to WinUI 2.7.2 (in which case I wouldn't need the WV2 NuGet at all).

However, upgrading WebView2 to 1.0.1305-prerelease works. Installing WinUI 2.8.0-prerelease.220601001 and older works as well, and this brings in WV2 1.0.1020.30.

I am told by WV2 and WinUI 2 docs to avoid using prerelease versions to ship production apps. Prerelease WinUI 2.8 also is missing some bug fixes, and ships itself entirely with my app, turning a 2MB app download into a ~30MB one (a 1400% increase), so prerelease versions are undesirable to ship the final production app.

champnic commented 2 years ago

Thanks @sylveon! I wasn't trying to suggest using a prerelease package long-term, but just wanted info that would help us narrow down when the issue was introduced. At this point my best guess is that there is some difference between the release and prerelease versions of the WebView2 SDKs that is causing this - I'll take a look at what the differences are.

champnic commented 2 years ago

Weird - it works if I update to 1.0.305-prerelease, build, and then downgrade to 1.0.1264.42, even after running "Clean" and deleting the build folder. Do you see the same thing @sylveon?

sylveon commented 2 years ago

Weird, it even seems to reproduce across projects, so now installing WinUI 2.8 on a new project "just works"

sylveon commented 2 years ago

NVM the part about cross-project, I had forgot to install cppwinrt. I can reproduce this on a brand new project.

champnic commented 2 years ago

It seems to be ordering dependent. As long as the build system evaluates WebView2 .targets file after the XAML .targets file it builds fine. I can upgrade to 1.0.305-prerelease and downgrade WITHOUT building in between, and it starts working fine.

asklar commented 2 years ago

I think I see what the problem is.

When you add a nuget package reference, VS will add imports for the package’s props and targets. Props go at the top, targets at the bottom.

Neither WinUI nor webview have a props file in the right location in the package (in build\native), for whatever reason, only targets. The WinUI targets import a props file from a directory above.

This means that it’s possible for webview2’s targets to be imported before winui’s targets (and therefore the winui props), rendering the project unbuildable.

I think the right solution is for WinUI to move its props file to the build/native directory, and remove the weird Import: https://github.com/microsoft/microsoft-ui-xaml/blob/a43efca645ce0a01ea5565a07135d867452b581e/build/NuSpecs/MUXControls-Nuget-FrameworkPackage.targets#L11

asklar commented 2 years ago

for the time being, a workaround is to switch the order of these lines in your vcxproj:

-    <Import Project="packages\Microsoft.Web.WebView2.1.0.1264.42\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('packages\Microsoft.Web.WebView2.1.0.1264.42\build\native\Microsoft.Web.WebView2.targets')" />
    <Import Project="packages\Microsoft.UI.Xaml.2.8.0\build\native\Microsoft.UI.Xaml.targets" Condition="Exists('packages\Microsoft.UI.Xaml.2.8.0\build\native\Microsoft.UI.Xaml.targets')" />
+    <Import Project="packages\Microsoft.Web.WebView2.1.0.1264.42\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('packages\Microsoft.Web.WebView2.1.0.1264.42\build\native\Microsoft.Web.WebView2.targets')" />
krschau commented 2 years ago

This issue has been resolved by https://github.com/microsoft/microsoft-ui-xaml/pull/7574, and is available in the 2.8.1 release.

sylveon commented 2 years ago

Correct, appears fixed in 2.8.1 now, thanks!