Bug 17080 - Error building Android project with PCLs referenced out of order
Summary: Error building Android project with PCLs referenced out of order
Status: RESOLVED FEATURE
Alias: None
Product: Class Libraries
Classification: Mono
Component: General ()
Version: unspecified
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Martin Baulig
URL:
Depends on:
Blocks:
 
Reported: 2014-01-06 19:26 UTC by Jon Goldberger [MSFT]
Modified: 2014-01-09 21:33 UTC (History)
3 users (show)

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


Attachments
Test Project (45.50 KB, application/zip)
2014-01-06 19:27 UTC, Jon Goldberger [MSFT]
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 GitHub or Developer Community 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 FEATURE

Comment 1 Jon Goldberger [MSFT] 2014-01-06 19:27:33 UTC
I have come across an error where the order in which PCLs are referenced can cause a failure. In the attached test case, there are four projects projects:
AndroidBuildTest (MonoAndroid)
Profile158 (Portable Profile158)
Profile158-2 (Portable Profile158)
Profile7 (Portable Profile7)

Profile158-2 references project Profile158. AndroidBuildTest references the other three.

In AndroidBuildTest.csproj, if Profile158 appears before Profile158-2, everything is fine. However, if Profile158-2 appears before Profile158, any cs file referencing Profile7 fails with this error:
error CS0012: The type `System.Object' is defined in an assembly that is not referenced. Consider adding a reference to assembly `System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

-------------------------------------------------------------
=== Xamarin Studio ===

Version 4.2.2 (build 2)
Installation UUID: 092b839b-e4ba-41d0-8ccc-a3bdbc960f0d
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.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/ddunkin/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.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

=== Xamarin.Mac ===

Xamarin.Mac: Not Installed

=== 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.8.5
Darwin WS1681.local 12.5.0 Darwin Kernel Version 12.5.0
Sun Sep 29 13:33:47 PDT 2013
root:xnu-2050.48.12~1/RELEASE_X86_64 x86_64
Comment 2 Jon Goldberger [MSFT] 2014-01-06 19:27:55 UTC
Created attachment 5769 [details]
Test Project
Comment 3 Martin Baulig 2014-01-07 10:00:51 UTC
Well, there are two problems here:

(a) Your Mono is too old, the CS0012 will go away when you use xbuild from Mono 3.2.6.

You are using direct references to the sub-project outputs.  This should be considered an expert option and only used when there is a good reason for it and you know what you're doing.  In this case, the following applies:

(b) You must not use xbuild on the entire solution or use the "Build" command in Xamarin Studio.  This is not supported and the result will be random.  All the sub-projects must be built separately.  I would recommend to remove them from the solution and manually copy their output to some "lib" directory.

Directly referencing the output of other projects should be considered an expert option and only used when there is a good reason for it.

If this is not what you want, then use Project References (point (b) won't apply in this case); your .csproj should look like this:

  <ItemGroup>
    <ProjectReference Include="..\Profile158\Profile158.csproj">
      <Project>{607ECE68-267B-4FE1-A206-CCBC554CDEC9}</Project>
      <Name>Profile158</Name>
    </ProjectReference>
    <ProjectReference Include="..\Profile158-2\Profile158-2.csproj">
      <Project>{562F7A11-5400-468D-823C-6013A2E8E97D}</Project>
      <Name>Profile158-2</Name>
    </ProjectReference>
    <ProjectReference Include="..\Profile7\Profile7.csproj">
      <Project>{44E181D2-29E6-4C5E-B55A-3D890FF5505F}</Project>
      <Name>Profile7</Name>
    </ProjectReference>
  </ItemGroup>

In Xamarin Studio, right-click References, select Edit References, remove the three .dll references, then switch to the "Projects" tab and check the sub-projects.  This will get you project references.
Comment 4 Martin Baulig 2014-01-07 10:05:43 UTC
Btw. Visual Studio has this option to specify the "Build Order" which makes direct references to sub-project outputs less of a problem.
Comment 5 Dave Dunkin 2014-01-09 21:33:20 UTC
I'm not actually referencing the output of other projects, that was just a convenient way to demonstrate the problem. I'm glad it will be fixed in the next release.