views:

5507

answers:

5

I'm scripting the checkout, build, distribution, test, and commit cycle for a large C++ solution that is using Monotone, CMake, Visual Studio Express 2008, and custom tests.

All of the other parts seem pretty straight-forward, but I don't see how to compile the Visual Studio solution without getting the GUI.

The script is written in Python, but an answer that would allow me to just make a call to: os.system would do.

+1  A: 

msbuild is your friend.

msbuild "C:\path to solution\project.sln"
Adam Davis
I've seen that fail in odd situations due to differences in how MSBuild and DevEnv process .sln files.
Jeffrey Hantin
A: 

Check out MSBuild

dgrant
+1  A: 

MSBuild usually works, but I've run into difficulties before. You may have better luck with

devenv /Build YourSolution.sln
Jeffrey Hantin
MSBuild doesn't work with Visual Fortran projects ( *.vfproc ). Thanks for pointing me towards devenv, which does.
Maik Beckmann
+11  A: 

I know of two ways to do it.

Method 1
The first method (which I prefer) is to use msbuild:

msbuild project.sln /Flags...

Method 2
You can also run:

vcexpress /build project.sln /Flags...

The vcexpress option returns immediately and does not print any output. I suppose that might be what you want for a script.

Note that DevEnv is not distributed with Visual Studio Express 2008 (I spent a lot of time trying to figure that out when I first had a similar issue).

So, the end result might be:

os.system("msbuild project.sln /p:Configuration=Debug")

You'll also want to make sure your environment variables are correct, as msbuild and vcexpress are not by default on the system path. Either start the Visual Studio build environment and run your script from there, or modify the paths in Python (with os.putenv).

Moses Schwartz
A: 

I'm doing something different but basic idea is same. I'm building a C# App to compile & Build MFC Code i googled a-lot and I found your thread really helpful but i'm facing 2 problems;

1) Related To Compile as my MFC project have 4 different configuration 2 for Oracle 10 & 2 for Orace 8i but when i pass Oracle 10 Configuration in command-line it doesn't recognize it & builds the project at oralce 8 Configuration

Oralce 8 Configuration : a) Debug b) Release

Oralce 10 Configuration : a) Debug (Ora 10) b) Release (Ora 10)

but when is pass these values in command line for e.g;

devenv /build Debug (Ora 10) "c:\MySolutions\Visual Studio Projects\MySolution\MySolution.sln"

it doesn't build it at the given configuration from command-line

2) Related to Process Class in C# i'm calling CMD from Process.Start(Path to CMD) it starts the Command-Prompt but after opening the windows it closes it (I said closes it because i checked the Process Tab in task-manager & it wasn't there).

Please Help me with this.

Thanks

KhanZeeshan