Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a Batch File for Visual Studio Command Prompt

I want to create a batch file for Visual Studio 2008 x64 Cross Tools Command Prompt to do something continuesly in my PC, here is the senario.

svn update delete some files MSBuild MySolutiuon.sln delete some files xcopy somefiles MSBuild AutomateBuildConfiguration.xml /p:Configuration=Release xcopy some files delete somefiles xcopy some files  create a Zip file if it is possible // it is not neccessary 

I can do most of it with simple Command Prompt and MSBuild parts with Visual Studio Command Prompt, but as these two prompt are different I cannot complete my senario.

I have tested all command and work great for me, Give me a solution if you know what should I do.

I checked this and didn't underestand anything Thank you in advance

like image 299
Nasser Hadjloo Avatar asked May 04 '11 05:05

Nasser Hadjloo


People also ask

How do I create a .bat file in Visual Studio?

Show activity on this post. Make the first line of your batch file set up the VS environment: call "C:\Program Files\Microsoft Visual Studio 2008\VC\vcvarsall. bat" x86_amd64 svn update delete some files MSBuild MySolutiuon.

How do you write a batch file in CMD?

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.

How do I run a batch file in Visual Studio code?

Then, use the Tasks: Run Build Task hotkey ( Ctrl Shift B by default). You can have more than one such task. At most one task can have "isDefault": true , the one that Ctrl Shift B should run.

What is batch command in CMD?

In Windows, the batch file is a file that stores commands in a serial order. The command line interpreter takes the file as an input and executes in the same order. A batch file is simply a text file saved with the .bat file extension.


1 Answers

Make the first line of your batch file set up the VS environment:

call "C:\Program Files\Microsoft Visual Studio 2008\VC\vcvarsall.bat" x86_amd64 svn update delete some files MSBuild MySolutiuon.sln ... more commands ... 

x86_amd64 is the argument used for x64 Cross Tools Command Prompt.

Once vcvarsall.bat has run, msbuild will be available in the path for the rest of the commands in your batch file.

Alternatively, if you aren't using Visual C++, you might prefer to set up the environment with this line (instead of the call to vcvarsall.bat):

For VS 2008:

call "%vs90comntools%vsvars32.bat" 

For VS 2010:

call "%vs100comntools%vsvars32.bat" 

For VS 2012:

call "%vs110comntools%vsvars32.bat" 

For VS 2013:

call "%vs120comntools%vsvars32.bat" 

For VS 2015:

call "%vs140comntools%vsvars32.bat" 

For VS 2017:

Batch is now called vc not vs.

call "%vs140comntools%\..\..\VC\Auxiliary\Build\vcvars32.bat" 

or better

call "%vs140comntools%\VsDevCmd.bat" 
like image 103
sean e Avatar answered Sep 29 '22 19:09

sean e