Search code examples
visual-studio-2005

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?


Solution

  • 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