Bug 56220 - Can't build iOS project (Xamarin.Forms) that references Autofac nuget
Summary: Can't build iOS project (Xamarin.Forms) that references Autofac nuget
Status: VERIFIED FIXED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: General ()
Version: 4.5.0 (15.2)
Hardware: PC Windows
: --- blocker
Target Milestone: 15.2.2
Assignee: Bugzilla
URL:
: 56205 ()
Depends on:
Blocks: 56457
  Show dependency tree
 
Reported: 2017-05-11 11:48 UTC by graham
Modified: 2017-08-04 15:06 UTC (History)
11 users (show)

Tags: 15.2R,VSDCItem
Is this bug a regression?: Yes
Last known good build: XamarinVS 4.4.0.34


Attachments
A test project to reproduce the issue (21.68 KB, application/x-zip-compressed)
2017-05-11 16:33 UTC, Ruben Buniatyan
Details
Example diagnostic build output (191.13 KB, application/zip)
2017-05-16 04:44 UTC, Brendan Zagaeski (Xamarin Team, assistant)
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 graham 2017-05-11 11:48:52 UTC
# Steps to reproduce
Include Autofac nuget in a Xamarin.Forms project and build iOS project. 

# Expected behavior
Project builds successfully.

# Actual behavior
iOS project build fails with error:

The item "C:\Users\...\.nuget\packages\Autofac\4.5.0\lib\netstandard1.1\Autofac.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.	... C:\Program Files (x86)\MSBuild\Xamarin\Xamarin.Apple.Sdk.targets	29	

# Supplemental info (logs, images, videos)
Downgrading Xamarin VS to 4.4 resolves the issue.

# Test environment (full version information)
Visual Studio 2015 Update 3
Xamarin.VS 4.5.0.443			  
Project enabled for Nuget 3
Comment 1 Ruben Buniatyan 2017-05-11 14:59:07 UTC
See the issue https://bugzilla.xamarin.com/show_bug.cgi?id=56205
Comment 2 graham 2017-05-11 15:12:06 UTC
@Ruben Buniatyan: That appears to be a private bug. If it contains any useful solutions could you reproduce them here? Thanks.
Comment 3 Ruben Buniatyan 2017-05-11 16:10:35 UTC
Well, the solution is not that useful, but at least, I was able to run the project. I just commented out _ResolveAssemblies target in Xamarin.Apple.Sdk.targets. I'm not sure about side effects though.
Comment 4 Ruben Buniatyan 2017-05-11 16:33:16 UTC
Created attachment 22091 [details]
A test project to reproduce the issue
Comment 5 mpr6280 2017-05-12 20:20:00 UTC
I get a similar message with AutoMapper.dll. I was unable to recreate the issue in a test solution sadly.

The item "C:\Users\...\.nuget\packages\AutoMapper\6.0.2\lib\netstandard1.3\AutoMapper.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.	UI.XamarinForms.iOS
Comment 6 Prashant [MSFT] 2017-05-15 05:42:19 UTC
*** Bug 56205 has been marked as a duplicate of this bug. ***
Comment 7 Brendan Zagaeski (Xamarin Team, assistant) 2017-05-16 02:10:07 UTC
## Off-site cross-referencing for bookkeeping

https://developercommunity.visualstudio.com/content/problem/55286/xamarinios-build-error-msb4096-referencecopylocalp.html
Comment 8 Brendan Zagaeski (Xamarin Team, assistant) 2017-05-16 04:42:07 UTC
## Possible temporary workaround

Deleting the project.json file from the App1 iOS app project in the test case from Comment 4 allows the project to build successfully.  For users who have the option to convert their iOS app projects away from using project.json for NuGet packages, this could be a way forward for the moment.




## Confirmation testing results

- Deleting the project.json file from the App1 iOS app project allows the solution to build successfully. 

- A simplified test case where ClassLibrary1 only calls `typeof(System.IO.Compression.ZipArchive)` (for example) and has the Newtonsoft.Json and System.ValueTuple packages removed is still sufficient to hit the issue.

- The unmodified test case from Comment 4 build successfully in Visual Studio on Mac.

- I was also able to hit the problem in a new test case created from scratch.  I added a project.json file to an iOS app project and then referenced a .NET Standard library that called `typeof(System.IO.Compression.ZipArchive)`.




## Steps followed to test

1. Ensure Visual Studio 2017 has the ".NET Core cross-platform development" workload installed.

2. Attempt to build the attached test case from Comment 4 in the "Debug|iPhoneSimulator" configuration.




## Regression status: Regression between the 15.1 Release and the 15.2 Release

> BAD:  Xamarin.VisualStudio 4.5.0.443 (c871575) + Xamarin.iOS 10.10.0.33 (d15-2: 3e5ac5ff) + Mono 5.0.0.100 (9667aa6) + VS 2017 version 15.2
> GOOD: Xamarin.VisualStudio 4.4.0.34  (3f99c5a) + Xamarin.iOS 10.8.0.175 (d15-1: a04678c2) + Mono 4.8.1     (22a39d7) + VS 2017 version 15.1

(Note: To test with the 15.1 Release, I added `<DebugType>Full</DebugType>` to the ClassLibrary1.csproj since the Xamarin 15.1 Release did not yet support portable .pdb debugging symbols.)




## Testing environment info (brief)



### Windows

Xamarin.VisualStudio 4.5.0.443 (c871575)

Microsoft Visual Studio Enterprise 2017 
Version 15.2 (26430.6) Release
Microsoft .NET Framework
Version 4.6.01586

Windows 10 (64-bit) Version 1607 (OS Build 14393.1198)
US English locale, US Eastern time zone



### Mac

Xamarin.iOS 10.10.0.33 (d15-2: 3e5ac5ff)
Mono 5.0.0.100 (2017-02/9667aa6)

Xcode 8.3, Build version 8E162
macOS 10.12.4
US English locale, US Eastern time zone
Comment 9 Brendan Zagaeski (Xamarin Team, assistant) 2017-05-16 04:44:27 UTC
Created attachment 22182 [details]
Example diagnostic build output
Comment 10 Ruben Buniatyan 2017-05-16 08:40:10 UTC
Unfortunately, removing project.json is not an option when referencing .NET Standard libs from Xamarin projects as Xamarin projects still use the same old .csproj format and project.json is a must in this case.
Comment 11 Greg Cadmes 2017-05-16 21:33:20 UTC
I found this link to be a temporary workaround.

http://stackoverflow.com/questions/43913048/xamarin-ios-build-error-msb4096-referencecopylocalpaths-does-not-define-a-val

However, the path to the "Xamarin.Apple.Sdk.targets" for VS2015 is located here: 'C:\Program Files (x86)\MSBuild\Xamarin'

The aforementioned link was the path for VS2017. I tried to upgrade to VS2017, but that's another disastrous story. 

So far this appears to have fixed the 'ReferenceCopyLocalPaths' issue, although not sure about what may be lurking from having modified the .targets file.

HTH
Greg
Comment 12 Brendan Zagaeski (Xamarin Team, assistant) 2017-05-24 13:17:50 UTC
## Verification status: verified fixed with Xamarin.VisualStudio 4.5.0.475 (70f1268) "Xamarin 15.2.2 release"

GOOD: Xamarin.VisualStudio 4.5.0.475 (70f1268)
BAD:  Xamarin.VisualStudio 4.5.0.443 (c871575)

This is the expected result based on the overlap of this bug with the symptoms from Bug 56457, Comment 2, and the corresponding fixes from Bug 56457, Comment 6.




## Fix location information for internal bookkeeping (from Bug 56457, Comment 6)

Fixed in 15.2.2: 846ca8f70ebf376d7b41c136afbbccd90a581d74
Fixed in master: 2fce8f00f71c75df56a7eb499fe9d5422ac84020