Welcome to MSDN Blogs Sign in | Join | Help

MSBuild, Orcas, and Multi-targeting

Disclaimer: Since I am talking about Orcas, and as of yet unreleased software, what follows is subject to change.

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. 

Firstly, multi-targeting support within Visual Studio Orcas is not entirely available in the October CTP just yet. The MSBuild support is all there, but the IDE features to leverage it fully are still in development. However, MSBuild is entirely capable of multi-targeting as described, so I’ll try to distill what “multi-targeting” means as it relates to MSBuild.

By the time Orcas releases, there will be three different frameworks that will be available to you for building your applications:  

  • .NET Framework 2.0 (Visual Studio 2005 timeframe)
  • .NET Framework 3.0 (Vista timeframe)
  • .NET Framework 3.5 (Orcas timeframe).

What makes things even more interesting is that by the time Orcas ships, there will only be two toolsets that can build code for these three frameworks, so toolsets and frameworks don’t exactly map one to one. By toolset, I am referring to the set of tools and build process that ships in the .NET Framework that allow you to build your code to run on the platform. The two toolsets are:

  • .NET Framework 2.0 toolset (csc.exe, vbc.exe, tasks and targets files that shipped along with Visual Studio 2005)
  • .NET Framework 3.5 toolset (csc.exe, vbc.exe, tasks and targets files that will ship in Orcas)

Today, you use the .NET Framework 2.0 toolset to build code targeting .NET Framework 2.0 and .NET Framework 3.0. Also, MSBuild version numbers line up with the version of the framework that it ships in - so we are calling MSBuild that you already use today as 2.0, and the Orcas version is currently called MSBuild 3.5. 

In order to provide a compelling upgrade story and an easy migration scenario between Visual Studio 2005 and Visual Studio Orcas, we (MSBuild team) had to follow a few ground rules without compromise. It turns out that these rules also boil down to fundamental principles that any good build tool should adhere to:

  1. Always maintain clean separation between the build engine and the toolset. A new version of the MSBuild engine/MSBuild.exe should be able to build using a previously shipped toolset.
  2. When building projects authored to build using an older toolset, a newer version of MSBuild.exe should not automatically move you forward to the new toolset, forcing you to take on additional dependencies that you don't need.
  3. Switching to the new toolset and building using a newer set of tools, compilers, etc should be as easy, as long as you are moving between compatible versions of the framework.

So how does all of this manifest itself in the Orcas CTP that I started this little post with? That's the fun part.

The Orcas tools are installed in the %windir%\Microsoft.Net\Framework\v3.5.xxxxx. That's where the new version of MSBuild lives in Orcas (at least for now - remember, this is all very preliminary and subject to change as we tweak things). MSBuild 3.5 is entirely side by side with MSBuild 2.0. Here's a quick rundown of what it means to use MSBuild 3.5:

  • You can use it to build projects and solutions created using Visual Studio 2005, and it will continue to use the 2.0 tools and targets files to build the project - no new tools are used at all, giving you the same build results as if you were using the previous version of MSBuild. You will want to do this to use the new engine features, improved performance of the new version of MSBuild without taking on a new build process.
  • You can use it to build existing .NET 2.0 / Visual Studio 2005 projects using the Orcas / .NET Framework 3.5 toolset by using the /ToolsVersion:3.5 from the command line. The other available toolset of course, is /ToolsVersion:2.0 to explicitly build using 2.0.
  • You can author projects that automatically build with the new toolset - simply edit your Visual Studio authored project file, add a ToolsVersion="3.5" attribute on the <Project> element, and build with msbuild.exe version 3.5.
  • Visual Studio Orcas will explicitly author projects to use the new 3.5 toolset - this is because Visual Studio Orcas requires the new compilers and targets files that ships in the .NET Framework 3.5.
  • If you are using the 3.5 toolset, you can also specify a <TargetFrameworkVersion> property in your project that will give you version specific build process rules based on the framework you are targeting. It is this property that enables MSBuild and the rest of the 3.5 tools to target all three different versions of the framework. Obviously, the 2.0 build process does not honor this property in the same way the 3.5 toolset does. I will get into the details of TargetFrameworkVersion in a subsequent post.

I've tried to show the side by side aspects in the figure below. Note that MSBuild 2.0 cannot use the 3.5 toolset, but MSBuild 3.5 can consume both toolsets.

 

In summary, here are the key takeaways

  • MSBuild 3.5 will not force you to a new toolset and build process
  • The concept of a Toolset (specified using ToolsVersion attribute) is new - think of a toolset as a matched set of tasks, targets, and command line tools that can build for a particular version of the framework.
  • MSBuild Orcas will include a build process that is "Target Framework Version" aware, and can support .NET Framework 2.0, 3.0 and 3.5.
  • You can build a project with either the 2.0 or the 3.5 toolset by explicitly overriding the ToolsVersion you use. 

That's just the start of it - there's a ton of functionality in there, and I will cover it over the coming weeks. Please let us know what you think about all of this, as gathering feedback is the primary purpose of releasing CTPs. Like I mentioned earlier, as is with any pre-release software, keep in mind that all of this could change based on what you tell us and based on what we find!

[ Author : Faisal Mohamood ]

Published Friday, November 03, 2006 2:08 AM by msbuild

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

Tuesday, November 14, 2006 8:56 PM by MSBuild Team Blog

# Multi-Targeting : How does it work?

So in my last post , I described the multi-targeting feature at a very high level. I discussed how there

Wednesday, November 15, 2006 9:23 PM by Buck Hodges

# 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"

Thursday, November 16, 2006 12:49 AM by Tatis

# Visual Studio Orcas y Multi-Targeting

La siguiente versi&oacute;n de Visual Studio (por ahora llamada Orcas ), soportar&aacute; la compilaci&oacute;n

Thursday, December 28, 2006 8:31 PM by Ali Pasha's WebLog...

# Supporting Visual Studio 2005 extensions for .NET Framework 3.0 (WCF)...

I don't think that 'support' should block anyone from using the extensions to adopt WCF, as any projects

Saturday, February 10, 2007 4:45 PM by CoqBlog

# Le prochain Visual Studio (Orcas) devrait permettre de développer pour .NET 2.0

Jusqu'ici une règle assez simple régissait l'utilisation de Visual Studio : à chaque Framework son Visual

Sunday, April 22, 2007 3:40 AM by Eric Hu's Weblog

# Orcas and .NetFx 3.5 ENU Beta1

微軟副總, Somasegar 已經在他的部落格正式宣布下一代Visual Studio開發工具, 代號 "Orcas", 英文版的 Beta1 已經推出. MSDN 訂戶可以搶先 下載 囉! 不過 Beta1

Tuesday, April 24, 2007 4:34 PM by Signs on the Sand

# Finally multitargeting Visual Studio

I installed Microsoft Visual Studio Codename Orcas Beta1 and was really pleased to see that it's finally capable of targeting not only .NET 3.5. It supports .NET versions 2.0, 3.0 and 3.5. This is going to be the first multitargeted Visual Studio version,

Friday, May 04, 2007 6:41 PM by MSBuild Team Blog

# New Registry syntax in MSBuild v3.5

During development of the multi-targeting feature of the next version of MSBuild, we found it convenient

Wednesday, June 27, 2007 11:10 AM by Ion Singh

# re: MSBuild, Orcas, and Multi-targeting

What's going on with setup projects in orcas?

Tuesday, July 17, 2007 9:26 PM by LC

# re: MSBuild, Orcas, and Multi-targeting

Saturday, September 08, 2007 2:56 PM by SRLTeam

# Building .NET 3.0 projects from Team Foundation Build 2005 not supported

Building .NET 3.0/3.5 projects from Team Foundation Build 2005 not supported. Team Foundation Build 2005

Monday, October 22, 2007 1:37 PM by Aaron Hallberg

# Error MSB3021 and Team Build

The error message " error MSB3021: Unable to copy file "&lt;filename&gt;" to "&lt;output location&gt;".

Monday, October 22, 2007 1:44 PM by Noticias externas

# Error MSB3021 and Team Build

The error message &quot; error MSB3021: Unable to copy file &quot;&lt;filename&gt;&quot; to &quot;&lt;output

Tuesday, October 30, 2007 11:00 AM by Aaron Hallberg

# Building VC++ 2005 Projects With Team Build 2008

MSBuild introduced a multi-targeting feature in VS 2008 that allows it to build managed code projects

Tuesday, October 30, 2007 11:59 AM by Noticias externas

# Building VC++ 2005 Projects With Team Build 2008

MSBuild introduced a multi-targeting feature in VS 2008 that allows it to build managed code projects

Thursday, April 03, 2008 2:12 AM by prajeesh

# re: MSBuild, Orcas, and Multi-targeting

whether MSBuild3.5 supports building .vdproj projects?

Thursday, April 03, 2008 4:08 PM by Tibi

# re: MSBuild, Orcas, and Multi-targeting

Can i build my VS2008 projects with msbuild in computer where is no Visual Studio installed?

Monday, July 20, 2009 1:46 PM by Mahendra Ghedia

# re: MSBuild, Orcas, and Multi-targeting

Yes you can build your project using MSBuild with only .net framework installed (no visual studio required)

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker