Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

build .net solution from batch file

I have a solution file comprising of 15 projects using a few third party dll references. I want to be able to build the solution from a batch file. What is the best way to do this?

Thanks

like image 855
stackoverflowuser Avatar asked Oct 07 '10 19:10

stackoverflowuser


People also ask

What is %1 in a batch file?

When used in a command line, script, or batch file, %1 is used to represent a variable or matched string. For example, in a Microsoft batch file, %1 can print what is entered after the batch file name.

How do I run a batch file from the Visual Studio command prompt?

The key to executing a batch file directly in Visual Studio is to Add one using the External Tools selection of the Tools menu. To do this, you: Create a simple batch program that executes other batch programs.


2 Answers

Run msbuild - for example:

msbuild MySolution.sln /p:Configuration=Release /p:Platform="Any CPU"
like image 89
Jon Skeet Avatar answered Oct 26 '22 23:10

Jon Skeet


One of the simplest ways is to execute msbuild with the solution file as input:

@echo off
call %windir%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe path\to\solution.sln

If this is done in a Visual Studio command prompt you can skip the path to msbuild.exe.

like image 41
Fredrik Mörk Avatar answered Oct 27 '22 00:10

Fredrik Mörk