Bug 56457 - System.ValueTuple dependency with 4.3.0 fails with Xamarin 10.10.0.30
Summary: System.ValueTuple dependency with 4.3.0 fails with Xamarin 10.10.0.30
Status: VERIFIED FIXED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: iOS ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: 15.2.2
Assignee: Bugzilla
URL:
: 56750 ()
Depends on: 56220
Blocks:
  Show dependency tree
 
Reported: 2017-05-15 15:21 UTC by Jerome Laban
Modified: 2017-06-07 20:57 UTC (History)
11 users (show)

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


Attachments
ValueTuple workaround (1.69 KB, text/plain)
2017-05-16 02:01 UTC, Jerome Laban
Details
Logs (1.35 KB, application/x-zip-compressed)
2017-05-23 10:59 UTC, Neha Kharbade
Details


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:
Status:
VERIFIED FIXED

Description Jerome Laban 2017-05-15 15:21:16 UTC
Using System.ValueTuple with Xamarin.iOS 10.10.0.30 forces the upgrade of the System.ValueTuple nuget package to the version 4.3.1, which in turn breaks the compatibility with previous versions of Xamarin.

This is a problem for nuget package authors, which rely on specific versions of those packages, and forcing the upgrade is not an acceptable change.

A better way for Xamarin to handle this would be to introduce a Xamarin.iOS11, to allow for library authors to target those versions.

Has a new TFM version been considered ?
Comment 1 Vincent Dondain [MSFT] 2017-05-15 17:09:59 UTC
Hi Jerome,

Could you please provide us with a full build log or/and steps to reproduce?

I fail to repro with Xamarin.iOS 10.10.0.33.

I added some code making use of ValueTuple:

```
static (int count, double sum) Tally (IEnumerable<double> values)
{
	int count = 0;
	double sum = 0.0;
	foreach (var value in values) {
		count++;
		sum += value;
	}
	return (count, sum);
}
```

I added the System.ValueTuple package, version 4.3.0 and I'm not asked to update to 4.3.1.

Note: System.ValueTuple is present in the mscorlib included with Xamarin.iOS 10.10.0.33 reducing the usefulness of the package.
Comment 2 Jerome Laban 2017-05-15 19:03:37 UTC
The issue happens when building libraries with a previous version of Xamarin. I'll build repro steps.
Comment 3 Jerome Laban 2017-05-15 19:18:39 UTC
This is the log, using Xamarin.iOS 10.10.0.33 and System.ValueTuple 4.3.0: 

   1>------ Rebuild All started: Project: App33, Configuration: Debug iPhoneSimulator ------
   1>  App33 -> c:\users\jerome.laban\documents\visual studio 2017\Projects\App33\App33\bin\iPhoneSimulator\Debug\App33.exe
   1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Xamarin.Apple.Sdk.targets(29,5): error MSB4096: The item "C:\Users\jerome.laban\.nuget\packages\System.ValueTuple\4.3.0\lib\netstandard1.0\System.ValueTuple.dll" in item list "ReferenceCopyLocalPaths" does not define a value for metadata "ResolvedFrom".  In order to use this metadata, either qualify it by specifying %(ReferenceCopyLocalPaths.ResolvedFrom), or ensure that all items in this list define a value for this metadata.
   ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========


And this is the log using a previous Xamarin (4.3.0.784):

   Error CS8137: Cannot define a class or member that utilizes tuples because the compiler required type 'System.Runtime.CompilerServices.TupleElementNamesAttribute' cannot be found. Are you missing a reference?

I just created an empty iOS project with the Tally method above, in the Main.cs Application class.
Comment 4 Jerome Laban 2017-05-16 02:01:55 UTC
Created attachment 22181 [details]
ValueTuple workaround

Here is a workaround msbuild targets that allows the conditional removal of the System.ValueTuple if the current Xamarin version is 4.5 and higher, because it already includes it in mscorlib.
Comment 5 Vincent Dondain [MSFT] 2017-05-16 08:23:53 UTC
Thanks Jerome for all these information.

I believe this bug should be reassigned to the Xamarin VS Windows team since it totally works on the Mac (:

Also your full build log might help them (not just the error).

with the exact same setup, on the Mac, I get:

```
ReferenceCopyLocalPaths=
            /Users/Vince/Projects/Test/packages/System.ValueTuple.4.3.0/lib/netstandard1.0/System.ValueTuple.dll
                    CopyLocal=true
                    FusionName=System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
                    HintPath=../packages/System.ValueTuple.4.3.0/lib/netstandard1.0/System.ValueTuple.dll
                    OriginalItemSpec=System.ValueTuple
                    ReferenceSourceTarget=ResolveAssemblyReference
                    ResolvedFrom={HintPathFromItem}
                    Version=
```

So no problem with `ReferenceCopyLocalPaths.ResolvedFrom`.

Here's my full build log: https://gist.github.com/VincentDondain/7055bfb1e7cca9246a797de94a45a4d3
Comment 6 Daniel Cazzulino 2017-05-18 13:19:26 UTC
Fixed in 15.2.2: 846ca8f70ebf376d7b41c136afbbccd90a581d74
Fixed in master: 2fce8f00f71c75df56a7eb499fe9d5422ac84020

FWIW, I couldn't repro it locally with a brand new iOS app + class library referencing ValueTuple nuget package.

Just in case, I've implemented the fix mentioned also in the SO question at http://stackoverflow.com/questions/43913048/xamarin-ios-build-error-msb4096-referencecopylocalpaths-does-not-define-a-val/44031762#44031762, which ensures the given metadata is present, just like we do with the other values.

In my testing, it was always present, so I'm guessing some other nuget package/build targets or environment is affecting the resulting item group. In any case, the fix is in place.
Comment 7 Brendan Zagaeski (Xamarin Team, assistant) 2017-05-18 18:39:42 UTC
## Bookkeeping note

I am updating the target milestone to 15.2.2 based on the planned tentative location of the candidate fix from Comment 6.  The candidate fix from Comment 6 is currently on track for inclusion in the upcoming Xamarin 15.2.2 release, tentatively scheduled for publication within the next several business days.
Comment 8 Chiranjib Mukherjee 2017-05-19 12:43:26 UTC
@Brendan Zagaeski 

Please do let us know when the desired build is ready so that the team here can verify the same on our end.

thanks
Comment 9 Neha Kharbade 2017-05-23 10:59:33 UTC
Created attachment 22387 [details]
Logs

Hello @Jerome Laban,

I am using following steps for verification of this bug, 

Steps:
1. Create IOS App in the VS.
2. Add in Nuget pkg 'System.ValueTuple' version 4.3.0 with Xamarin.iOS 10.10.0.35.
3. Build the Application.
4. The Application successfully build.
5. After that in Nuget pkg the updates list show 'System.ValueTuple' version 4.3.1.
6. Update the Nuget pkg with latest version.
7. Build the application.
8. The Application successfully build.


It would be great if anyone can review it & update me if I left any scenario/Need to follow different steps.

Please update me so that I can update status of this bug.

Environment : Microsoft Visual Studio Enterprise 2017 d15svc
Version 15.2 (26430.55) d15svc d15svc PR
VisualStudio.15.int.d15svc/15.2.0+26430.55.d15svc
Microsoft .NET Framework
Version 4.6.01055
Xamarin   4.5.0.475 (70f1268)
Xamarin.Android SDK   7.3.1.1 (bc24645)
Xamarin.iOS and Xamarin.Mac SDK   10.10.0.35 (4cffddf)
Comment 10 Brendan Zagaeski (Xamarin Team, assistant) 2017-05-24 13:28:28 UTC
> I couldn't repro it locally with a brand new iOS app + class library
> referencing ValueTuple nuget package

The Xamarin.iOS project must also include a project.json file.  This is described in the slightly earlier bug about this issue (Bug 56220), and that bug includes a test case.  I have verified the effectiveness of the candidate changes from Comment 6 using the test case from that bug, and I have updated that bug accordingly with the additional verification status for a scenario where I also confirmed hitting the issue before the fix.




## Note to the Xamarin.VisualStudio engineering team

It would be fine to mark this bug as a duplicate of Bug 56220 for precise bookkeeping if desired, but it's OK to leave them as-is too since Bug 56220 is already linked in the "Depends on" field for this bug.  Thanks!
Comment 11 Jerome Laban 2017-05-24 13:35:13 UTC
Thanks @Brendan, I'll take a look at the repro steps, will check in the next release.
Comment 12 Emanuel 2017-06-07 20:57:41 UTC
*** Bug 56750 has been marked as a duplicate of this bug. ***