Bug 22636 - Build fails with failure to resolve System.Runtime.Versioning.FrameworkName
Summary: Build fails with failure to resolve System.Runtime.Versioning.FrameworkName
Status: VERIFIED FIXED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: iOS ()
Version: 3.5
Hardware: PC Mac OS
: High major
Target Milestone: 3.5
Assignee: Adrian Alonso
URL:
Depends on:
Blocks:
 
Reported: 2014-09-04 09:38 UTC by Allie Miller
Modified: 2014-12-14 05:34 UTC (History)
19 users (show)

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


Attachments
TestProjectRepro (10.84 KB, application/zip)
2014-09-04 14:00 UTC, Adrian Alonso
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 Allie Miller 2014-09-04 09:38:21 UTC
*Overview"

After updating to Xamarin for VS 3.5.55.0, attempting to build a pre-existing iOS project fails with the following error:

ErrorMessage: Failed to resolve "System.Runtime.Versioning.FrameworkName" reference from "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets 319 3 Econ-i

*Additional Information*
Logs from Visual Studio attached

*Versioning Information*
Microsoft Visual Studio Ultimate 2013
Version 12.0.30723.00 Update 3
Microsoft .NET Framework
Version 4.5.51641

Installed Version: Ultimate

Architecture and Modeling Tools 06181-004-0452003-02967
Microsoft Architecture and Modeling Tools

UML® and Unified Modeling Language™ are trademarks or registered trademarks of the Object Management Group, Inc. in the United States and other countries.

LightSwitch for Visual Studio 2013 06181-004-0452003-02967
Microsoft LightSwitch for Visual Studio 2013

Team Explorer for Visual Studio 2013 06181-004-0452003-02967
Microsoft Team Explorer for Visual Studio 2013

Visual Basic 2013 06181-004-0452003-02967
Microsoft Visual Basic 2013

Visual C# 2013 06181-004-0452003-02967
Microsoft Visual C# 2013

Visual C++ 2013 06181-004-0452003-02967
Microsoft Visual C++ 2013

Visual F# 2013 06181-004-0452003-02967
Microsoft Visual F# 2013

Visual Studio 2013 Code Analysis Spell Checker 06181-004-0452003-02967
Microsoft® Visual Studio® 2013 Code Analysis Spell Checker

Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.

The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.

Windows Phone SDK 8.0 - ENU 06181-004-0452003-02967
Windows Phone SDK 8.0 - ENU

Application Insights Tools for Visual Studio Package 1.0
Application Insights Tools for Visual Studio

ASP.NET<http://ASP.NET>; and Web Tools 12.3.50717.0
Microsoft Web Developer Tools contains the following components:
Support for creating and opening ASP.NET<http://ASP.NET>; web projects
Browser Link: A communication channel between Visual Studio and browsers
Editor extensions for HTML, CSS, and JavaScript
Page Inspector: Inspection tool for ASP.NET<http://ASP.NET>; web projects
Scaffolding: A framework for building and running code generators
Server Explorer extensions for Microsoft Azure Websites
Web publishing: Extensions for publishing ASP.NET<http://ASP.NET>; web projects to hosting providers, on-premises servers, or Microsoft Azure

ASP.NET<http://ASP.NET>; Web Frameworks and Tools 2012.2 4.1.21001.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET<http://ASP.NET>; Web Frameworks and Tools 2013 5.2.20703.0
For additional information, visit http://www.asp.net/

Common Azure Tools 1.2
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

JetBrains ReSharper 8.2.1 Full Edition build 8.2.1000.4556 on 2014-05-19T02:12:38
JetBrains ReSharper 8.2.1 package for Microsoft Visual Studio. For more information about ReSharper, visit http://www.jetbrains.com/resharper/. Copyright © 2003–2014 JetBrains, Inc.

Microsoft Advertising SDK for Windows Phone
Microsoft Advertising SDK for Windows Phone
Build

Microsoft Azure Mobile Services Tools 1.2
Microsoft Azure Mobile Services Tools

Microsoft Azure Tools 2.4
Microsoft Azure Tools for Microsoft Visual Studio 2013 - v2.4.20730.1601

NuGet Package Manager 2.8.50313.46
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

Office Developer Tools for Visual Studio 2013 ENU 12.0.30626
Microsoft Office Developer Tools for Visual Studio 2013 ENU

PowerShell Tools 1.2
Provides file classification services using PowerShell

PreEmptive Analytics Visualizer 1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SQL Server Data Tools 12.0.40706.0
Microsoft SQL Server Data Tools

Windows Phone 8.1 SDK Integration 1.0
This package integrates the tools for the Windows Phone 8.1 SDK into the menus and controls of Visual Studio.

Workflow Manager Tools 1.0 1.0
This package contains the necessary Visual Studio integration components for Workflow Manager.

Xamarin 3.5.55.0 (2db5ccd228887372e207e112bc3b5f1b16b24293)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android
Comment 4 PJ 2014-09-04 10:13:28 UTC
Adding this for consideration to 3.6.
Comment 5 Akhilesh kumar 2014-09-04 12:13:05 UTC
I have tried to reproduce this issue by updating my builds from (XVS 3.3.47 and XI 7.2.6.28) to (XVS 3.5.55 + XI 7.4.0.108). But I am able to build and run iOS pre-existing(created with XVS 3.3.47 and XI 7.2.6.28) app successfully with XVS 3.5.55.

Could you please provide a test project?  So that I can reproduce this issue at my end.

Thanks!
Comment 10 Onno 2014-09-04 14:50:21 UTC
I'm having this same issue except with another dll, namely:

Error	5	Failed to resolve "System.Reflection.Emit.ModuleBuilder" reference from "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"	C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets

I can confirm that the error does not occur when starting a debug session on the iOS simulator.
Comment 11 Jose Gallardo 2014-09-04 18:53:10 UTC
The root cause of this issue is an iOS project having a direct or indirect reference to a Framework assembly (which can carry other assemblies like the wrong System.dll).

In particular, we were able to repro the issue on several projects with  dependencies on Newtonsoft.Json.

The reason is an error on the Newtonsoft.Json nuget package. The portable lib for 4.5 ("portable-net45+wp80+win8+wpa81") is not really portable, and has references to framework assemblies not compatible with i.e. monotouch.

The workaround is to make csproj references to Newtonsoft.Json.dll  to point to the 4.0 assembly ("portable-net40+sl4+wp7+win8") which doesn't have such incompatible dependencies.

Please verify the workaround with the users.

Thanks
Comment 12 Thomas van der Heijden 2014-09-04 20:05:55 UTC
I've removed all references to Newtonsoft.Json.  The issue is still there, how do I track this one down?

Also why did this suddenly stop working with the latest stable release?  Isn't this a regression issue?
Comment 13 Adrian Alonso 2014-09-04 20:28:17 UTC
Basically you should check if there is any other reference in the output directory of the App which has been built against an invalid framework.

Another typical problem that we found is when the System.Dynamic.dll assembly is copied to the output.

We're investigating why this could have been working with the previous build. And we're also looking forward to improve the mtouch tool execution to provide a more descriptive error message for these cases.
Comment 14 Thomas van der Heijden 2014-09-04 23:33:54 UTC
I've spend a couple of hours trying to track down where this reference is coming from.  No useful tools makes this quite time consuming.  I think it's not as easy as don't reference DLL x.y.z.  Besides why does it work in XS and not in VS?

I've created a separate project with Json.Net (6.0.0.2 from nuget.org and 6.0.0.4 from MS source) and it works fine.  It also adds the Dynamic library.  So it's not that.

Weird part: when I added BugSense.Xamarin.IOS to a clean IOS project it installed 5.0.8 json and it failed to compile.  When I upgraded to 6.0.0.2 it worked.  When I upgraded to 6.0.0.4 it stopped working.

Then I created a new project exactly the same way and all versions compiled without any issues!?!?!

Odd thing I discovered.  the project had System.Xml full version in the output folder.  I guess some package has a reference to it.  However if include a reference in system.xml it uses the mono touch version instead?!

I've also created a separate project with the exact same references as my main project and it builds fine.  I think some much more dodgy is going on.  I did get the feel it might be related to timing or the order references are added to the project.  At one stage I managed to compile my project by remove and adding the same reference.  When I then added another reference it stopped working and I couldn't get it to work anymore.

I've also seen System.Reflection.Emit.ModuleBuilder error from time to time.  Probably related.
Comment 15 Onno 2014-09-05 03:21:28 UTC
I can confirm that the workaround suggested by Jose Gallardo works.
Comment 16 Jim Bennett 2014-09-06 03:32:29 UTC
The problem with Jose Gallardo's solution is that this fixes it for Visual Studio, but if you then try to compile on Xamarin Studio on the Mac you get a build error - fix for that is to put it back.
Comment 17 Jose Gallardo 2014-09-08 12:20:07 UTC
We still working on this issue. The assembly shipped in Newtonsoft.Json for the portable profile 925 is actually a RIGHT portable one, however the wrong referenced assemblies are included by our build process. That is the actual issue, and what we need to fix. 
We're currently working on that fix and we'll keep you updated about the progress on this thread.
The bug is reopened now.
Comment 18 Brendan Zagaeski (Xamarin Team, assistant) 2014-09-08 13:10:05 UTC
Not sure if it will still be relevant, but there's a small chance this old bug might be helpful:
https://bugzilla.xamarin.com/show_bug.cgi?id=16904
Comment 21 Ram Chandra 2014-09-09 13:21:58 UTC
I have checked this issue with following builds:

Microsoft Visual Studio Professional 2013
Version 12.0.30723.00 Update 3
Microsoft .NET Framework
Version 4.5.50938
Installed Version: Professional
Xamarin   3.5.57.0 (3f0c2c501a1c42ac9d362dd1970c001bdce7ce6b)

Mac Environment : 
X.iOS 7.4.0.108
Xcode 5.1.1
Mono 3.8.0.9

I have created an iOS single view application and add the portable class library to the solution. In PCL, I have declare two property "Name" and "Size". Which used in button's click event in iOS single view application, with the help of JsonConvert.SerializeObject("") and when I run the sample application I observed that I am not getting any error/exception.

Screencast : http://screencast.com/t/MwhGqhhHImOh

I have reproduced this issue with XVS 3.5.55

Screencast( XVS )  : http://screencast.com/t/8CmtcrU95qes

This issue has been fixed. Hence, I am closing this issue.