Dave
Dave

Reputation: 895

Build one project inside a solution from the command line

I am working on a large C++ solution in Visual Studio 2005. I want to log all of the output from the build of one project within that solution. The output window in VS seems to be malfunctioning. I suspect there is too much output for it to handle. I can't copy the output and I can't even save it to disk.

My idea is to build the project on the command line and just redirect the output to a file. I'm not sure what command I have to execute in order to build a project in the context of a solution. I tried to just vcbuild the project, but I think it's missing data inherited from the solution.

Any ideas?

Upvotes: 6

Views: 4430

Answers (3)

granadaCoder
granadaCoder

Reputation: 27874

C# version with MSBuild (put the below code in a .bat file)

set msBuildDir=%WINDIR%\Microsoft.NET\Framework\v4.0.30319
set msBuildDir=%WINDIR%\Microsoft.NET\Framework\v2.0.50727

call %msBuildDir%\msbuild ".\SomeFolder\MyCSharpProject.csproj" /p:Configuration=Release /l:FileLogger,Microsoft.Build.Engine;logfile=Manual_MSBuild_ReleaseVersion_One_Project_CSharp_LOG.log


set msBuildDir=

Or for C++:

set msBuildDir=%WINDIR%\Microsoft.NET\Framework\v2.0.50727
set msBuildDir=%WINDIR%\Microsoft.NET\Framework\v4.0.30319

call %msBuildDir%\msbuild ".\Project1\Project1\Project1.vcxproj" /p:Configuration=Release /l:FileLogger,Microsoft.Build.Engine;logfile=Manual_MSBuild_ReleaseVersion_One_Project_C_Plus_Plus_LOG.log

set msBuildDir=

You'll need to pick your framework (2.0 or 4.0 (or other??), where I have

set msBuildDir=%WINDIR%\Microsoft.NET\Framework\vA.BCDEF

Just comment out or remove the framework version you do not want.

I had a solution with five (sub) projects. I built the "bottom most" project. And it only built this (single) assembly.

Keep in mind if the project you pick has dependencies, it'll build those as well. AKA, if you pick the "top most" assembly, it will build everything it needs.

Upvotes: 0

Peter Mortensen
Peter Mortensen

Reputation: 31585

Use DevEnv from the command line:

DevEnv /Build Debug /Project ProjectName  %SOLUTION_FILE%

where %SOLUTION_FILE% is an environment variable holding the full path to the solution file and ProjectName is the name of the project. The output will go to standard output.

The entire solution can be rebuild with:

DevEnv /Rebuild Debug %SOLUTION_FILE%

Example; for an (installer) project named MSQuantSetup:

set SOLUTION_FILE=D:\dproj\MSQall\MSQuant\MSQuant.sln
DevEnv /Build Debug /Project MSQuantSetup  %SOLUTION_FILE%

Or directly without the environment variable:

DevEnv /Build Debug /Project MSQuantSetup  D:\dproj\MSQall\MSQuant\MSQuant.sln

Upvotes: 8

zweihander
zweihander

Reputation: 6295

Take a look at this page, I think this is what you are looking for. Don't forget the /Project parameter if you want to build only one project.

Upvotes: 1

Related Questions