52

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....

Joe Healy
  • 5,349
  • 3
  • 32
  • 54
  • Pardon the dumb sounding question, but have you tried removing all of the packages across the projects as it suggests before changing the settings? – Paul Jan 27 '16 at 19:20
  • 1
    dadgum, that worked good. Use 'manage nuget' packages to remove xamarin forms from PCL. Use 'manage nuget' packages to re-add xamarin forms to PCL. Rebuilt. Go into targets, bye bye WP8. Post as an 'answer' and I'll mark it for you. – Joe Healy Jan 27 '16 at 19:47
  • Route I found that I actually preferred... We'll see if it holds up. Create new Xamarin forms app. Remove ios and WP8 projects. Add new C# PCL to project - select target platforms, for me win10+android. Add nuget Xamarin.Forms reference to PCL Drag app.cs from old PCL to new one. Delete OLD PCL. Rebuild. Note packages.config now shows win10 target as well: Doc on wth these mean at http://oren.codes/2015/06/09/pcls-net-core-dnx-and-uwp/ – Joe Healy Jan 27 '16 at 19:53
  • I'm glad you found a solution. I added an answer for posterity; feel free to make edit requests if you wish. – Paul Jan 27 '16 at 21:23

8 Answers8

38

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
Community
  • 1
  • 1
AKW
  • 767
  • 6
  • 13
  • 1
    Hi how to Uninstall Xamarin.Forms:, can you please explain steps in details. I can't find this option – Jigar Parekh Jun 23 '16 at 10:59
  • I've updated my answer to include further instructions on uninstalling Xamarin.Forms. You need to right click on the solution to find Manage NuGet Packages. You can uninstall from there – AKW Jun 24 '16 at 16:07
  • where from should I remove all NuGet Packages, from PCL lib or from the windows8.1 lib? – nicks Aug 01 '16 at 11:32
  • 6
    There is no "build" under solution properties. I thought you might mean "project properties --> build", but there's no "targeting" there, either. You might also have meant "project properties --> library --> target", but that still doesn't work. After uninstalling Xamarin Forms I still get the same error. – BlueRaja - Danny Pflughoeft Aug 27 '16 at 20:24
  • This worked for me, but I had to remove a whole lot more references than just Xamarin.Forms. I uninstalled ALL packages before I was able to change the PCL library targets (maybe I didn't need to remove all, but I wasn't going to diagnose exactly which subset to remove). Be sure to keep refer back to your old package.json file so you know what packages to re-add. – bojingo Apr 03 '17 at 14:52
  • 1
    I am also facing the same issue. I don't know how to do the second step. Doesn't make sense. – Anurag Jun 15 '17 at 06:25
  • @Anuragkannan kannan see my response - it will resolve your issue for VS2017 – Dave Friedel Sep 02 '17 at 18:31
17

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.

SteveOLeary
  • 418
  • 5
  • 9
  • 1
    works especially well with the latest release of Xamarin. default profile comes out 259. no option in ide to cut it down and remove Silverlight in vs2017. "unload" project, edit it to "111", close vs2017, reopen vs2017, reload project and gtg. great tip. – Joe Healy May 07 '17 at 16:17
  • Worked like a charm! – Shimmy Weitzhandler Jul 31 '17 at 09:41
5

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.

Elya Livshitz
  • 364
  • 1
  • 5
  • 9
  • 1
    And also delete all references you may have in that project to anything else – StingyJack Feb 08 '17 at 02:44
  • Be sure to use the following command to restore the NuGet packages: "Update-Package -reinstall" and not the "Restore packages" button in Visual Studio. This is because the NuGet Restore button in Visual Studio only restores files in the packages directory (\packages folder ), but does not restore files inside your project or otherwise modify your project. – JKL Jun 30 '18 at 11:37
3

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.

Paul
  • 1,155
  • 8
  • 15
  • To change the targets of PCL project you only need to do this manipulation (remove all packages) on **this** project and not on every projects of the solution. – Joël Salamin Feb 26 '16 at 07:59
2

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 ....

James Joyce
  • 1,414
  • 16
  • 16
0

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.

Beto Caldas
  • 1,962
  • 2
  • 20
  • 23
0

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.

Dave Friedel
  • 978
  • 11
  • 19
-2

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)

Terry
  • 110
  • 1
  • 2
  • this does not answer question, the PCL targeted platforms do not change by removing a build from the solution. – Dave Friedel Sep 02 '17 at 18:29
  • Unload your project. Open the .csproj for the pcl. Change the pcl number to pcl111. close csproj. reload project. Much easier! – Joe Healy Sep 05 '17 at 16:11