Is it possible to build MSBuild files (visual studio sln) from the command line in Mono?

49,632

Solution 1

Current status (Mono 2.10, 2011): xbuild is now able to build all versions of Visual Studio / MSBuild projects, including .sln files. Simply run xbuild just as you would execute msbuild on Microsoft .Net Framework. You don't need Monodevelop installed, xbuild comes with the standard Mono installation.

If your build uses custom tasks, they should still work if they don't depend on Windows executables (such as rmdir or xcopy).

When you are editing project files, use standard Windows path syntax - they will be converted by xbuild, if necessary. One important caveat to this rule is case sensitivity - don't mix different casings of the same file name. If you have a project that does this, you can enable compatibility mode by invoking MONO_IOMAP=case xbuild foo.sln (or try MONO_IOMAP=all). Mono has a page describing more advanced MSBuild project porting techniques.

Mono 2.0 answer (2008): xbuild is not yet complete (it works quite well with VS2005 .csproj files, has problems with VS2008 .csproj and does not handle .sln). Mono 2.1 plans to merge the code base of mdtool (MonoDevelop command line build engine) into it, but currently mdtool is a better choice. mdtool build -f:project.sln or man mdtool if you have MonoDevelop installed.

Solution 2

for now as per August 2017 we can use

msbuild

command as xbuild is depreciated.

Solution 3

xbuild now supports solutions and projects, both VS2005 and VS2008.

Solution 4

I think you are looking for xbuild: http://www.mono-project.com/Microsoft.Build

Share:
49,632
Kris Erickson
Author by

Kris Erickson

Full Stack developer, in spare time blogger about programming and builder of things (Recipe Folder for example).

Updated on July 08, 2022

Comments

  • Kris Erickson
    Kris Erickson almost 2 years

    Is it possible to build Visual Studio solutions without having to fire up MonoDevelop?

  • Mauricio Scheffer
    Mauricio Scheffer over 14 years
    apparently mdtool has been renamed to mdrun
  • skolima
    skolima over 14 years
    It's the other way round, you have an outdated MonoDevelop.
  • yoyo
    yoyo over 11 years
    xbuild from 2.10.9 not giving me any joy. "error MSB4126: The specified solution configuration "Debug|web" is invalid" -- despite using /p:Platform="Any CPU" as advised in the error message.
  • Polluks
    Polluks about 4 years
    msbuild is not part of Debian so far