Building Visual Studio Projects with Rake

We are building a Rails applicaiton that has a C++ client developed under windows, and needed a nice way to script things.  Since the web side of the project was in rails it seemed natural to use rake to build the C++ stuff.  Pretty simple, but in order for the devenv to get loaded we had to load some of the envorment varables up for rake. Once that was done everyting has been easy.

My Rakefile:

Visual Studio 2008 Environment Settings:

ENV[“VSINSTALLDIR”] = ‘C:Program FilesMicrosoft Visual Studio 9.0’
ENV[“VCINSTALLDIR”] = ‘C:Program FilesMicrosoft Visual Studio 9.0VC’
ENV[“DevEnvDir”] = ‘C:Program FilesMicrosoft Visual Studio 9.0Common7IDE’
ENV[“PATH”] = ‘C:Program FilesMicrosoft Visual Studio 9.0Common7IDE;C:Program FilesMicrosoft Visual Studio 9.0VCBIN;C:Program FilesMicrosoft Visual Studio 9.0Common7Tools;C:WINDOWSMicrosoft.NETFrameworkv3.5;C:WINDOWSMicrosoft.NETFrameworkv2.0.50727;C:Program FilesMicrosoft Visual Studio 9.0VCVCPackages;’ + ENV[“PATH”]
ENV[“INCLUDE”] = ‘C:Program FilesMicrosoft Visual Studio 9.0VCATLMFCINCLUDE;C:Program FilesMicrosoft Visual Studio 9.0VCINCLUDE;C:Program Filesboostboost_1_35_0’
ENV[“LIB”] = ‘C:Program FilesMicrosoft Visual Studio 9.0VCATLMFCLIB;C:Program FilesMicrosoft Visual Studio 9.0VCLIB;C:Program Filesboostboost_1_35_0lib’
ENV[“LIBPATH”] = ‘C:WINDOWSMicrosoft.NETFrameworkv3.5;C:WINDOWSMicrosoft.NETFrameworkv2.0.50727;C:Program FilesMicrosoft Visual Studio 9.0VCATLMFCLIB;C:Program FilesMicrosoft Visual Studio 9.0VCLIB’

WiX Environment Settings

WIX_PATH=“”C:/Program Files/Windows Installer XML v3/bin”“
CANDLE= WIX_PATH + “candle”
LIGHT = WIX_PATH + “light”

desc “Build the project in release”
task ‘release’ do
system ‘VCBuild path/to/project.vcproj Release /rebuild /nologo’
end

task :default => [:release]