Bug 47982 - Fail to compile a project using netstandard with Xamarin Studio Mac, same project compiles/runs fine with Visual Studio
Summary: Fail to compile a project using netstandard with Xamarin Studio Mac, same pro...
Status: RESOLVED NORESPONSE
Alias: None
Product: iOS
Classification: Xamarin
Component: MSBuild ()
Version: XI 10.4 (C9)
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-11-25 17:27 UTC by softlion
Modified: 2017-03-14 01:12 UTC (History)
6 users (show)

Tags:
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:
Status:
RESOLVED NORESPONSE

Description softlion 2016-11-25 17:27:24 UTC
When compiling with Xamarin Studio Mac a Xamarin forms app where the pcl library has been converted to a netstandard library, the compiler fails with these errors. The same project builds and run fine using Visual Studio Windows.

	error CS1070: The type `System.Resources.ResourceManager' has been forwarded to an assembly that is not referenced. Consider adding a reference to assembly `System.Resources.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
	error CS1070: The type `System.IServiceProvider' has been forwarded to an assembly that is not referenced. Consider adding a reference to assembly `System.ComponentModel, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

netstandard profiles tryed: netstandard1.3 and netstandard1.6
Comment 1 softlion 2016-11-25 18:46:39 UTC
Workaround: install .NET Core for Mac from instructions here https://www.microsoft.com/net/core#macos then on the command line:

dotnet restore
xbuild MyClient.sln /t:MyClient_iOS /p:Configuration="AppStore" /p:Platform="Any Cpu"

Building from Xamarin Studio will still fail. You have to build from command line.
Comment 2 softlion 2016-11-25 19:44:03 UTC
The workaround does not work for building. It fails with a mtouch error.

MTOUCH: error MT2001: Could not link assemblies. Reason: Value cannot be null.

Trying with VS Mac Preview 1
Comment 3 softlion 2016-11-25 21:20:27 UTC
Same error. But with vs mac restore does work. There is only the mtouch error when linker is enabled. When linker is disabled it generates an IPA fine.
Comment 4 softlion 2016-11-25 22:14:09 UTC
MTOUCH: error MT2001: Could not link assemblies. Reason: Value cannot be null.
		Parameter name: variable
		--- inner exception
		System.ArgumentNullException: Value cannot be null.
		Parameter name: variable
		  at Mono.Cecil.Cil.VariableIndex..ctor (Mono.Cecil.Cil.VariableDefinition variable) [0x00018] in /Users/builder/data/lanes/3985/62816dd6/source/xamarin-macios/external/mono/external/cecil/Mono.Cecil.Cil/Symbols.cs:178 
		  at Mono.Cecil.Cil.CodeReader.ReadScope (Mono.Cecil.Cil.ScopeDebugInformation scope) [0x0007b] in /Users/builder/data/lanes/3985/62816dd6/source/xamarin-macios/external/mono/external/cecil/Mono.Cecil.Cil/CodeReader.cs:172 
		  at Mono.Cecil.Cil.CodeReader.ReadScopes (Mono.Collections.Generic.Collection`1[T] scopes) [0x00007] in /Users/builder/data/lanes/3985/62816dd6/source/xamarin-macios/external/mono/external/cecil/Mono.Cecil.Cil/CodeReader.cs:157 
		  at Mono.Cecil.Cil.CodeReader.ReadScope (Mono.Cecil.Cil.ScopeDebugInformation scope) [0x000bc] in /Users/builder/data/lanes/3985/62816dd6/source/xamarin-macios/external/mono/external/cecil/Mono.Cecil.Cil/CodeReader.cs:177 
		  at Mono.Cecil.Cil.CodeReader.ReadDebugInfo () [0x00030] in /Users/builder/data/lanes/3985/62816dd6/source/xamarin-macios/external/mono/external/cecil/Mono.Cecil.Cil/CodeReader.cs:97 
		  at Mono.Cecil.Cil.CodeReader.ReadMethodBody () [0x000a9] in /Users/builder/data/lanes/3985/62816dd6/source/xamarin-macios/external/mono/external/cecil/Mono.Cecil.Cil/CodeReader.cs:88 
		  at Mono.Cecil.Cil.CodeReader.ReadMethodBody (Mono.Cecil.MethodDefinition method) [0x00014] in /Users/builder/data/lanes/3985/62816dd6/source/xamarin-macios/external/mono/external/cecil/Mono.Cecil.Cil/CodeReader.cs:59 
		  at Mono.Cecil.MetadataReader.ReadMethodBody (Mono.Cecil.MethodDefinition method) [0x00000] in /Users/builder/data/lanes/3985/62816dd6/source/xamarin-macios/external/mono/external/cecil/Mono.Cecil/AssemblyReader.cs:2141 
		  at Mono.Cecil.MethodDefinition.<get_Body>m__1 (Mono.Cecil.MethodDefinition method, Mono.Cecil.MetadataReader reader) [0x00000] in /Users/builder/data/lanes/3985/62816dd6/source/xamarin-macios/external/mono/external/cecil/Mono.Cecil/MethodDefinition.cs:154 
		  at Mono.Cecil.ModuleDefinition.Read[TItem,TRet] (TRet& variable, TItem item, System.Func`3[T1,T2,TResult] read) [0x00046] in /Users/builder/data/lanes/3985/62816dd6/source/xamarin-macios/external/mono/external/cecil/Mono.Cecil/ModuleDefinition.cs:986 
		  at Mono.Cecil.MethodDefinition.get_Body () [0x00032] in /Users/builder/data/lanes/3985/62816dd6/source/xamarin-macios/external/mono/external/cecil/Mono.Cecil/MethodDefinition.cs:154 
		  at Mono.Linker.Steps.MarkStep.ProcessMethod (Mono.Cecil.MethodDefinition method) [0x0017d] in /Users/builder/data/lanes/3985/62816dd6/source/xamarin-macios/external/mono/mcs/tools/linker/Mono.Linker.Steps/MarkStep.cs:1017 
		  at Xamarin.Linker.Steps.CoreMarkStep.ProcessMethod (Mono.Cecil.MethodDefinition method) [0x00017] in /Users/builder/data/lanes/3985/62816dd6/source/xamarin-macios/tools/linker/CoreMarkStep.cs:153 
		  at Mono.Linker.Steps.MarkStep.ProcessQueue () [0x00026] in /Users/builder/data/lanes/3985/62816dd6/source/xamarin-macios/external/mono/mcs/tools/linker/Mono.Linker.Steps/MarkStep.cs:125 
		  at Mono.Linker.Steps.MarkStep.Process () [0x0001e] in /Users/builder/data/lanes/3985/62816dd6/source/xamarin-macios/external/mono/mcs/tools/linker/Mono.Linker.Steps/MarkStep.cs:115 
		  at Mono.Linker.Steps.MarkStep.Process (Mono.Linker.LinkContext context) [0x0000f] in /Users/builder/data/lanes/3985/62816dd6/source/xamarin-macios/external/mono/mcs/tools/linker/Mono.Linker.Steps/MarkStep.cs:60 
		  at Xamarin.Linker.Steps.MobileMarkStep.Process (Mono.Linker.LinkContext context) [0x00003] in /Users/builder/data/lanes/3985/62816dd6/source/xamarin-macios/tools/linker/MobileMarkStep.cs:31 
		  at Xamarin.Linker.Steps.CoreMarkStep.Process (Mono.Linker.LinkContext context) [0x00018] in /Users/builder/data/lanes/3985/62816dd6/source/xamarin-macios/tools/linker/CoreMarkStep.cs:26 
		  at MonoTouch.Tuner.MonoTouchMarkStep.Process (Mono.Linker.LinkContext context) [0x0001e] in /Users/builder/data/lanes/3985/62816dd6/source/xamarin-macios/tools/linker/MonoTouch.Tuner/MonoTouchMarkStep.cs:36 
		  at Mono.Linker.Pipeline.Process (Mono.Linker.LinkContext context) [0x00027] in /Users/builder/data/lanes/3985/62816dd6/source/xamarin-macios/external/mono/mcs/tools/linker/Mono.Linker/Pipeline.cs:118 
		  at MonoTouch.Tuner.Linker.Process (MonoTouch.Tuner.LinkerOptions options, MonoTouch.Tuner.MonoTouchLinkContext& context, System.Collections.Generic.List`1[System.String]& assemblies) [0x000ac] in /Users/builder/data/lanes/3985/62816dd6/source/xamarin-macios/tools/mtouch/Tuning.cs:77 
		---
		  at MonoTouch.Tuner.Linker.Process (MonoTouch.Tuner.LinkerOptions options, MonoTouch.Tuner.MonoTouchLinkContext& context, System.Collections.Generic.List`1[System.String]& assemblies) [0x00153] in /Users/builder/data/lanes/3985/62816dd6/source/xamarin-macios/tools/mtouch/Tuning.cs:90 
		  at Xamarin.Bundler.Target.LinkAssemblies (System.String main, System.Collections.Generic.List`1[System.String]& assemblies, System.String output_dir, MonoTouch.Tuner.MonoTouchLinkContext& link_context) [0x001b3] in /Users/builder/data/lanes/3985/62816dd6/source/xamarin-macios/tools/mtouch/Target.cs:414 
		  at Xamarin.Bundler.Target.ManagedLink () [0x003ed] in /Users/builder/data/lanes/3985/62816dd6/source/xamarin-macios/tools/mtouch/Target.cs:506 
		  at Xamarin.Bundler.Target.ProcessAssemblies () [0x000e6] in /Users/builder/data/lanes/3985/62816dd6/source/xamarin-macios/tools/mtouch/Target.cs:631 
		  at Xamarin.Bundler.Application.BuildApp () [0x00036] in /Users/builder/data/lanes/3985/62816dd6/source/xamarin-macios/tools/mtouch/Application.cs:895 
		  at Xamarin.Bundler.Application.Build () [0x00058] in /Users/builder/data/lanes/3985/62816dd6/source/xamarin-macios/tools/mtouch/Application.cs:563 
		  at Xamarin.Bundler.Driver.Main2 (System.String[] args) [0x01cd7] in /Users/builder/data/lanes/3985/62816dd6/source/xamarin-macios/tools/mtouch/mtouch.cs:1520 
		  at Xamarin.Bundler.Driver.Main (System.String[] args) [0x0000f] in /Users/builder/data/lanes/3985/62816dd6/source/xamarin-macios/tools/mtouch/mtouch.cs:1007 
	Task "MTouch" execution -- FAILED
	Done building target "_CompileToNative" in project
Comment 5 softlion 2016-11-26 00:46:38 UTC
The problem was that a dependant library project was not included in the build configuration. I updated the configuration mapping and now the appstore/release build with another error which seems related to http://unix.stackexchange.com/questions/108174/how-to-persist-ulimit-settings-in-osx-mavericks.

Note that Visual Studio now builds the AppStore/Release without error, but does not generate the ipa file.
Comment 6 softlion 2016-11-26 00:54:15 UTC
Yes it worked !
Thanks for this bugzilla :)
Comment 7 Vincent Dondain [MSFT] 2016-11-28 13:02:05 UTC
Hi,

I'm getting a restore error saying Xamarin.Forms isn't compatible with netstandard (all versions), with XS or VS mac (same thing):

Package Xamarin.Forms 2.3.1.114 is not compatible with netstandard1.5 (.NETStandard,Version=v1.5). Package Xamarin.Forms 2.3.1.114 supports:
  - monoandroid10 (MonoAndroid,Version=v1.0)
  - monotouch10 (MonoTouch,Version=v1.0)
  - portable-monoandroid10+monotouch10+net45+win+win81+wp8+wpa81+xamarinios10 (.NETPortable,Version=v0.0,Profile=win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10)
  - uap10.0 (UAP,Version=v10.0)
  - win81 (Windows,Version=v8.1)
  - wp8 (WindowsPhone,Version=v8.0)
  - wpa81 (WindowsPhoneApp,Version=v8.1)
  - xamarinios10 (Xamarin.iOS,Version=v1.0)

Could you please give us you about information (Xamarin Studio > About Xamarin Studio) so we know your exact setup as well as exact repro step?

It's a bit confusing right now because you seem to have fixed things locally so I'm not sure there's an issue on our end, if so we'd be happy to fix it (:
Comment 8 Matt Ward 2016-11-28 13:07:49 UTC
Just to add to Vincent's comment, I am unable to reproduce the same build errors.

My test steps were:

1) With Visual Studio for Mac create a new Xamarin.Forms project.
   a) Select Android and iOS.
   b) Select PCL.
   c )Do not select use xaml.

2) Wait for NuGet packages to be added.
3) Open project options for the PCL project
4) Go to build - general and select .NETStandard Platform. Click OK.
5) Wait for package restore to complete.
6) Package restore fails saying that Xamarin.Forms is not compatible with .NETStandard - "Package Xamarin.Forms 2.3.1.114 is not compatible with netstandard1.5 "
   - Visual Studio shows the same restore error.
7) Add an imports line to the project.json file to allow Xamarin.Forms to be treated as compatible:
  "frameworks": {
    "netstandard1.5": {
        "imports": "portable-net45+win81+wp8+wpa81"
    }
  }
8) Save the project.json file to trigger a NuGet package restore.
9) Rebuild the entire solution.
10) Build is successful.

So if you can provide test steps or a small project that reproduces the problem that would be really helpful, thanks.
Comment 9 softlion 2016-11-28 13:58:40 UTC
Yes Visual studio for mac does Work perfectly.
I switched to it.
I was able to archive for the AppStore and publish the app after I added the mac setting to enable more simultaneous file descriptors.

But the current xamarin studio stable/beta/alpha do have issues: my project won't even compile on them (although it does in visual studio windows paired with a mac).

what information do you need ?
Comment 10 Matt Ward 2016-11-28 14:06:30 UTC
Xamarin Studio from the alpha channel works OK for me. The only problem I had was that it did not work if in the global Preferences - Projects - Build the Build with MSBuild setting was enabled. It only seems to compile without errors if this is unselected so xbuild is being used. When it was enabled I had to disable it and close and re-open the solution to get the build to work.

Xamarin Studio from the alpha channel is the first version where you could switch a PCL project to a .NETStandard project. Earlier versions do not support this and you would have had to create the project.json file manually.
Comment 11 David 2016-12-06 22:34:53 UTC
This is happening to me as well, in Xamarin Studio on macOS (stable as well as alpha). Is there anyone looking into this? I see the status is NEEDINFO. What information is still needed?
Comment 12 softlion 2016-12-06 23:04:10 UTC
I have a workaround:
Use visual studio mac preview.
It works fine !!
Comment 13 David 2016-12-07 09:30:55 UTC
Yup. Works! Thanks softlion.
Comment 14 Matt Ward 2016-12-07 09:35:41 UTC
@David - It would be good to find the steps to reproduce the problem and the environment information from the About dialog - Details. I cannot reproduce it using the steps I tried in #c8.
Comment 15 Manuel de la Peña [MSFT] 2017-01-03 09:50:57 UTC
@David could you please provide the info requested by @Matt so that we can move forward with the bug? Thx!
Comment 16 David 2017-01-03 19:11:31 UTC
It may take me some time to set up. I'd need to gut our current project of everything sensitive. I already migrated to Visual Studio Preview for Mac, and it's working just fine. But I'll try to make time to make a small project that reproduces the problem.
Comment 17 Manuel de la Peña [MSFT] 2017-02-07 11:52:28 UTC
@David any information about the project?
Comment 18 Timothy Risi 2017-03-14 01:12:37 UTC
We have not received the requested information. If you are still 
experiencing this issue please provide all the requested information 
and re-open the bug report. Thanks!