Bug 13268 - [Mac] [Studio] [Build] Fatal build error: exception during ExtractFromContentAssembly; "skipping extraction of resources"
Summary: [Mac] [Studio] [Build] Fatal build error: exception during ExtractFromContent...
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Mac Add-in ()
Version: 4.0.9
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: 4.2.4 (from master)
Assignee: Jeffrey Stedfast
URL:
Depends on:
Blocks:
 
Reported: 2013-07-16 10:53 UTC by Bart King
Modified: 2014-10-25 00:58 UTC (History)
6 users (show)

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


Attachments
Xamarin project to demonstrate build error (18.29 KB, application/x-gzip)
2013-07-16 10:53 UTC, Bart King
Details
TestProject (3.58 MB, application/octet-stream)
2014-03-25 12:09 UTC, Sadik Ali
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:
RESOLVED FIXED

Description Bart King 2013-07-16 10:53:29 UTC
Created attachment 4353 [details]
Xamarin project to demonstrate build error

When building a Xamarin.Mac app as "AppStore", extraction of embedded resources from custom assemblies fails with a build error.

The problem does not occur when building as "Debug".

I consider this a serious issue as I cannot build for the App Store.

=== SCENARIO ===

- Custom assembly with classes, containing embedded resources (such as images). These resources are set in Studio as "BundleResource". These resources are also inside folders in the assembly's project.

- Main project that references the custom assembly. Uses classes inside the assembly, and so on.

=== RESULTS ===

When building as "Debug":

- Resources are extracted into the correct folder, inside the main application's bundle (e.g. Contents/Resources/Some/Folder/File.png)

When building as "AppStore":

- Exception is raised by Xamarin Studio saying "Object is not set to an instance of an object".

=== EXCEPTION DETAIL ===

Here is the exception from the IDE log file:

ERROR [2013-07-16 14:46:53Z]: System.NullReferenceException: Object reference not set to an instance of an object
  at MonoDevelop.MonoMac.MonoMacBuildExtension.ExtractFromContentAssembly (IProgressMonitor monitor, MonoDevelop.MonoMac.MonoMacProjectConfiguration cfg, FilePath asmInBundle, System.Collections.Generic.HashSet`1 contentFileHash) [0x000c7] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.9-branch/f9c5c24e/source/md-addins/MonoDevelop.MonoMac/MonoDevelop.MonoMac/Project/MonoMacBuildExtension.cs:472 
  at MonoDevelop.MonoMac.MonoMacBuildExtension.UnpackContent (IProgressMonitor monitor, MonoDevelop.MonoMac.XamMacProjectBase proj, MonoDevelop.MonoMac.MonoMacProjectConfiguration cfg, System.Collections.Generic.List`1 assemblies, System.Collections.Generic.HashSet`1 contentFileHash) [0x0024c] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.9-branch/f9c5c24e/source/md-addins/MonoDevelop.MonoMac/MonoDevelop.MonoMac/Project/MonoMacBuildExtension.cs:389 

=== REPRODUCTION INSTRUCTIONS ===

Please see the attached project. It contains an assembly and a Xamarin.Mac application.

1. Open project, then Project->MainApp Options.
2. Under Mac OS X Application, set the Identifier to something that you can sign with.
3. Ensure the configuration is set to "Debug" (next to Play button).
4. Build->Build All.
5. Note warning in log about "skipping extraction of resources" from MyLib.dll. Why? I don't know.
6. Set configuration to "AppStore".
7. Build->Clean All.
8. Build->Build All.
9. Same error as step 5.
10. Right-click MainApp project and Build MainApp.
11. Error occurs as below:

Error extracting content from assembly '/Users/cleardemon/src/temp/ResourceExtraction/MyLib/bin/x86/AppStore/MyLib.dll'. Object reference not set to an instance of an object
Build: 1 error, 1 warning

=== ENVIRONMENT ===

=== Xamarin Studio ===

Version 4.0.9 (build 12)
Installation UUID: [snip]
Runtime:
	Mono 2.10.12 (mono-2-10/c9b270d)
	GTK 2.24.16
	GTK# (2.12.0.0)
	Package version: 210120000

=== Apple Developer Tools ===

Xcode 4.6.3 (2068)
Build 4H1503

=== Xamarin.Mac ===

Xamarin.Mac: 1.4.8

=== Xamarin.Android ===

Version: 4.6.8 (Starter Edition)
Android SDK: /Users/cleardemon/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		4.0   (API level 14)
		4.0.3 (API level 15)
Java SDK: /usr
java version "1.6.0_51"
Java(TM) SE Runtime Environment (build 1.6.0_51-b11-457-11M4509)
Java HotSpot(TM) 64-Bit Server VM (build 20.51-b01-457, mixed mode)

=== Xamarin.iOS ===

Version: 6.2.7.1 (Starter Edition)
Hash: 947e664
Branch: 
Build date: 2013-30-05 18:02:40-0400

=== Build Information ===

Release ID: 400090012
Git revision: f9c5c24e88417feb0319953db6d5fc650d416608
Build date: 2013-06-21 17:34:16+0000
Xamarin addins: 898d8afaabb160c025e21656f1490fa149397bff

=== Operating System ===

Mac OS X 10.8.4
Darwin tempest.local 12.4.0 Darwin Kernel Version 12.4.0
    Wed May  1 17:57:12 PDT 2013
    root:xnu-2050.24.15~1/RELEASE_X86_64 x86_64
Comment 1 Steve Flack 2014-01-02 16:47:36 UTC
I can confirm I see the same problem.

=== Xamarin Studio ===

Version 4.2.2 (build 2)
Installation UUID: e945753c-d735-4577-8207-608c7f947d36
Runtime:
	Mono 3.2.5 ((no/964e8f0)
	GTK+ 2.24.20 theme: Raleigh
	GTK# (2.12.0.0)
	Package version: 302050000

=== Apple Developer Tools ===

Xcode 5.0.2 (3335.32)
Build 5A3005

=== Xamarin.Mac ===

Xamarin.Mac: 1.6.27

=== Xamarin.iOS ===

Version: 7.0.5.2 (Business Edition)
Hash: 9c42159
Branch: 
Build date: 2013-02-12 20:04:08-0500

=== Xamarin.Android ===

Version: 4.10.2 (Business Edition)
Android SDK: /Users/steve/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		4.0   (API level 14)
		4.0.3 (API level 15)
		4.3   (API level 18)
		4.4   (API level 19)
Java SDK: /usr
java version "1.7.0_10"
Java(TM) SE Runtime Environment (build 1.7.0_10-b18)
Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)

=== Build Information ===

Release ID: 402020002
Git revision: c5f82958ae7d9af652b44b87ceff777b3ad19b91
Build date: 2013-11-19 15:35:40+0000
Xamarin addins: a4044fee09138f6fd031a9944b7caaeb51e57e80

=== Operating System ===

Mac OS X 10.9.1
Darwin MacBook-Pro.local 13.0.0 Darwin Kernel Version 13.0.0
    Thu Sep 19 22:22:27 PDT 2013
    root:xnu-2422.1.72~6/RELEASE_X86_64 x86_64
Comment 2 Jeffrey Stedfast 2014-01-02 17:45:43 UTC
This should be fixed in the upcoming 4.2.3
Comment 3 Saurabh 2014-02-13 10:28:41 UTC
I am trying to reproduce this issue with XS 4.2.2(Build 2), But I am unable to reproduce it.

Steps I have followed:
1. Open project, then Project->MainApp Options.
2. Under Mac OS X Application, set the Identifier to something that you can
sign with.
3. Ensure the configuration is set to "Debug" (next to Play button).
4. Build->Build All

Actual result: 
Not getting any warning. Project build successfully.
Build output: https://gist.github.com/atin360/95ffc2eb2fa527a9567e
Screencast: http://screencast.com/t/5iEd3vcxewST


6. Set configuration to "AppStore".
7. Build->Clean All.
8. Build->Build All.

Actual result:
Now, I am getting 1 warning:
"Warning: The referenced library 'MyLib.dll' is not used from any code, skipping extraction of content resources. (ResourceExtraction)" 
Build output: https://gist.github.com/atin360/9c7fe1c0e36e0a5cff8d
Screencast: http://screencast.com/t/oYIdcIszM

10. Right-click MainApp project and Build MainApp.

Actual result: Not getting any build error.
Build output: https://gist.github.com/atin360/71a376ac651341dedb86
Screencast: http://screencast.com/t/H1NBe4GoT0ka

Environment info:
=== Xamarin Studio ===

Version 4.2.2 (build 2)
Installation UUID: b1fc3b76-cf00-405e-a0a1-3839ac11fe6d
Runtime:
	Mono 3.2.7 ((no/40f92d5)
	GTK+ 2.24.23 theme: Raleigh
	GTK# (2.12.0.0)
	Package version: 302070000

=== Apple Developer Tools ===

Xcode 5.0.1 (3335.6)
Build 5A2034a

=== Xamarin.Mac ===

Xamarin.Mac: 1.6.27

=== Xamarin.iOS ===

Version: 7.0.6.242 (Business Edition)
Hash: b6e146d
Branch: 
Build date: 2014-05-02 14:05:53-0500

=== Xamarin.Android ===

Version: 4.12.0 (Business Edition)
Android SDK: /Users/apple/Desktop/android-sdk-macosx
	Supported Android versions:
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		3.2   (API level 13)
		4.0   (API level 14)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.2   (API level 17)
		4.3   (API level 18)
		4.4   (API level 19)
Java SDK: /usr
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)

=== Build Information ===

Release ID: 402020002
Git revision: c5f82958ae7d9af652b44b87ceff777b3ad19b91
Build date: 2013-11-19 15:35:40+0000
Xamarin addins: a4044fee09138f6fd031a9944b7caaeb51e57e80

=== Operating System ===

Mac OS X 10.9.2
Darwin Apples-iMac.local 13.1.0 Darwin Kernel Version 13.1.0
    Thu Jan 16 19:40:37 PST 2014
    root:xnu-2422.90.20~2/RELEASE_X86_64 x86_64

As per comment1, This issue is reproducible with XS 4.2.2 (build 2). But I am not able to reproduce it at my end.
Comment 4 Tim Uy 2014-03-24 13:48:17 UTC
I have 4.2.4 and I am seeing an issue where some critical dlls are not being included. This is the error:

Unhandled Exception:
System.MissingMethodException: Default constructor not found for type Cirrious.CrossCore.IoC.MvxPropertyInjector
at System.Activator.CreateInstance (System.Type,bool) <0x0017b>
....

but it really comes from a handful of 

"The referenced library "..." is not used from any code, skipping extraction  of content resources. 

Program works in Debug and compiles in Release but fails when running in release with 6 warnings (all of this kind).
Comment 5 Sadik Ali 2014-03-25 12:09:44 UTC
Created attachment 6406 [details]
TestProject

@Tim, The original case here still passes, and I'm unable to reproduce your crash with a basic test case. 
I have attached the project that I used to try to reproduce the issue .

@Tim, could you please share a test project on which you are getting crashed?
Comment 6 Jeffrey Stedfast 2014-03-25 15:11:36 UTC
When you get that warning, it means that mtouch did not copy the assemblies into the app bundle for some reason.

*Usually* this is because the linker detected that you weren't actually using any code from that assembly.

A workaround might be to disable linking in Release mode in the iOS Bundle section of the project options.

If you are actually using code from those assemblies, could you file a new bug under the Xamarin.iOS product? Thanks!
Comment 7 Akhilesh kumar 2014-03-26 09:12:41 UTC
I have reported a new issue for warning massages:
https://bugzilla.xamarin.com/show_bug.cgi?id=18585
Comment 8 Philippe Durand 2014-10-25 00:58:42 UTC
This is an ongoing bug in the latest Xamarin 5.6.2

I have a MonoMac project, and of course it lists many libraries as NOT USED, but they of course are all used.

The app runs fine anyway. The warning is just annoying.