Xamarin.Forms could not install package

痞子三分冷 提交于 2019-12-01 03:05:30

I had a similar issue using Visual Studio and I've found that the following combination in the PCL works:

  • .NET Framework 4.5
  • Windows Phone Silverlight 8
  • Xamarin.Android
  • Xamarin.iOS

You have created the wrong project type, you created a normal Windows app, and I assume you are targeting iOS/Android or Mac.

Create the project with the correct type and it should work correctly.

If you are using Xamarin Studio for Windows (without also having Visual Studio installed) you need to download the Portable Library Tools. See the Xamarin doc Introduction to Portable Class Libraries.

I had the same problem with my Xamarin project. The problem was, that in the portable Xamarin project Windows Phone Silverlight was set as target. The PCL project from which I created the nuget, didn't reference Silverlight as target. I don't need Silverlight, so uninstalling all nuget packages from my portable Xamarin project, removing silverlight as target and reinstalling the NuGet packages solved it.

I had similar issue using VS and I found solution here - http://forums.xamarin.com/discussion/29674/xamarin-forms-dll-cannot-be-installed

"It looks like your NuGet Package Manager needs to be upgraded. The Xamarin PCL Profiles are installed but NuGet is not recognising Xamarin.iOS as a target framework. You can update NuGet by selecting Tools - Extensions and Updates, then select the Updates tab, then select Visual Studio Gallery. Then update NuGet from there."

I have invested a lot of time trying all the solutions posted here, but none of them helped me... Here is the solution that worked for me (on Windows 10):

1.) Open your .csproj file

2.) Find the TargetFrameworkProfile entry

3.) This entry contains Profile78 for me, therefore I open the folder below

c:/Program Files (x86)/Reference Assemblies/Microsoft/Framework/.NETPortable/v4.5/Profile/Profile78/SupportedFrameworks

4.a) If the folder does not exist, then use one of the solutions posted here to install the PLC right on your PC

4.b) Unfortunately, ASP.NET and Xamarin don't like each other, therefore delete all ASP profiles from this folder. For me it was ASP.NET Core 5.0.xml. Obviously this will break your ASP.NET support in VS

5.) Restart Xamarin and have fun!

interesting reading about all that: https://forums.xamarin.com/discussion/52846/cannot-create-new-xamarin-forms-project-pcl-in-xamarin-studio-win10-vs2015

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!