Building software against different versions of .NET with MSBuild in Orcas
Faisal Mohamood, a program manager on the MSBuild team, has written a pair of posts about the “multi-targeting” feature in the Orcas version of MSBuild. Multi-targeting allows you to build your code against the .NET 2.0, 3.0, or 3.5 frameworks, according to your requirements. This is great because it allows folks to have some projects use the newest framework and other projects remain on an older framework by simply specifying the tool set in the project files.
So if you were curious enough to dig into what the October 2006 Orcas CTP contained, you might have seen something related to MSBuild – namely, Multi-Targeting. Here’s what the release notes for the CTP says, with respect to MSBuild and Multi-Targeting:
MSBuild Multi-targeting: Support multitargeting within the IDE by enabling Visual Studio to leverage MSBuild using the tasks and targets that were shipped in Visual Studio 2005. Additionally, command line solutions will build using the toolset appropriate for the .NET Framework version that is being targeted.
I just wanted to provide more clarity around what this means, because it does not entirely present an accurate picture. To make things worse, the topic of multi-targeting itself is a bit cloudy and confusing, so I want to shed some light on the big picture.
So, the next question obviously is, what happens when you build a project using a specific ToolsVersion, and what are the mechanics in action behind the scenes?
To understand this, we have to know a bit about how our project files are described.