VS2022中NuGet包安装/更新失败:SQLitePCLRaw.core元数据获取错误
NuGet包更新/安装失败问题排查与解决
问题现象
- 在VS2022中尝试安装新NuGet包或更新现有包时,针对目标框架为
.NETPortable,Version=v4.5,Profile=Profile75的项目XXX,获取SQLitePCLRaw.bundle_green.1.1.15依赖信息时,从本地源D:\TFS\XXX\XXX\packages读取SQLitePCLRaw.core.1.1.14元数据失败,报错Sequence contains no elements。 - 使用Package Manager Console执行
Update-Package命令强制更新所有包时,同样从nuget.org获取SQLitePCLRaw.core元数据失败,报错详情如下:
Update-Package : An error occurred while retrieving package metadata for 'SQLitePCLRaw.core' from source 'nuget.org'. Sequence contains no elements At line:1 char:1 + Update-Package + ~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Update-Package], Exception + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.UpdatePackageCommand
涉事项目文件片段
<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <PropertyGroup> <MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProjectGuid>{119FC141-E66C-48FA-A8B4-3D522E8D4D31}</ProjectGuid> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>TechAssist</RootNamespace> <AssemblyName>TechAssist</AssemblyName> <FileAlignment>512</FileAlignment> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkProfile>Profile75</TargetFrameworkProfile> <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <NuGetPackageImportStamp> </NuGetPackageImportStamp> <SccProjectName>SAK</SccProjectName> <SccLocalPath>SAK</SccLocalPath> <SccAuxPath>SAK</SccAuxPath> <SccProvider>SAK</SccProvider> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <NoWarn>CS4014;CS0168;CS1998</NoWarn> </PropertyGroup> ... <ItemGroup> <Reference Include="CarouselView.FormsPlugin.Abstractions, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\..\packages\CarouselView.FormsPlugin.5.0.2\lib\portable-net45+netcore45+wpa81+wp8+MonoAndroid10+Xamarin.iOS10\CarouselView.FormsPlugin.Abstractions.dll</HintPath> </Reference> <Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=3.17.3.35304, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <HintPath>..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.3.17.3\lib\netstandard1.1\Microsoft.IdentityModel.Clients.ActiveDirectory.dll</HintPath> </Reference> <Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory.Platform, Version=3.17.3.35304, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <HintPath>..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.3.17.3\lib\netstandard1.1\Microsoft.IdentityModel.Clients.ActiveDirectory.Platform.dll</HintPath> </Reference> <Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <HintPath>..\..\packages\Newtonsoft.Json.11.0.2\lib\portable-net45+win8+wp8+wpa81\Newtonsoft.Json.dll</HintPath> </Reference> <Reference Include="Plugin.Connectivity, Version=3.2.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\..\packages\Xam.Plugin.Connectivity.3.2.0\lib\netstandard1.0\Plugin.Connectivity.dll</HintPath> </Reference> <Reference Include="Plugin.Connectivity.Abstractions, Version=3.2.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\..\packages\Xam.Plugin.Connectivity.3.2.0\lib\netstandard1.0\Plugin.Connectivity.Abstractions.dll</HintPath> </Reference> <Reference Include="Plugin.DeviceInfo, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\..\packages\Xam.Plugin.DeviceInfo.4.1.1\lib\netstandard1.0\Plugin.DeviceInfo.dll</HintPath> </Reference> <Reference Include="Plugin.ExternalMaps, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\..\packages\Xam.Plugin.ExternalMaps.4.0.1\lib\netstandard1.0\Plugin.ExternalMaps.dll</HintPath> </Reference> <Reference Include="Plugin.ExternalMaps.Abstractions, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\..\packages\Xam.Plugin.ExternalMaps.4.0.1\lib\netstandard1.0\Plugin.ExternalMaps.Abstractions.dll</HintPath> </Reference> <Reference Include="Plugin.Geolocator, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\..\packages\Xam.Plugin.Geolocator.4.5.0.6\lib\netstandard1.0\Plugin.Geolocator.dll</HintPath> </Reference> <Reference Include="Plugin.Media, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\..\packages\Xam.Plugin.Media.4.0.1.5\lib\netstandard1.0\Plugin.Media.dll</HintPath> </Reference> <Reference Include="Plugin.Messaging, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\..\packages\Xam.Plugins.Messaging.5.2.0\lib\netstandard1.0\Plugin.Messaging.dll</HintPath> </Reference> <Reference Include="Plugin.Messaging.Abstractions, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\..\packages\Xam.Plugins.Messaging.5.2.0\lib\netstandard1.0\Plugin.Messaging.Abstractions.dll</HintPath> </Reference> <Reference Include="Plugin.Permissions, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\..\packages\Plugin.Permissions.3.0.0.12\lib\netstandard1.0\Plugin.Permissions.dll</HintPath> </Reference> <Reference Include="SignaturePad.Forms, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\..\packages\Xamarin.Controls.SignaturePad.Forms.3.0.0\lib\netstandard1.0\SignaturePad.Forms.dll</HintPath> </Reference> <Reference Include="SQLite-net"> <HintPath>..\..\packages\sqlite-net-pcl.1.6.292\lib\portable-net45+netcore45+wpa81+wp8+MonoAndroid10+MonoTouch10+Xamarin.iOS10\SQLite-net.dll</HintPath> </Reference> <Reference Include="SQLitePCLRaw.batteries_green, Version=1.1.14.520, Culture=neutral, PublicKeyToken=a84b7dcfb1391f7f, processorArchitecture=MSIL"> <HintPath>..\..\packages\SQLitePCLRaw.bundle_green.1.1.14\lib\portable-net45+netcore45+wpa81+wp8+MonoAndroid10+MonoTouch10+Xamarin.iOS10\SQLitePCLRaw.batteries_green.dll</HintPath> </Reference> <Reference Include="SQLitePCLRaw.batteries_v2, Version=1.1.14.520, Culture=neutral, PublicKeyToken=8226ea5df37bcae9, processorArchitecture=MSIL"> <HintPath>..\..\packages\SQLitePCLRaw.bundle_green.1.1.14\lib\portable-net45+netcore45+wpa81+wp8+MonoAndroid10+MonoTouch10+Xamarin.iOS10\SQLitePCLRaw.batteries_v2.dll</HintPath> </Reference> <Reference Include="SQLitePCLRaw.core, Version=1.1.14.520, Culture=neutral, PublicKeyToken=1488e028ca7ab535, processorArchitecture=MSIL"> <HintPath>..\..\packages\SQLitePCLRaw.core.1.1.14\lib\portable-net45+netcore45+wpa81+wp8+MonoAndroid10+MonoTouch10+Xamarin.iOS10\SQLitePCLRaw.core.dll</HintPath> </Reference> <Reference Include="System.Net.Http"> <HintPath>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\Xamarin.iOS\v1.0\System.Net.Http.dll</HintPath> </Reference> <Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <HintPath>..\..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\netstandard1.1\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath> </Reference> <Reference Include="System.ServiceModel" /> <Reference Include="Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\..\packages\Xamarin.Forms.2.5.1.527436\lib\portable-win+net45+wp80+win81+wpa81\Xamarin.Forms.Core.dll</HintPath> </Reference> <Reference Include="Xamarin.Forms.Platform, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\..\packages\Xamarin.Forms.2.5.1.527436\lib\portable-win+net45+wp80+win81+wpa81\Xamarin.Forms.Platform.dll</HintPath> </Reference> <Reference Include="Xamarin.Forms.Xaml, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\..\packages\Xamarin.Forms.2.5.1.527436\lib\portable-win+net45+wp80+win81+wpa81\Xamarin.Forms.Xaml.dll</HintPath> </Reference> </ItemGroup> ... <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" /> <Import Project="..\..\packages\Xamarin.Forms.2.5.1.527436\build\portable-win+net45+wp80+win81+wpa81\Xamarin.Forms.targets" Condition="Exists('..\..\packages\Xamarin.Forms.2.5.1.527436\build\portable-win+net45+wp80+win81+wpa81\Xamarin.Forms.targets')" /> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <PropertyGroup> <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> </PropertyGroup> <Error Condition="!Exists('..\..\packages\Xamarin.Forms.2.5.1.527436\build\portable-win+net45+wp80+win81+wpa81\Xamarin.Forms.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Xamarin.Forms.2.5.1.527436\build\portable-win+net45+wp80+win81+wpa81\Xamarin.Forms.targets'))" /> </Target> </Project>
解决方案
方案1:清理本地NuGet缓存
- 关闭VS2022,删除本地NuGet缓存目录(默认路径:
C:\Users\<你的用户名>\.nuget\packages),同时删除项目本地包目录D:\TFS\XXX\XXX\packages下的SQLitePCLRaw.core.1.1.14和SQLitePCLRaw.bundle_green.1.1.14文件夹。 - 重新打开VS2022,右键项目选择NuGet包管理器 -> 还原NuGet包,尝试再次更新或安装包。
方案2:手动修复项目文件中的包引用
- 卸载项目,右键编辑
.csproj文件:- 删除所有与
SQLitePCLRaw相关的Reference节点(包括SQLitePCLRaw.core、SQLitePCLRaw.batteries_green、SQLitePCLRaw.batteries_v2)。 - 删除项目文件中与
SQLitePCLRaw相关的导入或目标配置(如果存在)。
- 删除所有与
- 重新加载项目,通过NuGet包管理器重新安装
SQLitePCLRaw.bundle_green的最新兼容版本(需选择支持.NETPortable v4.5 Profile75的版本)。
方案3:检查并更新NuGet源配置
- 打开VS2022的工具 -> 选项 -> NuGet包管理器 -> 包源,确保
nuget.org源配置正确且启用;暂时禁用本地源,仅保留`
相关产品推荐
相关产品推荐

