Hi ,
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.
Hi ,
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.
Not sure if I understand the question.
Just create a file called test.bat, add the statement you've written above to that file and then just open a VS command prompt and type [pathtobatfile]\test.bat.
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)
The sample batch file below will detect the install directory that contains devenv.exe by looking it up in the registry (for VS2005, can easily be adapted for other versions) and executes devenv.exe. Is this what you're looking for?
@echo off
CALL :GETVS2005DIR
IF "%VS2005DIR%" == "" GOTO NOVS2005
IF NOT EXIST "%VS2005DIR%" GOTO NOVS2005
%VS2005DIR%devenv.exe ...
GOTO :EOF
:GETVS2005DIR
for /f "tokens=1,2* delims= " %%i in ('reg query HKLM\Software\Microsoft\VisualStudio\8.0 /v InstallDir') do set VS2005DIR=%%k
GOTO :EOF
:NOVS2005
echo.
echo Visual Studio 2005 installation directory not found
echo.
GOTO :EOF
Note also that as long as your solution does not contain a Setup project, you will normally be able to build it using MSBUILD, which is simpler and works on a machine without Visual Studio installed:
REM Check MsBuild is available (this is for V2.0, use a different version if desired)
SET MSBUILD=%WINDIR%\Microsoft.NET\Framework\v2.0.50727\MsBuild.exe
IF NOT EXIST "%MSBUILD%" GOTO NOMSB
"%MSBUILD%" MySolution.sln /t:rebuild /p:configuration=Debug /verbosity:quiet
GOTO :EOF
:NOMSB
echo.
echo MSBUILD not found
echo.
GOTO :EOF