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