jnschulze / flutter-webview-windows

A WebView2-powered Flutter WebView implementation for the Windows platform.
BSD 3-Clause "New" or "Revised" License
203 stars 120 forks source link

[EXCEPTION] Error during build #249

Closed MatthiasMRC closed 1 year ago

MatthiasMRC commented 1 year ago

When I build, I have this issue:

C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(149,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [C:\Users\dev\user_interface\build\windows\plugins\webview_windows\webview_windows_DEPENDENCIES_DOWNLOAD.vcxproj] C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(149,5): error MSB3073: C:\Users\m.marchione\AppData\Local\Microsoft\WinGet\Links\nuget.exe install Microsoft.Web.WebView2 -Version 1.0.1210.39 -ExcludeVersion -OutputDirectory "C:/Users/dev/user_interface/build/windows/packages" [C:\Users\dev\user_interface\build\windows\plugins\webview_windows\webview_windows_DEPENDENCIES_DOWNLOAD.vcxproj] C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(149,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [C:\Users\dev\user_interface\build\windows\plugins\webview_windows\webview_windows_DEPENDENCIES_DOWNLOAD.vcxproj] C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(149,5): error MSB3073: :cmEnd [C:\Users\dev\user_interface\build\windows\plugins\webview_windows\webview_windows_DEPENDENCIES_DOWNLOAD.vcxproj] C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(149,5): error MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone [C:\Users\dev\user_interface\build\windows\plugins\webview_windows\webview_windows_DEPENDENCIES_DOWNLOAD.vcxproj] C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(149,5): error MSB3073: :cmErrorLevel [C:\Users\dev\user_interface\build\windows\plugins\webview_windows\webview_windows_DEPENDENCIES_DOWNLOAD.vcxproj] C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(149,5): error MSB3073: exit /b %1 [C:\Users\dev\user_interface\build\windows\plugins\webview_windows\webview_windows_DEPENDENCIES_DOWNLOAD.vcxproj] C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(149,5): error MSB3073: :cmDone [C:\Users\dev\user_interface\build\windows\plugins\webview_windows\webview_windows_DEPENDENCIES_DOWNLOAD.vcxproj] C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(149,5): error MSB3073: if %errorlevel% neq 0 goto :VCEnd [C:\Users\dev\user_interface\build\windows\plugins\webview_windows\webview_windows_DEPENDENCIES_DOWNLOAD.vcxproj] C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(149,5): error MSB3073: :VCEnd" s'est arr�t�e avec le code 1. [C:\Users\dev\user_interface\build\windows\plugins\webview_windows\webview_windows_DEPENDENCIES_DOWNLOAD.vcxproj] Exception: Build process failed.

My flutter doctor:

[√] Flutter (Channel stable, 3.10.5, on Microsoft Windows [version 10.0.19045.3086], locale fr-FR) [√] Windows Version (Installed version of Windows is version 10 or higher) [!] Android toolchain - develop for Android devices (Android SDK version 33.0.2) X cmdline-tools component is missing Run path/to/sdkmanager --install "cmdline-tools;latest" See https://developer.android.com/studio/command-line for more details. X Android license status unknown. Run flutter doctor --android-licenses to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/windows#android-setup for more details. [√] Chrome - develop for the web [√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.5.1) [√] Android Studio (version 2022.1) [√] VS Code (version 1.79.2) [√] Connected device (3 available) [√] Network resources

I tried to change ccx_std like previous issue but it not working. Current I have this version: target_compile_features(${TARGET} PUBLIC cxx_std_17) change to 23 not working.

How to solve my issue ?

MatthiasMRC commented 1 year ago

I resolved my issue by following these steps:

  1. Uninstalling and reinstalling Visual Studio with the C++ and .NET desktop packages

  2. Ensuring that Visual Studio's NuGet is in the PATH, in my case:

C:\Users{your_user_name}\AppData\Local\Microsoft\WinGet\Links

  1. Verifying that the NuGetPackage directory exists:

C:\Program Files (x86)\Microsoft SDKs\NuGetPackages

  1. Allowing access to the files in this directory:

    right-click on NuGetPackage > Properties > Security > select "ALL APPLICATION PACKAGES" > Edit (in admin mode) > check all permissions.

Do the same for "ALL RESTRICTED APPLICATION PACKAGES"

  1. In PowerShell, run the command: nuget sources add -name "nuget.org" -source "https://api.nuget.org/v3/index.json"

  2. Then download the WebView2 and Implementation Library packages with the following commands: nuget install Microsoft.Web.WebView2 nuget install Microsoft.Windows.ImplementationLibrary You should not encounter any errors during the downloads.

  3. run into your project flutter clean and flutter pub get

Now, the Flutter application for Windows builds correctly, and the WebView works fine.