Bug 33349 - VS2015 compiled assemblies result in LinkAssemblies error (when using nested class)
Summary: VS2015 compiled assemblies result in LinkAssemblies error (when using nested ...
Status: VERIFIED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 5.2
Hardware: PC Windows
: Normal normal
Target Milestone: 6.0 (C6)
Assignee: Radek Doulik
URL:
Depends on:
Blocks:
 
Reported: 2015-08-24 22:11 UTC by Virgile Bello
Modified: 2015-11-13 16:24 UTC (History)
3 users (show)

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


Attachments
File to attach to new Android project to reproduce the issue. (36.90 KB, text/plain)
2015-08-24 22:11 UTC, Virgile Bello
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 or GitHub 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 Virgile Bello 2015-08-24 22:11:24 UTC
How to reproduce:

* Open VS2015
* Create a new Android empty app
* Add attached file (SortedList.cs)
* Compile
* Error is displayed (see end of this comment)

Details:

* Doesn't happens with VS2013
* Seems to be due to the fact nested types with new Roslyn compiler might have a comma (in this case, type is '<System-Collections-Generic-IEnumerable<System-Collections-Generic-KeyValuePair<TKey,TValue>>-GetEnumerator>d__58'<TKey, TValue>). In VS2013 the name didn't contain a comma (it was 'GetEnumerator>d__b'<TKey, TValue>).


error MSB4018: The "LinkAssemblies" task failed unexpectedly.
error MSB4018: System.IO.FileNotFoundException: Could not load assembly 'TValue>>-GetEnumerator>d__58, Version=, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
error MSB4018: File name: 'TValue>>-GetEnumerator>d__58.dll'
error MSB4018:    at Xamarin.Android.Tuner.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
error MSB4018:    at Xamarin.Android.Tuner.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference)
error MSB4018:    at Mono.Cecil.MetadataResolver.Resolve(TypeReference type)
error MSB4018:    at Mono.Cecil.ModuleDefinition.Resolve(TypeReference type)
error MSB4018:    at Mono.Cecil.TypeReference.Resolve()
error MSB4018:    at Mono.Linker.Steps.MarkStep.MarkIfType(CustomAttributeArgument argument)
error MSB4018:    at Mono.Linker.Steps.MarkStep.MarkCustomAttributeArguments(CustomAttribute ca)
error MSB4018:    at Mono.Linker.Steps.MarkStep.MarkCustomAttribute(CustomAttribute ca)
error MSB4018:    at Mono.Linker.Steps.MarkStep.MarkCustomAttributes(ICustomAttributeProvider provider)
error MSB4018:    at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
error MSB4018:    at Mono.Linker.Steps.MarkStep.ProcessQueue()
error MSB4018:    at Mono.Linker.Steps.MarkStep.Process()
error MSB4018:    at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
error MSB4018:    at Mono.Linker.Pipeline.Process(LinkContext context)
error MSB4018:    at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
error MSB4018:    at Xamarin.Android.Tasks.LinkAssemblies.Execute()
error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
Comment 1 Virgile Bello 2015-08-24 22:11:50 UTC
Created attachment 12625 [details]
File to attach to new Android project to reproduce the issue.
Comment 2 Rajneesh Kumar 2015-08-25 07:18:03 UTC
I tried to reproduce this issue but notable to reproduce this. To reproduce this issue I have followed the steps and instruction provided in bug description. 

Screencast: http://www.screencast.com/t/JfT375av3

Could you please let me know that what steps I am missing/wrong to reproduce this issue ? That would we very helpful to reproduce this issue at our end. also if possible please attach VS trace logs, environment info.

For VS Trace Logs: Help=>Xamarin=>Zip Xamarin logs.

Thanks..!

Build output: https://gist.github.com/Rajneesh360Logica/4c94adea49bcada63dfd

Environment Info:

Microsoft Visual Studio Community 2015
Version 14.0.23107.0 D14REL
Microsoft .NET Framework
Version 4.6.00079

Installed Version: Community

Visual Basic 2015   00322-20000-00000-AA500
Microsoft Visual Basic 2015

Visual C# 2015   00322-20000-00000-AA500
Microsoft Visual C# 2015

Visual C++ 2015   00322-20000-00000-AA500
Microsoft Visual C++ 2015

Windows Phone SDK 8.0 - ENU   00322-20000-00000-AA500
Windows Phone SDK 8.0 - ENU

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

ASP.NET and Web Tools   14.0.20626.0
ASP.NET and Web Tools

ASP.NET Web Frameworks and Tools 2013   5.2.30624.0
For additional information, visit http://www.asp.net/

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

GenerateUnitTest   1.0
Generates unit test code for methods in classes under test.

Microsoft Azure Mobile Services Tools   1.4
Microsoft Azure Mobile Services Tools

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

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

SQL Server Data Tools   14.0.50616.0
Microsoft SQL Server Data Tools

Visual Studio Tools for Universal Windows Apps   14.0.23121.00 D14OOB
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

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

Xamarin   3.11.888.0 (fcb03e8)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   5.1.5.3 (f98871a95a479f6d71b3067b7e5834d41fcb2118)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS   8.10.4.0 (2c66d2fed40ae89b785ae3830b9555e4a3687ab7)
Visual Studio extension to enable development for Xamarin.iOS.

Xamarin.iOS Unified Migration   1.0
Automated migration for Xamarin iOS Classic projects to Unified

Xamarin.TestCloud.Integration   1.0
Early preview of Xamarin Test Cloud integration
Comment 3 Jonathan Pryor 2015-08-25 13:37:58 UTC
What on earth did you do to make the linker want to find `TValue>>-GetEnumerator>d__58, Version=, Culture=neutral, PublicKeyToken=`?

By any chance, are you using an IL obfuscator?
Comment 4 Virgile Bello 2015-08-26 01:31:28 UTC
I forgot one important step to reproduce the issue: switch to "Release" build (Linking is only done in Release).

@Jonathan: No, this is how compiler names auto-generated types (yield state machine, async state machine, etc...).

When compiling SortedList.cs, VS2013 used to auto-generate a type named:
> 'GetEnumerator>d__b'<TKey, TValue>

But with VS2015 (new compiler Roslyn), it auto-generates a type named:
> '<System-Collections-Generic-IEnumerable<System-Collections-Generic-KeyValuePair<TKey,TValue>>-GetEnumerator>d__58'<TKey,
TValue>

This type contains a comma (,) and when parsing typename, it thinks what's after the comma is the assembly name. THen it tries to load what's after the comma as an assembly. This is either a problem in Mono.Cecil or how you use it.
Comment 5 Rajneesh Kumar 2015-08-26 06:03:18 UTC
I have checked this issue again and I am able to reproduce this. To reproduce this issue I have followed the steps mentioned in comment 2, and additionally now I am building in Release configuration.

Screencast: http://www.screencast.com/t/CrKmj9LULJCo

Thanks..!

Error details: https://gist.github.com/Rajneesh360Logica/91e051abe95346e75bff
Vs Trace Logs: https://gist.github.com/Rajneesh360Logica/b20a95fffd939462b127

Environment info: https://gist.github.com/Rajneesh360Logica/673b2f539942dc648e07
Comment 6 Radek Doulik 2015-09-04 08:47:15 UTC
this is fixed in master/monodroid by fa7e3749ba54fca560c2b268f94ce2f6d7894a6b
Comment 7 Radek Doulik 2015-09-10 16:38:22 UTC
it is now also fixed in cycle6/monodroid by d9cd0f1fb66595359ce3942fbc46c47b16d214fd
Comment 8 Rajneesh Kumar 2015-10-09 09:22:49 UTC
I have checked this issue with cycle 6 build Xamarin.VisualStudio_4.0.0.1571_22caaddd3430959006432f6c42a1ec3bd27dea66
and observed that I am able to build the application in release mode. Please refer the screencast : http://www.screencast.com/t/21x3jhZMd 

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

Thanks..!

Environment Info:

Microsoft Visual Studio Community 2015
Version 14.0.23107.0 D14REL
Microsoft .NET Framework
Version 4.6.00079

Installed Version: Community

Visual Basic 2015   00322-20000-00000-AA500
Microsoft Visual Basic 2015

Visual C# 2015   00322-20000-00000-AA500
Microsoft Visual C# 2015

Visual C++ 2015   00322-20000-00000-AA500
Microsoft Visual C++ 2015

Windows Phone SDK 8.0 - ENU   00322-20000-00000-AA500
Windows Phone SDK 8.0 - ENU

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

ASP.NET and Web Tools   14.0.20626.0
ASP.NET and Web Tools

ASP.NET Web Frameworks and Tools 2013   5.2.30624.0
For additional information, visit http://www.asp.net/

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

GenerateUnitTest   1.0
Generates unit test code for methods in classes under test.

Microsoft Azure Mobile Services Tools   1.4
Microsoft Azure Mobile Services Tools

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

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

SQL Server Data Tools   14.0.50616.0
Microsoft SQL Server Data Tools

Visual Studio Tools for Universal Windows Apps   14.0.23121.00 D14OOB
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

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

Xamarin   4.0.0.1571 (22caadd)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   6.0.0.11 (f94dc5b)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS   9.2.0.85 (7bcf0da)
Visual Studio extension to enable development for Xamarin.iOS.