Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use a specific Windows SDK with MSBuild?

I have a large project made of many C++ and C# projects, and a MSBuild (3.5) script to build the whole thing. This script is based on the VCBuild (C++ projects) and MSBuild (C# projects) tasks. It is regularly executed by a Continuous Integration server.

I want to be able to select a specific Windows SDK (v6.0A, v7.0, v7.1...) to be used for compilation. As I have many branches in my repository that would ultimately need a different SDK version, I need a way to select the right one before each compilation.

On my computer, I have been able to setup a batch script that calls the right SetEnv.cmd before launching the MSBuild script. But this solution is not usable on the CI server as the MSBuild script is executed directly.

Do you know of a way to achieve the equivalent of SetEnv.cmd under MSBuild?

like image 395
Mac Avatar asked Jun 10 '10 15:06

Mac


1 Answers

You could create a custom MSBuild task that uses Environment.SetEnvironmentVariable to set the appropriate environment variable values depending on the specified platform SDK version. Check the vcvars32.bat (or vcvars64.bat depending on your target configuration) to see what environment variables need to be set.

like image 143
Jim Lamb Avatar answered Oct 19 '22 01:10

Jim Lamb