Is it possible to build Visual Studio solutions without having to fire up MonoDevelop?
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.
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>.
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.
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 .
for now as per August 2017 we can use
command as xbuild is depreciated.
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.
xbuild now supports solutions and projects, both VS2005 and VS2008.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With