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

Please add Sample using CMake with WebView2 (with Nuget or alternative) #174

Open
nat42 opened this issue Mar 3, 2023 · 1 comment
Open

Comments

@nat42
Copy link

nat42 commented Mar 3, 2023

Trying to implement Microsoft's WebView2 is my first time attempting to use nuget with a native code C++ project (WIN32 target), and I suspect this experience is not unexpected/uncommon, as I believe nuget gets used far more with .net projects, but I note that nuget is what is recommented to use per: https://learn.microsoft.com/en-us/microsoft-edge/webview2/get-started/win32

I am generating Visual Studio solution files with CMake, and have added the following to my MakeLists.txt file:
set_property(TARGET ${PROJECT_NAME} PROPERTY VS_PACKAGE_REFERENCES "Microsoft.Web.WebView2_1.0.*;Microsoft.Windows.ImplementationLibrary_1.0.*")

I generate my solution file with:
cmake .. -G "Visual Studio 17 2022" -A Win32

The nuget packages were downloaded and the above works, except that when I open the solution and attempt to build the WebView2.h header (which should come from the nuget package) can not be found:
fatal error C1083: Cannot open include file: 'WebView2.h': No such file or directory

Microsoft endorses CMake for use with Visual Studio with C++ projects, particularly where the C++ project may also need to target other platforms or provide configuration over what is built. I think a developer would expect that they can write code to implement the Microsoft's WebView2 in a source file for the Win32 target or inside an #ifdef block that is WIN32 specific.

There is open ticket for this issue with the CMake team here: https://gitlab.kitware.com/cmake/cmake/-/issues/24103 but it sounds as though they have determined there is a nuget limitation preventing it from being made to work.

A ticket was created for the Nuget team but was rejected as being "By Design" here: NuGet/Home#12204

A Microsoft Developer Community ticket is "Under Review" for the Nuget change described here: https://developercommunity.visualstudio.com/t/Impossible-to-maintain-CC-Nuget-packa/10195731

I that the above tickets demonstrate why the provided WebView 2 Getting Started / Samples code is insufficient for this very common use case, as it would be reasonable for a developer to expect this just to work, or for an alternative to be provided (such as to using nuget for the distribution, which has been chosen by Microsoft as the way to get the headers and library code needed to build against). And kindly ask that the team add a sample where CMake is used, as the tickets above demonstrate why this is needed and not obvious.

If this is not within the purview of WebView2Samples issues, I hope that as Microsoft also chose nuget, and is the developer for nuget and Visual Studio also some communication with those other project teams can be made to find a solution.

@venki-thiyag
Copy link

Any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants