Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build solution using batchfile

I want to build .NET solution using batch file.

I am aware that I need to use following statement

devenv /build release "D:\Source Code\Source\test.sln"

But I do not know how to create batch file which will execute on VS command prompt.

like image 745
Ram Avatar asked Apr 28 '10 12:04

Ram


People also ask

How do you program a batch file?

To create a Windows batch file, follow these steps: Open a text file, such as a Notepad or WordPad document. Add your commands, starting with @echo [off], followed by, each in a new line, title [title of your batch script], echo [first line], and pause. Save your file with the file extension BAT, for example, test.

What is batch file explain with example?

A batch file is a script file that stores commands to be executed in a serial order. It helps automate routine tasks without requiring user input or intervention. Some common applications of batch files include loading programs, running multiple processes or performing repetitive actions in a sequence in the system.

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.


1 Answers

The visual studio command prompt just loads some variables and path settings. That's all it is, it's nothing specially, it's not a different command prompt, it's the same command prompt with some settings configured. You can load the same settings in your own batch file by including the following line at the top:

call "C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86

(Obviously, for different versions of VS, the path might change slightly)

You can replace "x86" with the appropriate architecture for your machine. The permitted values are:

  • x86
  • amd64
  • x64
  • ia64
  • x86_amd64
  • x86_ia64

That said, I don't think you actually need to load all the vars/paths all you really need to do is provide the full path to the devenv.exe file. You could try this instead:

"c:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe" /build release "D:\Source Code\Source\test.sln"

(Again, the path will change for different versions of visual studio)

like image 193
Simon P Stevens Avatar answered Sep 18 '22 15:09

Simon P Stevens