Remove ios, windows8, and wp8 from Xamarin Forms PCL - nuget 3.0 opt-into error?

Visual Studio-2015Nugetxamarin.formsWindows 10-Universal

Visual Studio-2015 Problem Overview


I'm working on a Xamarin Forms project. I want to target Android and Windows 10 UWP.

When I try to clean up the PCL by removing "Windows 8", "Windows Phone Silverlight 8", "Windows Phone 8.1", "Xamarin.ios", and "Xamarin.ios (classic)" from the PCL targets, I get the following nasty...

I'm really just trying to remove WP8 as I don't care about targeting it.

> The project's targets cannot be changed. The selected targets require > the project to opt-into NuGet 3.0 support, however, Visual Studio > cannot automatically do this for you. Please uninstall all NuGet > packages and try again.

How do you get a project to opt-into NuGet 3.0? Something else I should try?

environ: Xamarin Forms, VS2015

enter image description here

Thanks....

Visual Studio-2015 Solutions


Solution 1 - Visual Studio-2015

The solution that worked for me:

Uninstall Xamarin.Forms:

Right Click Solution -> Manage NuGet Packages -> Uninstall Xamarin.Forms -> Restart VS

Then remove build platforms:

Right Click Solution -> Properties -> Build -> under Targeting select Change -> Remove platform(s) -> Restart VS

Reinstall Xamarin.Forms:

Manage NuGet packages -> Search for Xamarin.Forms -> Install -> Restart VS

Solution 2 - Visual Studio-2015

Another possible solution is to rename packages.config temporarily, change the PCL settings to the new target platforms, and then change the name of packages.config back again. This worked for me on my project using VS 2015. Can't take credit for this solution, read it on a blog some time back and just posting it here in case it helps someone. If I come across the blog article again I'll post the link here.

Solution 3 - Visual Studio-2015

For me this is what fixed it: Look into packages.config file in that target project, and uninstall ALL installed packages. Then you'll be able to change the Targeting. Then re-install your packages.

Solution 4 - Visual Studio-2015

Per comments on the original question, there are a couple potential routes; one would be to try and remove all packages from the projects and make the necessary changes before re-adding them again.

Solution 5 - Visual Studio-2015

For my initial prototype I didn't want to waste time on another platforms; so:

  1. I started a new solution - "Blank App (Xamarin Forms Portable)"
  2. I used PackageManager to remove ALL packages from all projects
  3. I changed the Project Targets to exclude any Windows Mobile apps (it wanted to keep Windows 8.1; I think this was the .NET inclusion I wanted)
  4. I removed the 3 Windows projects
  5. I used PackageManager to readd "Xamarin.Forms" to all remaining projects - and it automatically added all the other packages that existed at startup

Now my solution is only (really) targeting Android and iOS ....

Solution 6 - Visual Studio-2015

If your problem is about those option showing everywhere on solution, you can simple select in solution explorer those that you don't want to show then right-click and click on "Unload Project". They will stay there increasing the project size, but they will leave from deploy list and other places.

Solution 7 - Visual Studio-2015

None of the above resolved my issue AND uninstalling nuget packages or editing the project file is NOT a solution (at least for me - talk about reference hell) but this method does work:

First, you cannot remove a single targeted platform such as win8, silverlight or asp.net core without unchecking the .NET Framework too.

When you uncheck the Windows 8 and ASP.NET Core also uncheck the .NET Framework. Do not fret, it will not present the above error message but VS will automatically recheck the .NET Framework (often a lower version) and then once completed re-add Window 8.1 after removing the others.

Once that happens, you can then remove the others subsequently. This took me a while to figure out since it is not obvious nor explained anywhere else. You do not need to uninstall Xamarin.Forms.

Solution 8 - Visual Studio-2015

The best way to disable one of the builds is in Solution Explorer, Right Click the build you don't want included like Windows or WinPhone and click Unload Project. Then the that build will change to (unavailable)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJoe HealyView Question on Stackoverflow
Solution 1 - Visual Studio-2015AKWView Answer on Stackoverflow
Solution 2 - Visual Studio-2015SteveOLearyView Answer on Stackoverflow
Solution 3 - Visual Studio-2015Elya LivshitzView Answer on Stackoverflow
Solution 4 - Visual Studio-2015PaulView Answer on Stackoverflow
Solution 5 - Visual Studio-2015James JoyceView Answer on Stackoverflow
Solution 6 - Visual Studio-2015Beto CaldasView Answer on Stackoverflow
Solution 7 - Visual Studio-2015Dave FriedelView Answer on Stackoverflow
Solution 8 - Visual Studio-2015TerryView Answer on Stackoverflow