Wednesday, August 1, 2007

VS 2008 multi targeting Support

I installed Visual Studio 2008 Beta 2 yesterday. There was no problem to install the program and this version works fine together with VS 2005 on the same machine.

When you open a 2005 solution in 2008 a wizard will perform an upgrade of the project files and the solution file. After the wizard was finished I checked the new solution file and compared it with the old one. There was one changed row.

The first row in the old solution file:Microsoft Visual Studio Solution File, Format Version 9.00# Visual Studio 2005

The first row in the new solution file:Microsoft Visual Studio Solution File, Format Version 10.00# Visual Studio 2008.NET 3.5 project file

The project files were the same. As you know VS 2008 has a multi targeting support. If you want to be able to run the same code in both VS 2005 and VS 2008 you can create a new solution file for VS 2008 and keep the old solution file for VS 2005. Only remember to update both files when you add or remove a project.

You can see what framework you use in the project files. Compare these two parts of a project file for the same win form project.

.NET 3.5 project file

<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>


.NET 2.0 project file

<ItemGroup> <Reference Include="System" /> <Reference Include="System.Data" /> <Reference Include="System.Deployment" /> <Reference Include="System.Drawing" /> <Reference Include="System.Windows.Forms" /> <Reference Include="System.Xml" /> </ItemGroup>

You got the RequiredTargetFramework to specify the versions of the references. Clever.

No comments: