Bug 60653 - Release build does not contain nugets dependecy libs
Summary: Release build does not contain nugets dependecy libs
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: XI 11.3 (xcode9.1)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Future Cycle (TBD)
Assignee: Sebastien Pouliot
Depends on:
Reported: 2017-11-13 19:52 UTC by eusebiu.marcu
Modified: 2017-11-15 23:06 UTC (History)
3 users (show)

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

test project (14.77 KB, application/zip)
2017-11-13 19:52 UTC, eusebiu.marcu

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 eusebiu.marcu 2017-11-13 19:52:09 UTC
Created attachment 25674 [details]
test project

In Release mode, some nugets are not added inside the .app (In Debug they are)

Steps to reproduce:
0. ensure latest stasble VS for Mac
1. create a XF (PCL) app
2. install Xamarin.FFImageLoading.Svg.Forms nuget
3. Build Debug (Generic Device) - verify that Xamarin.FFImageLoading.Svg.Forms.dll is inside the .app file
4. Build Release (Generic Device) - verify that Xamarin.FFImageLoading.Svg.Forms.dll.inside the .app file => expected to be present!

See attachment for project!

Visual Studio Enterprise 2017 for Mac
Version 7.2.2 (build 11)
Installation UUID: 4b7b8e45-bb1b-4775-bbd6-d0b4c1835c58
	Mono (2017-06/1f4613aa1ac) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 504010006


.NET Core
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
SDK: /usr/local/share/dotnet/sdk/2.0.0/Sdks
SDK Versions:
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.4.1/lib/mono/msbuild/15.0/bin/Sdks

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

Apple Developer Tools
Xcode 9.1 (13532)
Build 9B55

Version: (Visual Studio Enterprise)
Hash: 51128b8c
Branch: xcode9.1
Build date: 2017-10-31 22:42:13-0400

Version: (Visual Studio Enterprise)
Android SDK: /Users/eusebiumarcu/Library/Android/sdk
	Supported Android versions:
		4.4 (API level 19)
		5.1 (API level 22)
		6.0 (API level 23)
		7.0 (API level 24)
		7.1 (API level 25)
		8.0 (API level 26)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 26.0.2
SDK Build Tools Version: 26.0.2

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

Android Designer EPL code available here:

Version: (Visual Studio Enterprise)

Xamarin Inspector
Version: 1.3.2
Hash: 461f09a
Branch: 1.3-release
Build date: Tue, 03 Oct 2017 18:26:57 GMT
Client compatibility: 1

Build Information
Release ID: 702020011
Git revision: b604c37c5a4a2f0919b45ffbe2aaad9fe040af31
Build date: 2017-11-01 08:31:43-04
Xamarin addins: d57dc14cbd4eb166ee62bab585965ab78d3650bc
Build lane: monodevelop-lion-d15-4

Operating System
Mac OS X 10.12.6
Darwin 16.7.0 Darwin Kernel Version 16.7.0
    Wed Oct  4 00:17:00 PDT 2017
    root:xnu-3789.71.6~1/RELEASE_X86_64 x86_64

Enabled user installed addins
Straight8's SpecFlow Integration
Comment 1 Manuel de la Peña [MSFT] 2017-11-15 12:39:02 UTC
Seems that the linker is being very aggressive and removes the dll even when you are doing:

var ignore = typeof(FFImageLoading.Svg.Forms.SvgCachedImage);

Confirming the bug.
Comment 2 Sebastien Pouliot 2017-11-15 15:57:56 UTC
I'll double check to be 100% sure but I'm fairly sure that it's _normal_

What's happening is that the newer, Roslyn [1] `csc` C# compiler will optimize [2] and remove unused code such as:

> var ignore = typeof(FFImageLoading.Svg.Forms.SvgCachedImage);

Since the code is not part of the assembly binary then final app will not have the assembly (and that's unrelated to the linker).

[1] The older Mono `mcs` C# compiler did not optimize such unused statements (so the assembly has a reference to the assembly);

[2] /optimize+ is only done on release builds, as such you have the reference in debug builds
Comment 3 Sebastien Pouliot 2017-11-15 23:06:29 UTC
> Xamarin.FFImageLoading.Svg.Forms.dll

There's no such assembly, I think you meant FFImageLoading.Svg.Forms.dll

If you rebuild your project with "Project Options | Compiler | Enable optimizations" turned off then it works - i.e. FFImageLoading.Svg.Forms.dll (and others) are present. So this is, like I suspected, related to the C# compiler.

More useful (to keep the optimizations) is to change your

> var ignore = typeof(FFImageLoading.Svg.Forms.SvgCachedImage);

into something the compiler cannot ensure it's unused (so it won't remove it), e.g.

> typeof(FFImageLoading.Svg.Forms.SvgCachedImage).ToString();

or something similar that ensure your compiled assembly has a reference(s) to what you want to bring into your application.