Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building Visual Studio 2008 solution from command line

I'm trying to automate the building process for a certain open source project. It will do an update on the SVN directory, use CMake to get a .sln file, and build that. I can successfully do this manually, and do svn and cmake from a batch script, but Now I need to build the solution.

A quick google search revealed:

devenv /build release /project <projname> <solutionfile>.sln

However, that uses the latest version of visual studio (Visual Studio Professional 2011), while the .sln file generated is for Visual C++ Express 2008. I have both versions installed on my computer. Is there a devenv I can use for Visual C++ Express 2008? Or is there a commandline argument to specify which version to use?

UPDATE

I tried using msbuild, but that didn't seem to like building .vcproj files directly, and I didn't want to build ALL the project files by having it build the .sln file. I ended up using this:

"C:\Program Files\Microsoft Visual Studio 9.0\VC\vcpackages\vcbuild.exe" <myproj>.vcproj "Release|Win32"
like image 759
Entity Avatar asked Nov 21 '11 17:11

Entity


People also ask

How do I compile a Visual Studio solution from the command line?

At the command line, type MSBuild.exe <SolutionName>. sln , where <SolutionName> corresponds to the file name of the solution that contains the target that you want to execute. Specify the target after the -target: switch in the format <ProjectName>:<TargetName>.

How do I rebuild a solution in Visual Studio?

To build or rebuild a single project In Solution Explorer, choose or open the project. On the menu bar, choose Build, and then choose either Build ProjectName or Rebuild ProjectName. Choose Build ProjectName to build only those project components that have changed since the most recent build.

How do I run a build in Visual Studio?

Build and run your code in Visual Studio To build your project, choose Build Solution from the Build menu. The Output window shows the results of the build process. To run the code, on the menu bar, choose Debug, Start without debugging. A console window opens and then runs your app.


2 Answers

I think you are using the wrong tool to build this. Rather than trying to drive the IDE from the command line you should simply use msbuild.

msbuild.exe projectname.proj /property:Configuration=Release

In order to set your environment up for the specific version of MSVC you need to call the vcvar.bat file from that specific version. This will set up the necessary environment variables needed by the build tools.

like image 160
David Heffernan Avatar answered Sep 22 '22 13:09

David Heffernan


For Visual Studio Express 2008 the IDE is called VCExpress.exe. Also you should probably specify the full path of the program when you have two versions installed:

C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\VCExpress.exe /build release /project <projname> <solutionfile>.sln
like image 30
Tobias Schlegel Avatar answered Sep 25 '22 13:09

Tobias Schlegel