Bug 26079 - Setting $(AndroidUseLatestPlatformSdk)=True should NOT clear $(TargetFrameworkVersion)
Summary: Setting $(AndroidUseLatestPlatformSdk)=True should NOT clear $(TargetFramewor...
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Android ()
Version: 4.0.0 (C6)
Hardware: PC Mac OS
: High normal
Target Milestone: 4.0.0 (C6)
Assignee: Juan Marcelo Tondato
: 25534 ()
Depends on:
Reported: 2015-01-15 14:08 UTC by Jonathan Pryor
Modified: 2016-02-04 22:41 UTC (History)
12 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Jonathan Pryor 2015-01-15 14:08:28 UTC
Went through a wonderful debugging odyssey with Jason Smith wherein:

1. Have Xamarin.Android Library project.
2. Set $(AndroidUseLatestPlatformSdk)=True in Project Preferences.
3. Add a Nuget package to the project, and add the GooglePlayServices package
4. Note that Nuget will only install GooglePlayServicesLib 19.0.0

Further note that the latest NuGet package version is 22!

Attempting to install 22.0.0 will result in an error, mentioning that "MonoAndroid,v2.2" isn't supported (or something like that).

The cause for the above NuGet error is that the .csproj has an *empty* $(TargetFrameworkVersion), so Xamarin.Android.Common.targets auto-sets it to v2.2, which isn't supported by the latest GooglePlayServices package.

Visual Studio MUST NOT clear out $(TargetFrameworkVersion); during the Xamarin.Android build, if $(AndroidUseLatestPlatformSdk) is True, then $(TargetFrameworkVersion) is ignored, but for *other* utilities *outside* the Xamarin.Android build process -- like the nuget package manager! -- the $(TargetFrameworkVersion) is hugely important.

Consequently, if $(AndroidUseLatestPlatformSdk) is set to True, then $(TargetFrameworkVersion) should be set to the currently know latest version, e.g. v5.0.
Comment 1 Jonathan Pryor 2015-01-22 18:12:45 UTC
*** Bug 25534 has been marked as a duplicate of this bug. ***
Comment 2 Jeremy Kolb 2015-02-01 19:21:23 UTC
I'm hitting this same issue.  I can't figure out how to make a new android library that depends on the recyclerview.  No matter how I configure the project Nuget refuses to install the support library.
Comment 4 Daniel Cazzulino 2015-03-21 12:26:50 UTC
Ok, we found the root cause for this and we'll have a fix next week.

Also, we could also reproduce this issue with Xamarin Studio when choosing Android 2.3 or lower versions. It might be worth to also report it for that product? cc'ing Greg who might be interested to look at the XS side.
Comment 5 Mikayla Hutchinson [MSFT] 2015-03-22 03:17:00 UTC
Not really happy with thing since it will churn the csproj file, and isn't guaranteed to be 100% accurate, but I guess it's an unavoidable workaround for tools (e.g. NuGet) that read/evaluate TargetFrameworkVersion from the csproj file and aren't aware of AndroidUseLatestPlatformSdk.

We might be able to fix it better if we could compute the TargetFrameworkVersion value from property functions.
Comment 6 Jeremy Kolb 2015-03-23 09:46:17 UTC
Alternatively could you provide the Xamarin Android Platforms as nuget packages (or possibly meta packages)?  Then those version could be depended on.
Comment 11 Peter Collins 2015-04-27 16:08:51 UTC
While setting $(AndroidUseLatestPlatformSdk) to true no longer clears / overwrites any $(TargetFrameworkVersion) that exists in the .csproj, attempting to install the google play services NuGet from the PM console is still failing to install one of the dependencies in the above case that Ram has mentioned.

From what I've seen [0], this only occurs on the first installation attempt right after creating a new template. The same Installation command succeeds after closing and opening, or reloading the solution. I see no difference in the files before and after reloading the solution.

[0] http://screencast.com/t/bqhHGkmHODJn
Comment 12 Peter Collins 2015-04-27 16:30:28 UTC
I've filed bug #29439 for similar behavior I'm seeing via the `Manage NuGet Packages` window. Presumably both Comment 11 and Bug #29439 have the same cause, and we can likely resolve this bug and track the other for a future release.
Comment 14 Mohit Kheterpal 2015-06-23 13:11:18 UTC
I am getting the same behaviour with C5SR2 latest build of XVS i.e. 5.11.666, as mentioned in Peter's comment 11.

And as per comment 12, this issue is tracked in bug 29439 for future release. So, I am updating its target milestone same as in bug 29439. We will verify this issue when bug 29439 will be resolved.

Comment 15 PJ 2015-07-07 17:50:18 UTC
Mohit, can you work around 29439 and still verify the behavior after the first attempt? 

It sounds like you'll only be blocked the first time:

> this only occurs on the first installation attempt right after creating a new template. The same Installation command succeeds after closing and opening, or reloading the solution.
Comment 16 Mohit Kheterpal 2015-07-08 06:22:12 UTC
Today, I have checked this issue again using Cycle 5 Trunk XVS 3.11.755 and observed that this issue is working fine, in first attempt I am able to install Xamarin.GooglePlayServices by nuget Manager console as shown in screencast : http://www.screencast.com/t/7UA3B4A8b

Hence closing this issue.