Bug 17026 - xbuild does not exclude incompatible references
Summary: xbuild does not exclude incompatible references
Status: CONFIRMED
Alias: None
Product: Tools
Classification: Mono
Component: xbuild ()
Version: unspecified
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks: 17027
  Show dependency tree
 
Reported: 2014-01-02 14:02 UTC by Jon Goldberger [MSFT]
Modified: 2014-03-04 11:59 UTC (History)
13 users (show)

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


Attachments
PCL-Inclusion of RegLib test project (85.44 KB, application/zip)
2014-01-02 14:03 UTC, Jon Goldberger [MSFT]
Details
MSBuild output (5.66 KB, text/plain)
2014-01-13 07:21 UTC, Martin Baulig
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 for Bug 17026 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Comment 1 Jon Goldberger [MSFT] 2014-01-02 14:03:13 UTC
From case: 
I created few samples that demonstrate the following cases regarding PCL.
Issue 1: PCL cannot include Regular Library. But this works fine in Xamarin studio but fails in Visual Studio.

* From the attached code "PCL-Inclusion of RegLib.zip", I had 2 libs, PCLLib (PCL Library) and RegLib (Normal regular library).
* Here PCLLib invokes one of the method of RegLib and hence includes RegLib.
* This works fine in Xamarin but FAILS in Visual Studio.
* You can run the solution to validate this statement.
* Instructions to run the Application:
* Don’t pull the folders/projects out of the Unzipped folder.
* You can test on either of the platforms iOS or Android. Lets say for iOS.
* Compile RegLib first and then PCLLib and then iOSLib.
* Now compile iOSNativeApp and run.
* You may see the output on the console, saying that the strings are coming from RegLib and PCLLib too.
* Follow the same for Droid if you want to.

[test project PCL-Inclusion of RegLib.zip attached]
Comment 3 Marek Habersack 2014-01-03 04:10:37 UTC
I'm not nearly an expert on PCL, but it seems to me that the described scenario is indeed an invalid one and that VS behavior is correct and that the regular lib working in an XS-compiled application is by pure chance.

Martin, can you take a look, please? If the fix is simple we might want to consider including it in 1.10 (after approval from QA of course) if not, we'll put it in 1.12. Thanks!

Jon, I changed the product version in the bug description to 1.10 (from 1.8) since that's what your version report contains.
Comment 4 dean.ellis 2014-01-03 04:17:05 UTC
I agree, in this instance I think XS is incorrect and Visual Studio is behaving correctly. You should NOT be able to reference a normal library project from a PCL. You can reference other PCL projects/libraries/assemblies but that is it. 

This will probably apply to https://bugzilla.xamarin.com/show_bug.cgi?id=17027 as well.
Comment 5 Martin Baulig 2014-01-06 04:33:37 UTC
Haven't looked at the test case yet, but from your description, I agree that this should be invalid.  Detecting "invalid" library reference is something that has not received very much testing, so I'm not too surprised to find bugs ;-)
Comment 6 PJ 2014-01-10 13:40:09 UTC
I'm moving this to XS based on the last few comments.
Comment 7 Mikayla Hutchinson [MSFT] 2014-01-10 16:16:00 UTC
XS does NOT let you reference a normal library project from a PCL project. However, this reference was added as a dll reference, not a project reference, and neither XS or VS validates these. You are correct that this is invalid, but it's something that should be enforced by the compiler, not the IDE.

How does it fail in VS?
Comment 8 Martin Baulig 2014-01-13 07:08:21 UTC
Hmm, I don't see how this could possibly work with Mono / XS.  The normal library should contain a reference to the "normal" .NETFramework corlib, so the compiler should really generate an error.
Comment 9 Martin Baulig 2014-01-13 07:19:59 UTC
You should not be able to compile the PCLLib.csproj, attaching msbuild output.
Comment 10 Martin Baulig 2014-01-13 07:20:42 UTC
-> CONFIRMED
Comment 11 Martin Baulig 2014-01-13 07:21:50 UTC
Created attachment 5820 [details]
MSBuild output
Comment 12 Martin Baulig 2014-01-13 07:30:43 UTC
So it seems like MSBuild checks this in the "ResolveAssemblyReferences" target.  I'll have a look at this.

As a first step, I'll write some test case for this msbuild task, then check what happens if you attempt to invoke the compiler directly.