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.
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.
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.
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.
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:
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)
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