Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

mono

msbuild

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

like image 241
Kris Erickson Avatar asked Sep 10 '08 17:09

Kris Erickson


People also ask

How do I run MSBuild from command line?

To run MSBuild at a command prompt, pass a project file to MSBuild.exe, together with the appropriate command-line options. Command-line options let you set properties, execute specific targets, and set other options that control the build process.

How do I create a sln file in MSBuild?

At the command line, type MSBuild.exe <SolutionName>. sln , where <SolutionName> corresponds to the file name of the solution that contains the target that you want to execute. Specify the target after the -target: switch in the format <ProjectName>:<TargetName>.

How do I get MSBuild command from Visual Studio?

To install MSBuild on a system that doesn't have Visual Studio, go to Build Tools for Visual Studio 2019, or install the . NET SDK. If you have Visual Studio, then you already have MSBuild installed. With Visual Studio 2022, it's installed under the Visual Studio installation folder.

How do I compile a sln file?

Go to your folder with your solution sln file, and just type msbuild. It will automatically start building the sln files. If you use nuget packages, you will get errors about missing packages. You may have read somewhere that you only need to type “msbuild /t:restore”, but I think that it's only works for .


3 Answers

for now as per August 2017 we can use

msbuild

command as xbuild is depreciated.

like image 42
profesor79 Avatar answered Oct 12 '22 03:10

profesor79


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.

like image 95
skolima Avatar answered Oct 12 '22 02:10

skolima


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

like image 40
radical Avatar answered Oct 12 '22 02:10

radical