Bug 58740 - Building default Android project after adding Fsharp.core from nuget with 'link SDK assemblies only' dies with exception
Summary: Building default Android project after adding Fsharp.core from nuget with 'l...
Alias: None
Product: Android
Classification: Xamarin
Component: Linker ()
Version: 7.4 (15.3)
Hardware: PC Mac OS
: --- normal
Target Milestone: 15.5
Assignee: Radek Doulik
Depends on:
Reported: 2017-08-13 18:55 UTC by Sam Williams
Modified: 2017-08-29 12:51 UTC (History)
4 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 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:

Description Sam Williams 2017-08-13 18:55:49 UTC
Similar to https://bugzilla.xamarin.com/show_bug.cgi?id=52940
Clone: https://github.com/willsam100/linkerError
Create a new Xamarin.Forms F# project, add Fsharp.Core to the project (4.1 or higher, I used 4.2.2). Set linking to 'link SDK assemblies only', build and see the linker fail with 

"error MSB4018: The "LinkAssemblies" task failed unexpectedly.
error MSB4018: System.NullReferenceException: Object reference not set to an instance of an object"

I attempted to add Fsharp.Core to the ignore list, with no luck (also tried add the entire list of System packages). 

I have not found work around other than not using the linker. Google do not allow an APK larger than 100MB, this empty project results in an APK of 54MB
Comment 1 Sam Williams 2017-08-13 18:57:04 UTC
This is what i tested on. Also reproducible on stable channel
=== Visual Studio Community 2017 for Mac (Preview) ===

Version 7.1 Preview (7.1 build 1294)
Installation UUID: 8d3712bd-ee56-4387-80b1-d5ddc495dce3
	Mono (d15-3/da80840) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 502000215

=== NuGet ===


=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
SDK: /usr/local/share/dotnet/sdk/1.0.4/Sdks
SDK Versions:
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.2.0/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.5.5
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 8.3.3 (12175.1)
Build 8E3004b

=== Xamarin.iOS ===

Version: (Visual Studio Community)
Hash: bf350ba5
Branch: d15-3
Build date: 2017-07-05 11:08:04-0400

=== Xamarin.Android ===

Version: (Visual Studio Community)
Android SDK: /Users/sam.williams/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		6.0 (API level 23)
		7.0 (API level 24)
		7.1 (API level 25)

SDK Tools Version: 
SDK Platform Tools Version: 24.0.0
SDK Build Tools Version: 25.0.2

Java SDK: /usr
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

Android Designer EPL code available here:

=== Xamarin Inspector ===

Version: 1.2.2
Hash: b71b035
Branch: d15-1
Build date: Fri, 21 Apr 2017 17:57:12 GMT

=== Xamarin.Mac ===

Version: (Visual Studio Community)

=== Build Information ===

Release ID: 701001294
Git revision: c1117555164ee74ba7293159b12602d4b253ad9c
Build date: 2017-08-02 12:16:18-04
Xamarin addins: 3bb0c32a14f1b7e368bf5ac53a84c3581c019391
Build lane: monodevelop-lion-d15-3

=== Operating System ===

Mac OS X 10.12.6
Darwin 16.7.0 Darwin Kernel Version 16.7.0
    Thu Jun 15 17:36:27 PDT 2017
    root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64

=== Enabled user installed addins ===

MvvmCross Template pack 1.4.13
AddinMaker 1.3.7
Paket 0.3
WakaTime 3.0.0
xUnit.NET 2 testing framework support 0.7.5
Redth's Addins 1.0.9
Comment 2 Jon Douglas [MSFT] 2017-08-14 19:07:07 UTC
I am able to reproduce this on 15.3 with the provided reproduction in https://bugzilla.xamarin.com/show_bug.cgi?id=58740#c0

2>C:\Program Files (x86)\Microsoft Visual Studio\Preview\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1591,5): error MSB4018: The "LinkAssemblies" task failed unexpectedly.
2>System.NullReferenceException: Object reference not set to an instance of an object.
2>   at Mono.Linker.Steps.ResolveFromAssemblyStep.ProcessLibrary(LinkContext context, AssemblyDefinition assembly, RootVisibility rootVisibility)
2>   at Mono.Tuner.CustomizeActions.ProcessAssembly(AssemblyDefinition assembly)
2>   at Mono.Linker.Steps.BaseStep.Process(LinkContext context)
2>   at Mono.Linker.Pipeline.Process(LinkContext context)
2>   at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
2>   at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
2>   at Xamarin.Android.Tasks.LinkAssemblies.Execute()
2>   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
2>   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
2>Done building project "Linker.Droid.fsproj" -- FAILED.
2>Build FAILED.

I believe there are also two interesting bookkeeping items which are:



Marking CONFIRMED as I can reproduce on 15.3.
Comment 3 Cody Beyer (MSFT) 2017-08-28 17:00:50 UTC
had to make title shorter. Title was previously: 

>Building default Android project after adding Fsharp.core from nuget with  'link SDK assemblies only' dies with exception:  Caused by: android.runtime.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object
Comment 4 Radek Doulik 2017-08-29 12:51:05 UTC
this is fixed in monodroid/d15-4/aafbe32d258d44e466fdd0453c3601ffe178657e