Bug 53510 - iOS MSBuild CLI not working with PCL libraries
Summary: iOS MSBuild CLI not working with PCL libraries
Alias: None
Product: iOS
Classification: Xamarin
Component: MSBuild ()
Version: XI 10.8 (d15-1)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2017-03-19 18:52 UTC by Shane
Modified: 2017-03-21 19:00 UTC (History)
2 users (show)

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:

Description Shane 2017-03-19 18:52:29 UTC
From what I can tell when "/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/smcs" is ran the facade's aren't being passed in as references. 

Here's a project to recreate the issue

The parameters I'm using to run the build are in msb.sh

export MSBuildSDKsPath=/usr/local/share/dotnet/sdk/1.0.1/Sdks/
msbuild /t:restore NetStandard.Ref/NetStandard.Ref.csproj 
msbuild XamarinIOS.CLI.sln /t:build /p:Configuration=release /p:Platform=iPhoneSimulator

If I have a PCL library where I reference something like "IDisposable" then during the build process I get exceptions that look like this

"error CS0012: The type `System.IDisposable' is defined in an assembly that is not referenced. Consider adding a reference to assembly `System.Runtime, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [XamarinIOS.CLI.csproj]"

If I reference IDisposable from the main iOS project it all works fine but if it's inside the PCL then it causes exceptions.

The attached project has a NETStandard and PCL project the issue happens without the NETStandard library as well. 

This project builds fine inside VSfM and the command line CLI works fine on Windows from a Visual Studio 2017 command prompt window

Microsoft (R) Build Engine version
Copyright (C) Microsoft Corporation. All rights reserved.

=== Visual Studio for Mac Preview ===

Version Preview 5 (7.0 build 1659)
Installation UUID: 023a3e1e-f586-405c-9144-3aee8abfd609
	Mono 4.8.0 (mono-4.8.0-branch/8f6d0f6) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 408000520

=== NuGet ===


=== Xamarin.Profiler ===

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

=== Apple Developer Tools ===

Xcode 8.2.1 (11766.1)
Build 8C1002

=== Xamarin.iOS ===

Version: (Visual Studio Enterprise)
Hash: ba11e48
Branch: cycle9
Build date: 2017-03-10 08:48:04-0500

=== Xamarin.Android ===

Version: (Visual Studio Enterprise)
	Supported Android versions:
		6.0 (API level 23)
		7.1 (API level 25)

SDK Tools Version: 25.2.4
SDK Platform Tools Version: 25.0.2
SDK Build Tools Version: 25.0.2

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

Android Designer EPL code available here:

=== Xamarin Inspector ===

Hash: cdc01b9
Branch: 1.1-release
Build date: Wed, 22 Feb 2017 23:24:11 GMT

=== Xamarin.Mac ===

Version: (Visual Studio Enterprise)

=== Build Information ===

Release ID: 700001659
Git revision: c3bcd7708b7762fa4c12a88e7c5d75d83eb6462b
Build date: 2017-03-14 22:27:06-04
Xamarin addins: 11612bcfed8942216a2991a15e28b8d3df21449a
Build lane: monodevelop-lion-vs-mac-preview5

=== Operating System ===

Mac OS X 10.11.6
Darwin 15.6.0 Darwin Kernel Version 15.6.0
    Mon Jan  9 23:07:29 PST 2017
    root:xnu-3248. x86_64
Comment 1 es2000 2017-03-21 16:37:40 UTC
We have detected the same issue, because our build server does not build anymore. Does anyone already has a solution for the problem?
Comment 2 Manuel de la Peña [MSFT] 2017-03-21 17:10:08 UTC

This is a known issue in 4.8.0 there is the following workaround:

sudo cp /Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/msbuild/15.0/bin/Roslyn/System.Reflection.Metadata.dll /Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/msbuild/15.0/bin/
Comment 3 Manuel de la Peña [MSFT] 2017-03-21 17:23:41 UTC
Will close the bug as already fix since I have confirmed that it was fixed in https://github.com/xamarin/bockbuild/commit/e96ae1a3a6a84d39ee0b0a78279086b48898be13
Comment 4 Shane 2017-03-21 19:00:57 UTC
Msbuild is Msbuild'ing once again :-)

Thank you Manuel