monomonodevelopxbuildcakebuild

Compiling a solution with MonoDevelop or Cake/XBuild giving different results


I'm getting a different behavior when compiling a solution with MonoDevelop 5.1.0 and the same solution through a Cake script invoking XBuild.

When compiling the solution with MonoDevelop, everything works fine. When compiling through my cake script, I get the following error:

The type System.IDisposable' 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'

What could be the reason for such a different behavior?

The cake script doesn't do anything fancy. It just calls XBuild with the exact same solution.

My environment (on Fedora 23):

mono --version
Mono JIT compiler version 4.4.0 (Stable 4.4.0.142/81f38a9 Thu Apr 28 09:14:25 EDT 2016)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
    TLS:           __thread
    SIGSEGV:       altstack
    Notifications: epoll
    Architecture:  amd64
    Disabled:      none
    Misc:          softdebug 
    LLVM:          supported, not enabled.
    GC:            sgen

XBuild Version:
XBuild Engine Version 14.0
Mono, Version 4.4.0.0
Copyright (C) 2005-2013 Various Mono authors

Solution

  • You could try to instead of using the XBuild aliases to use the Cake.Xamarin addin which provides the MDToolBuild alias for the mdtool which uses Monodevelop without GUI to compile your solution.

    public static void MDToolBuild(
           FilePath projectOrSolutionFile,
           Action<MDToolSettings> settings
    )
    

    Example usage in a Cake script:

    #addin "Cake.Xamarin"
    
    MDToolBuild(
       "./mySolution.sln",
       settings=> { settings.Configuration = "Debug"; },
    );