无法更新PCL项目中的NuGet包问题求助
Hey there, I’ve dealt with my fair share of finicky NuGet issues in Xamarin projects, so let’s walk through some practical fixes to get your TK.Customs package installed in that stubborn PCL project.
Possible Solutions to Try
Double-check your PCL’s target framework profile
TK.Customs packages often have strict compatibility requirements for PCL profiles. Head to your PCL project’s properties, open the Target frameworks section, and confirm you’re using a profile that matches the package’s needs (many versions require Profile78 or higher). If your current profile is outdated, upgrade it—just be aware this might mean adjusting dependencies in your Android/iOS projects too.Wipe your local NuGet cache
Corrupted cache files are one of the most common causes of installation failures. Open the NuGet Package Manager Console and run this command to clear everything:nuget locals all -clearThen close Visual Studio, delete the
packagesfolder in your solution directory, reopen the solution, and try reinstalling the package.Manually clean up leftover references in the project file
Sometimes old package references linger even after uninstalling. Here’s how to fix that:- Right-click your PCL project and select Unload Project.
- Right-click the unloaded project and choose Edit [YourProjectName].csproj.
- Scan for any entries related to TK.Customs (like
<Reference>tags or<PackageReference>lines) and delete them. - Save the file, reload the project, and attempt the installation again.
Inspect your solution’s NuGet.config
Navigate to your solution’s root folder and open theNuGet.configfile. Make sure your package sources are correctly configured (no typos, and the official NuGet gallery is listed). If you have custom sources that might be causing conflicts, temporarily comment them out and try installing the package once more.Install via the NuGet command line
Sometimes the Visual Studio UI hides useful error details. Try installing the package directly via the Package Manager Console:- Set your PCL project as the default in the console’s dropdown.
- Run this command (replace
[YourDesiredVersion]with the version you want):Install-Package TK.CustomMap -Version [YourDesiredVersion]
This will give you more detailed error messages if something’s still blocking the installation.
Consider migrating to .NET Standard
PCL is a legacy technology, and newer packages like TK.Customs often have better support for .NET Standard. If your project allows it, migrate your PCL to a .NET Standard library (right-click project > Properties > Target framework > switch to .NET Standard). This can resolve underlying compatibility issues that are hard to fix in PCL.
Full Error Message
[Paste your complete error message here if you haven’t already]
内容的提问来源于stack exchange,提问作者petterandersson

