52
votes

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

8
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
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
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: <package id="Xamarin.Forms" version="1.3.3.6323" targetFramework="portable45-net45+dotnet+netcore45" /> Doc on wth these mean at oren.codes/2015/06/09/pcls-net-core-dnx-and-uwpJoe Healy
I'm glad you found a solution. I added an answer for posterity; feel free to make edit requests if you wish.Paul

8 Answers

38
votes

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
17
votes

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.

5
votes

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.

3
votes

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.

2
votes

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

0
votes

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.

0
votes

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.

-2
votes

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)