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

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

Closed
asklar opened this issue Aug 28, 2021 · 29 comments · Fixed by #5990
Closed

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

asklar opened this issue Aug 28, 2021 · 29 comments · Fixed by #5990
Labels
area-Islands Xaml Islands feature area-WebView needs-cherrypicktorelease PR tagged for cherry-pick to the current release branch (but not yet picked) product-winui2 team-Controls Issue for the Controls team wct

Comments

@asklar
Copy link
Member

asklar commented Aug 28, 2021

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

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Aug 28, 2021
@asklar
Copy link
Member Author

asklar commented Aug 28, 2021

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
Copy link
Member Author

asklar commented Aug 28, 2021

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>

@asklar asklar changed the title Can't build C++ app with 2.7.0-prerelease.210827001 Can't build any xaml islands app with 2.7.0-prerelease.210827001 Aug 28, 2021
@jevansaks
Copy link
Member

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

@champnic
Copy link

champnic commented Sep 8, 2021

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

@StephenLPeters StephenLPeters added area-External Not owned by the WinUI team, not actionable in this repository. needs-cherrypicktorelease PR tagged for cherry-pick to the current release branch (but not yet picked) team-Controls Issue for the Controls team and removed needs-triage Issue needs to be triaged by the area owners labels Sep 14, 2021
@jonthysell
Copy link

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
Copy link

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
Copy link

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

@asklar
Copy link
Member Author

asklar commented Sep 28, 2021

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
Copy link
Member

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
Copy link
Member Author

asklar commented Sep 28, 2021

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

@jevansaks
Copy link
Member

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

<file target="build\$ID$.targets" src="MUXControls-Nuget-Common.targets"/>
<file target="buildTransitive\$ID$.targets" src="MUXControls-Nuget-Common.targets"/>

@ghost ghost removed the working on it label Sep 28, 2021
@ghost
Copy link

ghost commented Jul 13, 2022

🎉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
Copy link

ghost commented Jul 18, 2022

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

Handy links:

@sylveon
Copy link
Contributor

sylveon commented Jul 23, 2022

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

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Jul 23, 2022
@asklar
Copy link
Member Author

asklar commented Jul 23, 2022

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?

@ghost ghost removed the needs-triage Issue needs to be triaged by the area owners label Jul 23, 2022
@sylveon
Copy link
Contributor

sylveon commented Jul 23, 2022

Yes, it's set to true
image

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Jul 23, 2022
@sylveon
Copy link
Contributor

sylveon commented Jul 23, 2022

However, the build still fails

@sylveon
Copy link
Contributor

sylveon commented Jul 23, 2022

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
Copy link

champnic commented Jul 25, 2022

@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
Copy link
Contributor

sylveon commented Jul 25, 2022

@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
Copy link

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
Copy link

champnic commented Jul 26, 2022

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
Copy link
Contributor

sylveon commented Jul 26, 2022

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

@sylveon
Copy link
Contributor

sylveon commented Jul 26, 2022

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

@champnic
Copy link

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
Copy link
Member Author

asklar commented Jul 26, 2022

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:

<Import Project="$(MSBuildThisFileDirectory)..\Microsoft.UI.Xaml.props"/>

@asklar asklar reopened this Jul 26, 2022
@ghost ghost added needs-triage Issue needs to be triaged by the area owners and removed needs-triage Issue needs to be triaged by the area owners labels Jul 26, 2022
@asklar
Copy link
Member Author

asklar commented Jul 26, 2022

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 krschau added fixed-internally This bug has been fixed, and the fix will be shipped in the next version of WinUI 3. and removed needs-triage Issue needs to be triaged by the area owners area-External Not owned by the WinUI team, not actionable in this repository. labels Aug 5, 2022
@krschau krschau removed the fixed-internally This bug has been fixed, and the fix will be shipped in the next version of WinUI 3. label Aug 15, 2022
@krschau
Copy link
Contributor

krschau commented Aug 15, 2022

This issue has been resolved by #7574, and is available in the 2.8.1 release.

@krschau krschau closed this as completed Aug 15, 2022
@sylveon
Copy link
Contributor

sylveon commented Aug 17, 2022

Correct, appears fixed in 2.8.1 now, thanks!

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Aug 17, 2022
@krschau krschau removed the needs-triage Issue needs to be triaged by the area owners label Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Islands Xaml Islands feature area-WebView needs-cherrypicktorelease PR tagged for cherry-pick to the current release branch (but not yet picked) product-winui2 team-Controls Issue for the Controls team wct
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants