Flutter 引入webview_windows插件,在已经使用$PATH 中的 nuget.exe情况下,windows端构建失败

报错

PS F:\xx\xxxx> flutter run -d windows      
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
Launching lib\main.dart on Windows in debug mode...
E:\Some software\Visual Studio\VS 2022\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(156,5): error MSB3073: ���setlocal [F:\xx\xxxx\build\windows\x64\plugins\webview_windows\webview_windows_DEPENDENCIES_DOWNLOAD.vcxproj]
E:\Some software\Visual Studio\VS 2022\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(156,5): error MSB3073: C:\Windows\System32\nuget.exe install Microsoft.Windows.ImplementationLibrary -Version 1.0.220914.1 -ExcludeVersion -OutputDirectory F:/xx/xxxx/build/windows/x64/packages [F:\xx\xxxx\build\windows\x64\plugins\webview_windows\webview_windows_DEPENDENCIES_DOWNLOAD.vcxproj] 
E:\Some software\Visual Studio\VS 2022\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(156,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [F:\xx\xxxx\build\windows\x64\plugins\webview_windows\webview_windows_DEPENDENCIES_DOWNLOAD.vcxproj]
E:\Some software\Visual Studio\VS 2022\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(156,5): error MSB3073: C:\Windows\System32\nuget.exe install Microsoft.Web.WebView2 -Version 1.0.1210.39 -ExcludeVersion -OutputDirectory F:/xx/xxxx/build/windows/x64/packages [F:\xx\xxxx\build\windows\x64\plugins\webview_windows\webview_windows_DEPENDENCIES_DOWNLOAD.vcxproj]
E:\Some software\Visual Studio\VS 2022\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(156,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [F:\xx\xxxx\build\windows\x64\plugins\webview_windows\webview_windows_DEPENDENCIES_DOWNLOAD.vcxproj]
E:\Some software\Visual Studio\VS 2022\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(156,5): error MSB3073: :cmEnd [F:\xx\xxxx\build\windows\x64\plugins\webview_windows\webview_windows_DEPENDENCIES_DOWNLOAD.vcxproj]
E:\Some software\Visual Studio\VS 2022\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(156,5): error MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone [F:\xx\xxxx\build\windows\x64\plugins\webview_windows\webview_windows_DEPENDENCIES_DOWNLOAD.vcxproj]
E:\Some software\Visual Studio\VS 2022\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(156,5): error MSB3073: :cmErrorLevel [F:\xx\xxxx\build\windows\x64\plugins\webview_windows\webview_windows_DEPENDENCIES_DOWNLOAD.vcxproj]
E:\Some software\Visual Studio\VS 2022\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(156,5): error MSB3073: exit /b %1 [F:\xx\xxxx\build\windows\x64\plugins\webview_windows\webview_windows_DEPENDENCIES_DOWNLOAD.vcxproj]
E:\Some software\Visual Studio\VS 2022\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(156,5): error MSB3073: :cmDone [F:\xx\xxxx\build\windows\x64\plugins\webview_windows\webview_windows_DEPENDENCIES_DOWNLOAD.vcxproj]
E:\Some software\Visual Studio\VS 2022\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(156,5): error MSB3073: if %errorlevel% neq 0 goto :VCEnd [F:\xx\xxxx\build\windows\x64\plugins\webview_windows\webview_windows_DEPENDENCIES_DOWNLOAD.vcxproj]
E:\Some software\Visual Studio\VS 2022\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(156,5): error MSB3073: :VCEnd�����˳�������Ϊ 1�� [F:\xx\xxxx\build\windows\x64\plugins\webview_windows\webview_windows_DEPENDENCIES_DOWNLOAD.vcxproj]

解决方法

在 Windows 上运行 Flutter 应用时遇到了 MSB3073 错误。这个错误通常与 NuGet 包的安装问题有关

错误信息表明 NuGet 无法成功安装所需的包,导致构建失败

1、使用vs打开项目
2、点击 工具 -> NuGet 包管理器 -> 程序包管理器设置
在这里插入图片描述
3、在常规中,将以下选项设置成图中所示
在这里插入图片描述
4、添加程序包源
https://www.nuget.org/api/v2/
名字可以随便取
在这里插入图片描述
5、点击确定,关闭vs

6、重新打开vs,工具 -> NuGet 包管理器 -> 程序包管理器设置 ,清除存储
在这里插入图片描述
7、删除图中框出的两项
在这里插入图片描述
8、运行命令

flutter pub get --no-example

flutter run -d windows

完结,撒花~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值