Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
Referencing a .NET Standard 2.0 library project from an iOS project and using some code in the library will result in a build error:
Error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=22.214.171.124, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
## Steps to Reproduce
1. Build the attached sample in VS for Mac
## Actual Results
The above build error.
## Expected Results
No Build errors
## Version Info:
=== Visual Studio Community 2017 for Mac (Preview) ===
Version 7.1 Preview (7.1 build 1289)
Installation UUID: b968d862-551c-4a33-ab4e-9666400e357c
Mono 126.96.36.199 (2017-04/ef39d08) (64-bit)
GTK+ 2.24.23 (Raleigh theme)
Package version: 502000213
=== NuGet ===
=== .NET Core ===
Runtime Version: 2.0.0-preview2-25407-01
SDK Version: 2.0.0-preview2-006497
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.2.0/lib/mono/msbuild/15.0/bin/Sdks
=== Xamarin.Profiler ===
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler
=== Apple Developer Tools ===
Xcode 8.3.3 (12175.1)
=== Xamarin.iOS ===
Version: 10.12.0.14 (Visual Studio Community)
Build date: 2017-07-05 11:08:04-0400
=== Xamarin.Android ===
Version: 188.8.131.52 (Visual Studio Community)
Android SDK: /Users/johnmiller/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
6.0 (API level 23)
SDK Tools Version: 25.2.5
SDK Platform Tools Version: 26.0.0
SDK Build Tools Version: 25.0.3
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.Mac ===
Version: 184.108.40.206 (Visual Studio Community)
=== Xamarin Inspector ===
=== Build Information ===
Release ID: 701001289
Git revision: 6a34636ae67255dab639f2589ee25bfc76693228
Build date: 2017-07-12 14:06:52-04
Xamarin addins: 310d55d575c7d3248a145747ffdc9cb3a9d7c64c
Build lane: monodevelop-lion-d15-3
=== Operating System ===
Mac OS X 10.12.5
Darwin 16.6.0 Darwin Kernel Version 16.6.0
Fri Apr 14 16:13:31 PDT 2017
## Additional Information
If you reference the netstandard.dll file in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/Facades/ from the iOS project it will build successfully.
Created attachment 23918 [details]
Could be related to https://bugzilla.xamarin.com/show_bug.cgi?id=57842
*** This bug has been marked as a duplicate of bug 57842 ***
Are we sure this is the same as bug #57842? That bug seems to be about having the project files (.csproj) in the same directory - and indicates that when this is not the case the build works. The title of the bug is the same as this one though.
The attached project has the .NET Standard project in a different directory than the Xamarin.iOS project. Also the error message is different.
I can repro this particular bug using msbuild from the command line and with VS Mac 220.127.116.111 and later with Mono 18.104.22.168 (2017-06/e9d3a69) and Xamarin.iOS 10.99.1.7. Note that you need to remove the netstandard assembly reference from the Xamarin.iOS project to see the error.
@Matt, from the description I'm not sure this is the same issue (but it does seems related). I'm re-opening the issue.
It's a compiler error so it happens quite early in the build process (and before reaching the SDK tools). My guess it's something that the msbuild tasks should handle _or_ it's the .csproj that is incorrect (template? IDE issue?)
Where is the netstandard.dll reference added for _normal_ netstandard projects ? e.g. if I reference some NS2 assemblies from a console app ?
@John can you attach the build log ? in such cases it's a lot faster to look at it and assign/c.c. people than having everyone download and try it by themselves. thanks!
I suspect this is an MSBuild targets/tasks problem.
The error occurs if you run msbuild from the command line. I am guessing that the Xamarin.iOS MSBuild target may have to reference the netstandard.dll, which seems to be for .NET Standard 2.0, automagically like it does for the other facade dlls.
Failing diagnostic MSBuild build output:
Note that I had to remove the explicit netstandard.dll reference from the project file in the attached zip for the build to fail.
If I create a normal .NET Console project (.NET 4.6.1) that references a Sdk style project that targets .NET Standard 2.0 I can see that the following netstandard.dll is referenced and used by csc.exe:
@Matt, could you attach the diag build log from comment #7 ?
.NET 4.6.1 referencing .NET Standard 2.0 - msbuild output:
Adding version info where I can repro this problem:
Mono 22.214.171.124 (2017-06/e9d3a69 Tue Jul 25 05:56:19 EDT 2017)
Mono 126.96.36.199 (d15-3/da80840 Thu Jul 20 16:43:07 EDT 2017)
.NET Core SDKs: 1.0.4 and 2.0.0-preview2-006497
@matt provided the required information asked in https://bugzilla.xamarin.com/show_bug.cgi?id=58504#c8
However I'm not able to reproduce the issue using the test case provided by John.
See my versions information: https://gist.github.com/VincentDondain/4929ad0add1132d3be726752142e00ff
@matt, is your test case slightly different?
Note: I'm using a more recent XI + mono
Yeah John's test case includes the workaround where it directly references the netstandard.dll. With that reference it compiles. I removed that reference since it should not be needed and the build should then fail.
Created attachment 24184 [details]
I am having difficulties getting this working even on a console app, with today's d15-3 build.
/Users/donblas/Library/Caches/VisualStudio/7.0/MSBuild/78994_1/Sdks/Microsoft.NET.Sdk/build/Microsoft.NET.Sdk.Common.targets(5,5): Error: Project '/Users/donblas/Projects/MySpecialConsoleProject/NetStandardLib/NetStandardLib.csproj' targets '.NETStandard,Version=v2.0'. It cannot be referenced by a project that targets '.NETFramework,Version=v4.6.1'. (MySpecialConsoleProject)
Attached project above.
Turns out you need to install this:
to get it to work at all. Filing a bug against XS for this...
Created attachment 24185 [details]
This works for me on today's released 15.3 for XI (see screen shot).
15.3 XM fails for both supported profiles with
/usr/local/share/dotnet/sdk/2.0.0/Sdks/Microsoft.NET.Sdk/build/Microsoft.NET.Sdk.Common.targets(5,5): Error: Project '/Users/donblas/Downloads/TestNetStandard.iOS 2/NetStandardLib/NetStandardLib.csproj' targets '.NETStandard,Version=v2.0'. It cannot be referenced by a project that targets '.NETFramework,Version=v4.5'. (XMStd)
Ok, scratch that (and apologies for the spam). I did not realize @John's repro had the work around applied.
The simplified hack
<Reference Include="netstandard" />
Fixes XI and XM Modern.
XM Full requires a second hack
in the top property group, but then works as well.
@Ankit I think you have (or are working on) a PR for fixing this right ?
Yeah, I am testing the fix.
@Ankit, is this still on the radar for 15.4 ?
@Sebastien, it is. I am waiting to get an update for some of the sdks for 15.4, which might affect this.
Tests need to be added though.
Landed in master and PR out to 15.4:
Verified the bug on VSfM 15.4 build, issue is not reproducible.
For iOS Project
1. Created single view ios app & have reference of .net library 2.0 project.
2. Build & deployed the project successfully.
For Mac Project
1. Created Mac app & have reference of .net library 2.0 project.
2. Build & deployed the project successfully.
Verified with test project attached and provided .NetCore 2.0 refernce
Visual Studio Enterprise 2017 for Mac (Preview)
Version 7.2 Preview (7.2 build 617)
Xamarin.Android Version: 188.8.131.52 (Visual Studio Enterprise)
Xamarin.iOS Version: 184.108.40.206 (Visual Studio Enterprise)
Xamarin.Mac Version: 220.127.116.11 (Visual Studio Enterprise)
Operating System Mac OS X 10.12.6
Build Info : https://gist.github.com/neerajdeshmukh/10e01593e96222b944c30f2f35999de3
Screen cast : https://www.screencast.com/t/6WDm8FnTZnl3