Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get cmd line build command for VS solution?

This is probably easy but I am getting stuck: when I build a solution in Visual Studio - how do extract the exact cmd line for the current build command in order to be able to do the same build from VisualStudio console?

In the output window I can see the single projects in the solution build commands but not the one for the whole solution.

I am on VS2005.

Any help would be appreciated

like image 396
JohnIdol Avatar asked Nov 11 '08 10:11

JohnIdol


2 Answers

Navigate to your Programs menu > Microsoft Visual Studio 2005 > Visual Studio Tools > Visual Studio 2005 Command Prompt.

this command prompt has all the necessary .NET environment variables set for the the command line session. You can change directory to your solution directory (e.g. c:\projects\mySolution) and run

Msbuild.exe mySolution.sln 

You can see the various options available using msbuild /?

Msbuild is located at C:\Windows\Microsoft.NET\Framework\v2.0.50727

On top of msbuild /? quick-option check, you may reference the MSBuild Command Line Reference page for more explanations on its usage. And how to build specific targets in solutions.

like image 100
icelava Avatar answered Sep 18 '22 09:09

icelava


In addition to what @JohnIdol says correctly, I've found that you need to setup a number VS environment variables. I don't have the name of the batch file in front of me, but you can modify or 'I think' use it. It is in VS program files tree somewhere. Also, as I remember you don't want to be in a standard shell but a .NET setup shell for some paths and such. I'll add details later when I'm at a Windows PC with VS.

EDIT: The batch file mentioned is a shortcut in ProgFiles menu. Here is the details of its properties.

%comspec% /k ""C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat""x86" 

Here is my batch file, using MSBuild to call 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 
like image 45
kenny Avatar answered Sep 21 '22 09:09

kenny