One of the really great features I worked on for our upcoming release is ".NET Framework Multitargeting" for Visual Studio. This allows you to build applications targeting any of these frameworks using Visual Studio 2008:
When targeting .NET Framework 2.0, for example, Visual Studio will try to protect you from using any features that are only available in a higher framework version. This lets you confidently use Visual Studio 2008 for targeting any of these three platforms. New projects can be created targeting any of these frameworks, and projects can later be changed to target a different framework.
We've heard over-and-over again from .NET developers about how much harder it is to move to the next framework version than to move to the next Visual Studio version. Upgrading to a new Visual Studio means installing on a few developer machines - upgrading to target a new framework means ensuring that every client of the application has the new framework installed. Because of this, we very often get asked about whether it's possible to target the older frameworks with the newer tools. With Visual Studio 2008 - we're enabling just that.
There's another reason this is important for Visual Studio 2008 in particular. With .NET 2.0, .NET 3.0 and .NET 3.5, we'll have released three framework versions in about 2 years - but only two Visual Studio versions. Because of this - Visual Studio 2008 needs to be a great tool for targeting both .NET3.0 and .NET3.5, and multitrargeting enables this. In addition, we want developers and development organizations to be able to easily move from Visual Studio 2005 to Visual Studio 2008 - and support for multitargeting lowers the barrier to entry - you can continue working on your .NET 2.0 applications in Visual Studio 2008.
The New Project and New Website dialogs now have an additional UI element to choose the framework version to target. Choosing a target will limit the set of available templates in the dialog. Additionally, templates that are available for multiple targets will be generated with different default references and usings/imports based on the framework target. Out of the box, the defaults are to target .NET3.5 - but, just like other options in the dialog, the choice is "sticky", so if you pick .NET2.0, it'll default to that in the future.
Since some templates are unaffected by the .NET Framework target - the description of the template also mentions whether or not a specific .NET Framework target will be applied.
You can change the framework target of your project at any time through the Project->Properties dialog. If you change the target to a higher framework version, you will be able to use the new API features available in that framework. If you change the target to a lower framework version, any references in your project which are no longer allowed will be disabled (but left in your References list), and compiling your project will likely result in build failures due to the missing assemblies. However, we've tried to ensure that changing to a lower framework is easily reversible.
In C# projects, the drop-down to make these changes appears on the Application tab, for VB projects it appears in the Compiler->Advanced... tab and for C++ projects it appears in the Framework and References section.
The real heart of multitargeting support is the Add Reference dialog (see "So, how does this work?" below for details).
In the ".NET" tab, references which are not available for the target framework are grayed out and cannot be added. A hover-tip message explains the reason why. All the assemblies that ship as part of the higher frameworks will be grayed out, as will any other assemblies which themselves have references to assemblies in the higher frameworks.
In the "Browse" tab, you can still browse to any assembly, but if that assembly requires a higher framework version than your project, a warning dialog will be presented.
Some of the items that can be added to a project are dependent on a minimum framework version. For example the "Linq to SQL Classes" item template requires .NET 3.5. The Add New Item dialog thus filters out these items that are not available for the project. Custom or third party templates can also set the framework versions they want to be available in - so that they can integrate correctly into this filtering.
The toolbox provides controls from many different assemblies - some of which may not be available for the framework target of your project. So any controls defined in assemblies which are not available on your target framework will be filtered out of the toolbox. For example, the ElementHost WinForms control which allows WPF interop as part of .NET3.0 is not available in the toolbox when building a WinForms project targeting .NET 2.0.
At the end of the day, .NET framework target is all about deployment prequisites. So in the Prerequisites dialog we've provided a few options for which .NET Framework package to include with your deployment.
Many of the new language features in the .NET languages can be used with any of the available .NET framework targets. So Visual Studio 2008 allows you to use C#3.0, VB9, and VC9 for all projects, including those targeting .NET2.0 and .NET3.0.
Websites are different in this regard - you cannot use the new language features in a web site targeting .NET 2.0 or .NET 3.0. This restriction is in place because Web Sites need to compile on the web server, and this requires that the new compilers be installed on the Web Server. Since these new compilers come as part of the .NET 3.5 framework, this framework is required on the web server to use new language features.
The Visual Studio 2008 Express products have a limited version of multitargeting. All of the infrastructure described above is available - except for the dropdown in the New Project Dialog. This keeps the multitargeting features out of the way for beginning and hobbyist developers - but ensures that projects can continue to move between Express and full versions of Visual Studio as they could in Visual Studio 2005.
The three frameworks supported by Visual Studio Orcas are each supersets of one another - instead of being replacements as the previous .NET Framework releases have been. One benefit of this is that .NET Framework Multitargeting can be based just on the available set of references. That is - when you target .NET3.0, the only things you should be prevented from using are those that depend on assemblies in .NET3.5 - and this can be done by ensuring that you don't accidentally reference these assemblies.
There is one caveat to this - called "red bits". These are the changes in the framework that are part of .NET Framework 2.0 Service Pack 1 and .NET Framework 3.0 Service Pack 1, both of which will be released along with Visual Studio 2008. These two service packs are required for .NET3.5 to be installed, and they include a few very targetted additions of new functionality to the .NET 2.0 and .NET 3.0 frameworks. This means that when you target .NET 2.0 in Visual Studio Orcas, you are really targeting .NET 2.0 SP1. This is similar to what happens when you are using Visual Studio 2003 after the .NET Framework 1.1 service pack is installed on your machine - so it's really nothing new. But for those who want to be extra cautious about their framework dependencies, it's somthing to be aware of.
Orcas Beta1 is available now, and includes almost all of the multitargeting support described above. Take a look and let us know what you think. Orcas Beta2, which will be available later this summer, will include everything described here - along with a ton of other improvements and bug fixes across the rest of Visual Studio 2008 and the .NET 3.5 Framework. As always, send us feedback through Connect.
PingBack from http://testsubdomain.netmoviehost.com/net-framework-multitargeting-in-visual-studio-2008-aka-orcas/
So the multi-targeting will not support the .NET 1.1 framework?
The company I work for has a lot of applications which are required to be built using the .NET 1.1 framework, but would like to consolidate our Visual Studio development tools.
No - Visual Studio 2008 will not support targeting .Net Framework 1.1. This is something we really wanted to be able to support - since we know there are a lot of .NET developers working on .NET 1.1 applications. However, it would have been significantly more difficult to go back and support .NET 1.1 which was a substantially different runtime.
Thus, to fit in this release, the decision ended up being either to not support multitargeting at all - or to support only targeting .NET2.0 and greater. Because we really wanted Visual Studio 2008 to be a great tool for at least both .NET 3.0 and .NET 3.5 - we decided to put in the most multitargeting support we could fit in this release.
Luke - Thanks for your response. Guess we'll have to wait for a hack like with VS2005 so we can integreate TFS 2008 with .NET 1.1!
As I mentioned the other day, beta2 is coming soon ...VS2008 is the first version of VS that will be
I'm not going to write a long note explaining once again that I've been too busy to post. We all know
There are several good new blogs from members of the Microsoft C# team. Nevertheless, the most important
So you are running Visual Studio 2008 but want to run the .Net 2.0 framework for your applications? Tough
In this blog post, I’ll explain the possibilities and limitations of using solutions and projects between
Somasegar's WebLog : TechEd Developer in Europe . If you are doing WPF, WCF, and/or WF development this
Somasegar's WebLog : TechEd Developer in Europe . If you are doing WPF, WCF, and/or WF development
I've got some problems with VS 2008 Multitargeting feature. After install VS 2008, my .Net Framework 2 System.Data assembly was somehow replaced for a newer version. The assembly version is the same but the behavior. Since installation the enum System.Data.SqlDbType is the new one with DaTime2, DateTimeOffset, and so on (introduced in .NET Framework 3.5). May it be a bug?