Bug 26359 - NuGets bloat size in Starter Size calculation
Summary: NuGets bloat size in Starter Size calculation
Status: RESOLVED ANSWERED
Alias: None
Product: iOS
Classification: Xamarin
Component: Tools ()
Version: master
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-01-23 15:53 UTC by Joseph Hill
Modified: 2015-04-20 10:32 UTC (History)
3 users (show)

Tags:
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:
Status:
RESOLVED ANSWERED

Description Joseph Hill 2015-01-23 15:53:44 UTC
I recently published changes to the PortableRazor Starter Kit so that the projects reference the PortableRazor NuGet, rather than including the PortableRazor project source as a submodule:
https://github.com/xamarin/PortableRazorStarterKit

On Android, the PortableCongress sample above still builds and runs fine with Starter.

On iOS, attempting to build the project in Starter mode errors out with:

/Users/joseph/GitHub/xamarin/PortableRazorStarterKit/PortableCongress/iOSCongress/MTOUCHTASK: Error MT9005: User code size, 377508 bytes, is larger than 131072 bytes and requires a Indie (or higher) license. (MT9005) (iOSCongress)

If I take that sample and use a project reference on the PortableRazor source (or revert to a revision before I moved to NuGet), the project builds fine with Starter.

Changing Linker settings for the project has no impact on the calculated size.
Comment 1 Joseph Hill 2015-01-23 16:39:39 UTC
I unzipped the contents of the referenced PortableRazor package, and there is nothing anywhere near 250k in size in the package.  PortableRazor.dll is 16k on disk.
Comment 2 Joseph Hill 2015-01-24 21:45:46 UTC
Just went back and retested my claim that this builds if PortableRazor is referenced as a project rather than as a NuGet.  This claim was invalid.  This configuration also fails to build on iOS (so appears to be a regression).

The bloat appears to be coming from the System.Net.Http.dll and System.Net.Http.Primitives NuGets referenced in the the PortableCongress PCL:

Josephs-MacBook-Pro:iOSCongress joseph$ ls -al bin/iPhoneSimulator/Debug/
total 2864
drwxr-xr-x  11 joseph  staff      374 Jan 24 21:36 .
drwxr-xr-x   3 joseph  staff      102 Dec 27 00:42 ..
-rwxr-xr-x   1 joseph  staff  1117696 Jan 24 21:35 PortableCongress.dll
-rw-r--r--   1 joseph  staff     9213 Jan 24 21:35 PortableCongress.dll.mdb
-rwxr-xr-x   1 joseph  staff    16896 Jan 24 21:35 PortableRazor.dll
-rw-r--r--   1 joseph  staff     7072 Jan 24 21:35 PortableRazor.dll.mdb
-rw-r--r--   1 joseph  staff    22256 Dec 31 22:25 System.Net.Http.Primitives.dll
-rw-r--r--   1 joseph  staff   255176 Dec 31 22:25 System.Net.Http.dll
drwxr-xr-x  85 joseph  staff     2890 Jan 24 21:37 iOSCongress.app
-rwxr-xr-x   1 joseph  staff    12800 Jan 24 21:36 iOSCongress.exe
-rw-r--r--   1 joseph  staff     4333 Jan 24 21:36 iOSCongress.exe.mdb

The System.Net.Http* dlls also appear in the Android project's bin; however, they do not appear to be counting against the Starter size calculation on that platform (which I believe is the correct behavior).
Comment 8 Sebastien Pouliot 2015-01-26 15:06:25 UTC
Not quite. System.Net.Http.dll is not _only_ a facade, it's also a _real_ assembly in the framework with ship with the mobile profile. E.g. HttpClient comes from this assembly

https://msdn.microsoft.com/en-us/library/system.net.http.httpclient(v=vs.118).aspx

It's included (unlike others facades) because there's a reference to something in it (the most common one is using HttpClient). Normally facades references are eliminated since the references is mapped into another, real (non facade) assembly. 

I can track down what's the reference (that brings it) but the issue is that the wrong .dll is being copied.
Comment 9 Sebastien Pouliot 2015-04-20 10:32:38 UTC
That was diagnosed as having the MS assemblies used in the project (and XA was not checking that specific case and accepting it). 

For some reason the MS package includes their own assemblies and they overrides ours (and don't really work, e.g. fails on devices).

The best workaround would be not to depend on external packages for features that we already support on some PCL profiles (e.g. HttpClient). Ideally MS would not ship those assemblies for XI (or XA) as they are not required and conflict/cause issues with our own.

  <package id="Microsoft.Bcl" version="1.1.6" targetFramework="portable-net45+wp80+win+MonoAndroid10+MonoTouch10" />
  <package id="Microsoft.Bcl.Build" version="1.0.13" targetFramework="portable-net45+wp80+win+MonoAndroid10+MonoTouch10" />
  <package id="Microsoft.Net.Http" version="2.2.18" targetFramework="portable-net45+wp80+win+MonoAndroid10+MonoTouch10" />