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.
This question is related to
c++
python
visual-studio-2008
command-line
MSBuild usually works, but I've run into difficulties before. You may have better luck with
devenv YourSolution.sln /Build
DEVENV works well in many cases, but on a WIXPROJ to build my WIX installer, all I got is "CATASTROPHIC" error in the Out log.
This works: MSBUILD /Path/PROJECT.WIXPROJ /t:Build /p:Configuration=Release
To be honest I have to add my 2 cents.
You can do it with msbuild.exe. There are many version of the msbuild.exe.
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\msbuild.exe C:\Windows\Microsoft.NET\Framework64\v3.5\msbuild.exe C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe
C:\Windows\Microsoft.NET\Framework\v2.0.50727\msbuild.exe C:\Windows\Microsoft.NET\Framework\v3.5\msbuild.exe C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
Use version you need. Basically you have to use the last one.
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe
So how to do it.
Run the COMMAND window
Input the path to msbuild.exe
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe
"C:\Users\Clark.Kent\Documents\visual studio 2012\Projects\WpfApplication1\WpfApplication1.sln"
Add any flags you need after the solution path.
Press ENTER
Note you can get help about all possible flags like
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe /help
DEVENV works well in many cases, but on a WIXPROJ to build my WIX installer, all I got is "CATASTROPHIC" error in the Out log.
This works: MSBUILD /Path/PROJECT.WIXPROJ /t:Build /p:Configuration=Release
Using msbuild
as pointed out by others worked for me but I needed to do a bit more than just that. First of all, msbuild
needs to have access to the compiler. This can be done by running:
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat"
Then msbuild
was not in my $PATH so I had to run it via its explicit path:
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe" myproj.sln
Lastly, my project was making use of some variables like $(VisualStudioDir)
. It seems those do not get set by msbuild
so I had to set them manually via the /property
option:
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe" /property:VisualStudioDir="C:\Users\Administrator\Documents\Visual Studio 2013" myproj.sln
That line then finally allowed me to compile my project.
Bonus: it seems that the command line tools do not require a registration after 30 days of using them like the "free" GUI-based Visual Studio Community edition does. With the Microsoft registration requirement in place, that version is hardly free. Free-as-in-facebook if anything...
msbuild "C:\path to solution\project.sln"
MSBuild usually works, but I've run into difficulties before. You may have better luck with
devenv YourSolution.sln /Build
msbuild "C:\path to solution\project.sln"
To be honest I have to add my 2 cents.
You can do it with msbuild.exe. There are many version of the msbuild.exe.
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\msbuild.exe C:\Windows\Microsoft.NET\Framework64\v3.5\msbuild.exe C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe
C:\Windows\Microsoft.NET\Framework\v2.0.50727\msbuild.exe C:\Windows\Microsoft.NET\Framework\v3.5\msbuild.exe C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
Use version you need. Basically you have to use the last one.
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe
So how to do it.
Run the COMMAND window
Input the path to msbuild.exe
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe
"C:\Users\Clark.Kent\Documents\visual studio 2012\Projects\WpfApplication1\WpfApplication1.sln"
Add any flags you need after the solution path.
Press ENTER
Note you can get help about all possible flags like
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe /help
MSBuild usually works, but I've run into difficulties before. You may have better luck with
devenv YourSolution.sln /Build
msbuild "C:\path to solution\project.sln"
Using msbuild
as pointed out by others worked for me but I needed to do a bit more than just that. First of all, msbuild
needs to have access to the compiler. This can be done by running:
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat"
Then msbuild
was not in my $PATH so I had to run it via its explicit path:
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe" myproj.sln
Lastly, my project was making use of some variables like $(VisualStudioDir)
. It seems those do not get set by msbuild
so I had to set them manually via the /property
option:
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe" /property:VisualStudioDir="C:\Users\Administrator\Documents\Visual Studio 2013" myproj.sln
That line then finally allowed me to compile my project.
Bonus: it seems that the command line tools do not require a registration after 30 days of using them like the "free" GUI-based Visual Studio Community edition does. With the Microsoft registration requirement in place, that version is hardly free. Free-as-in-facebook if anything...
MSBuild usually works, but I've run into difficulties before. You may have better luck with
devenv YourSolution.sln /Build
msbuild "C:\path to solution\project.sln"
Source: Stackoverflow.com