[ACCEPTED]-How to get cmd line build command for VS solution?-build-process
Navigate to your Programs menu > Microsoft 10 Visual Studio 2005 > Visual Studio Tools 9 > Visual Studio 2005 Command Prompt.
this command prompt has all the necessary 8 .NET environment variables set for the the 7 command line session. You can change directory 6 to your solution directory (e.g. c:\projects\mySolution) and 5 run
Msbuild.exe mySolution.sln
You can see the various options available 4 using msbuild /?
Msbuild is located at C:\Windows\Microsoft.NET\Framework\v2.0.50727
On 3 top of msbuild /? quick-option check, you 2 may reference the MSBuild Command Line Reference page for more explanations 1 on its usage. And how to build specific targets in solutions.
In addition to what @JohnIdol says correctly, I've 13 found that you need to setup a number VS 12 environment variables. I don't have the 11 name of the batch file in front of me, but 10 you can modify or 'I think' use it. It is 9 in VS program files tree somewhere. Also, as 8 I remember you don't want to be in a standard 7 shell but a .NET setup shell for some paths 6 and such. I'll add details later when I'm 5 at a Windows PC with VS.
EDIT: The batch 4 file mentioned is a shortcut in ProgFiles 3 menu. Here is the details of its properties.
%comspec% /k ""C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat""x86"
Here 2 is my batch file, using MSBuild to call 1 the solution.
@echo off
:: setup VS2005 command line build environment
set VSINSTALLDIR=C:\Program Files\Microsoft Visual Studio 8
set VCINSTALLDIR=C:\Program Files\Microsoft Visual Studio 8\VC
set FrameworkDir=C:\WINDOWS\Microsoft.NET\Framework
set FrameworkVersion=v2.0.50727
set FrameworkSDKDir=C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0
set DevEnvDir=C:\Program Files\Microsoft Visual Studio 8\Common7\IDE
set PATH=C:\Program Files\Microsoft Visual Studio 8\Common7\IDE;C:\Program Files\Microsoft Visual Studio 8\VC\BIN;C:\Program Files\Microsoft Visual Studio 8\Com
mon7\Tools;C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\bin;C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\bin;C:\Program Files\Microsoft
Visual Studio 8\SDK\v2.0\bin;C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;C:\Program Files\Microsoft Visual Studio 8\VC\VCPackages;%PATH%
set INCLUDE=C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\INCLUDE;C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE;C:\Program Files\Microsoft Visual
Studio 8\VC\PlatformSDK\include;C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\include;%INCLUDE%
set LIB=C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\LIB;C:\Program Files\Microsoft Visual Studio 8\VC\LIB;C:\Program Files\Microsoft Visual Studio 8\VC
\PlatformSDK\lib;C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\lib;%LIB%
set LIBPATH=C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\LIB
echo %0 %*
echo %0 %* >> %MrB-LOG%
cd
if not ""=="%~dp1" pushd %~dp1
cd
if exist %~nx1 (
echo VS2005 build of '%~nx1'.
echo VS2005 build of '%~nx1'. >> %MrB-LOG%
set MrB-BUILDLOG=%MrB-BASE%\%MrB-WORK%.%MrB-NICEDATE%.%MrB-NICETIME%.build-errors.log
msbuild.exe %~nx1 /t:Rebuild /p:Configuration=Release > %MrB-BUILDLOG%
findstr /r /c:"[1-9][0-9]* Error(s)" %MrB-BUILDLOG%
if not errorlevel 1 (
echo ERROR: sending notification email for build errors in '%~nx1'.
echo ERROR: sending notification email for build errors in '%~nx1'. >> %MrB-LOG%
call mrb-email "Mr Build isn't happy about build errors in '%~nx1'" %MrB-BUILDLOG%
) else (
findstr /r /c:"[1-9][0-9]* Warning(s)" %MrB-BUILDLOG%
if not errorlevel 1 (
echo ERROR: sending notification email for build warnings in '%~nx1'.
echo ERROR: sending notification email for build warnings in '%~nx1'. >> %MrB-LOG%
call mrb-email "Mr Build isn't happy about build warnings in '%~nx1'" %MrB-BUILDLOG%
) else (
echo Successful build of '%~nx1'.
echo Successful build of '%~nx1'. >> %MrB-LOG%
)
)
) else (
echo ERROR '%1' doesn't exist.
echo ERROR '%1' doesn't exist. >> %MrB-LOG%
)
popd
For VS .NET 2003 you can use devenv.exe 2 to build the solution/project from command 1 line.
devenv solutionfile.sln /build solutionconfig
E.g. usage in batch file:
call "C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\vsvars32.bat"
devenv Tools.sln /build "Release"
If you want to see the exact command line 7 as provided by VS (rather than work it out) then 6 you could try replacing the MSBuild.exe 5 with your own console app that prints out 4 all the parameters to a file.
You could also 3 write out all the environment variables 2 supplied to check which ones VS provides 1 in the background.
I just want to thank the Bejoy on the example. I 6 had big problems with solution rebuild on 5 setup pre build event because they removed 4 most of the macros and this helped me a 3 lot.
Here is my solution based on Bejoy's 2 (considering that .bat file is located in 1 setup root folder which is part of solution):
call "%VS100COMNTOOLS%\vsvars32.bat"
devenv "%CD%\..\soulutionfile.sln" /build "Release"
You can start msbuild from the command line. msbuild 11 understands .sln (solution) files. You can 10 specify the .sln file and the build configuration 9 (debug, release etc.) from the command line.
http://msdn.microsoft.com/en-us/library/ms164311.aspx
Here 8 is the documentation on what you can do 7 with msbuild. MSBuild.exe is installed with 6 the .net framework, not with visual studio. You 5 can find it in c:\windows\microsoft.net\framework\v3.5 4 (or v2.0.50727)
I searched a bit and found 3 that you can also do a command line build 2 with visual studio using devenv.exe /build, more 1 info here:
http://msdn.microsoft.com/en-us/library/xee0c8y7(VS.80).aspx
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.