Bug 58182 - Project builds in Debug but not in Release
Summary: Project builds in Debug but not in Release
Status: RESOLVED DUPLICATE of bug 57645
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 7.1 (C9)
Hardware: PC Windows
: --- normal
Target Milestone: 15.4
Assignee: Radek Doulik
Depends on:
Reported: 2017-07-17 08:30 UTC by anton.duzenko@gmail.com
Modified: 2017-07-31 17:28 UTC (History)
5 users (show)

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

Build log (3.30 KB, text/plain)
2017-07-17 08:30 UTC, anton.duzenko@gmail.com
version info (2.77 KB, text/plain)
2017-07-17 08:33 UTC, anton.duzenko@gmail.com
diagnostic build log (4.47 MB, text/plain)
2017-07-17 09:16 UTC, anton.duzenko@gmail.com
diagnostic build log 2017 (487.19 KB, application/x-zip-compressed)
2017-07-17 09:20 UTC, anton.duzenko@gmail.com
version info 2017 (1.13 KB, text/plain)
2017-07-17 09:22 UTC, anton.duzenko@gmail.com
minimal reproducible (577.68 KB, application/x-zip-compressed)
2017-07-17 13:08 UTC, anton.duzenko@gmail.com

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 anton.duzenko@gmail.com 2017-07-17 08:30:15 UTC
Created attachment 23584 [details]
Build log

This happens on the business app, although an empty xamarin project builds just fine.
I tried cleaning project, restart VS, fresh check out from source control, nothing helps.
VS 2017 is able to build in Release, but not VS 2015 that I use for work.
Comment 1 anton.duzenko@gmail.com 2017-07-17 08:33:50 UTC
Created attachment 23586 [details]
version info
Comment 2 Jon Douglas [MSFT] 2017-07-17 09:12:43 UTC
Looks like you are running into a Linker error.

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1569,5): error MSB4018: The "LinkAssemblies" task failed unexpectedly.
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1569,5): error MSB4018: System.NullReferenceException: Object reference not set to an instance of an object.
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1569,5): error MSB4018:    at Mono.Linker.Steps.ResolveFromAssemblyStep.ProcessLibrary(LinkContext context, AssemblyDefinition assembly)
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1569,5): error MSB4018:    at Mono.Tuner.CustomizeActions.ProcessUserAssembly(AssemblyDefinition assembly)
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1569,5): error MSB4018:    at Mono.Tuner.CustomizeActions.ProcessAssembly(AssemblyDefinition assembly)
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1569,5): error MSB4018:    at Mono.Linker.Steps.BaseStep.Process(LinkContext context)
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1569,5): error MSB4018:    at Mono.Linker.Pipeline.Process(LinkContext context)
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1569,5): error MSB4018:    at MonoDroid.Tuner.Linker.Run(Pipeline pipeline, LinkContext context)
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1569,5): error MSB4018:    at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1569,5): error MSB4018:    at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1569,5): error MSB4018:    at Xamarin.Android.Tasks.LinkAssemblies.Execute()
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1569,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1569,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

What Linker mode is your Release application set to? The default is Link SDK Assemblies Only for a Release application:


Unfortunately the build log you attached isn't verbose enough and we will want a Diagnostic one instead. You can find instructions on getting a Diagnostic build output here:


Please attach both a VS 2015 failing log, and a VS 2017 succeeding log.

You mention that this builds just fine on VS 2017, but not on VS 2015? Can you please ensure that you are on the Stable channel of updates for both IDEs? Please also post your Version Information for your VS 2017 IDE.

Finally, for us to investigate this issue further, we will need a sample project demonstrating the behavior of the application. This can be a File->New->Xamarin.Android Application that has the minimal libraries included that demonstrates the problem.

Thus setting this bug to NEEDINFO until we have more information regarding the VS 2017 Version Information and more verbose build logs.
Comment 3 anton.duzenko@gmail.com 2017-07-17 09:16:16 UTC
Created attachment 23587 [details]
diagnostic build log
Comment 4 anton.duzenko@gmail.com 2017-07-17 09:20:07 UTC
Created attachment 23588 [details]
diagnostic build log 2017
Comment 5 anton.duzenko@gmail.com 2017-07-17 09:22:56 UTC
Created attachment 23589 [details]
version info 2017
Comment 6 anton.duzenko@gmail.com 2017-07-17 09:23:21 UTC
All good?
Comment 7 Jon Douglas [MSFT] 2017-07-17 09:41:53 UTC
From your VS 2017 logs it shows a pretty old version:

Version 15.1 (26403.7) Release

Xamarin (3f99c5a)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android SDK (b16fb82)
Xamarin.Android Reference Assemblies and MSBuild support.

Please update using the Visual Studio Installer application and then try to build your project again. It will most likely now fail in the same way your VS 2015 does. You will be updating to 15.2 which has the same build as your VS 2015.

If this is the case, we will need to get our hands on a reproduction. As mentioned earlier, this can be a project that has the same libraries installed as your sensitive project. We simply need to be able to reproduce this behavior locally. Without a reproduction project, it will be extremely difficult to know what the culprit is in this case as the build output doesn't give us much to go off of.

One way to diagnose this problem is:

1>  Task Parameter:LinkMode=SdkOnly (TaskId:226)
1>  Task Parameter:LinkSkip=System.Core (TaskId:226)

If you set your LinkMode to "None", does your build succeed? If so, we have a problem with the linker stripping out something you need in your application, however seeing that this is a NRE, I might guess that it's a bug in the Linker instead.

If the first scenario matches, you can follow my blog on this topic and see what's getting stripped out that you might be using. However this is really tedious:


Once you figure out what's being stripped out...You would then add it to the LinkSkip like you did with System.Core.
Comment 8 anton.duzenko@gmail.com 2017-07-17 09:44:32 UTC
Sorry, if you think that the updated VS2017 is also going to fail to build then I must not update it because I need to provide my employer daily release builds.
Comment 9 anton.duzenko@gmail.com 2017-07-17 13:08:56 UTC
Created attachment 23595 [details]
minimal reproducible

Let me know if you need anything else
Comment 10 anton.duzenko@gmail.com 2017-07-17 13:13:03 UTC
LinkMode to "None" -> builds OK
Comment 11 Radek Doulik 2017-07-19 16:03:50 UTC
The issue is resolving System.Data.Common.DbConnection/DataTypes in System.Data.Portable.dll. It is typeforwarded and it looks like the linker/cecil doesn't resolve it right.

Looking into how to fix it. No workaround yet.
Comment 12 Radek Doulik 2017-07-28 10:11:28 UTC
OK, I didn't notice before that the System.Data.Portable.dll assembly comes from the Mono.Data.Sqlite.Portable package.

The System.Data.Portable.dll assembly contains type forwarders which point to the System.Data.dll.

System.Data.dll changed meanwhile and doesn't contain the types anymore and needs to be updated. Matthew, could please take a look at it? (System.Data.Common.DbConnection/DataTypes and few more nested types in this class)

I will try to change the way the issue is reported, probably an exception with better description.
Comment 13 Radek Doulik 2017-07-31 14:30:04 UTC
*** Bug 57645 has been marked as a duplicate of this bug. ***
Comment 14 Radek Doulik 2017-07-31 17:28:35 UTC

*** This bug has been marked as a duplicate of bug 57645 ***