Visual Studio 2010 will allow you to move your projects from previous versions of Visual Studios to VS 2010 with ease, I will call this process as “Converting” the project from VS 200X to VS 2010…
VS 2010 will also allow you to change your project’s Target Framework Version to .NET 4.0 from .NET 2.0, 3.0 or 3.5… I will call this process as “Upgrading”…
The reason why VS allows you to deal with these two concepts separately is due to various reasons, some of which can be:
- You might be ready to use the latest and greatest tooling features of VS 2010 even if you are not yet ready to move to .NET 4.0 just yet…
- You might have a big solution with various projects and you might want to move few of the project to .NET 4.0 first and then take a staged approach to the rest of the projects… Obviously you would not want to open various projects in different versions of VS…
Project Conversion- When you are using projects with .csproj/.vbproj files (e.g. Class Library, Web Application Project etc) then these files typically contain some type of information about VS IDE version example in .csproj file you can see below:
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
In the above example you can notice that there is msbuild/2003 in the schema namespace… There is also ProductVersion 9.0 in the sample above. If you examine your project file in further depth you will also find references to the .targets files for the Web Application Projects like below:
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />
Notice that the location of the targets file is in above example is in “V9.0” directory in the above piece of xml… This all needs to be changed to Visual Studio 2010 references (i.e. “V 10.0”) to allow your pre VS 2010 project to use new features of VS 2010.
The process by which pre VS 2010 (e.g. VS 2008, VS 2005) project and solution files are modified to move to VS 2010 format is what I am referring to as Project Conversion.
VS 2010 conversion wizard is very similar to how VS 2003/VS 2005 to VS 2008 conversion Wizard use to look like… To convert pre VS 2010 project to VS 2010 you can double click the project or solution file on a box which has VS 2010 and the conversion wizard will kick off… Following will be the steps that you will see:
Step 1: UI describing that your project will be converted
Step 2: Option to back up your project (I would encourage you to create a back up of your project before converting so that you have a copy of your project in case there are any errors in conversion)
Step 3: Summary before the conversion begins
Note that so far you have not been asked about your .NET Framework Version. Do not worry about it just yet and hit the “Finish” button above… You will be allowed to make a decision on whether or not you would like to “Upgrade” your project to .NET 4.0 in the next step.
As soon as you click Finish, the project conversion will kick in the Project Upgrade dialog.
Project Upgrade- Step 3 of project conversion step is pretty much common to any VS project or solution file, by this what I mean is that some of the things like Product Version, Target File Paths etc are typically required to be changed for most projects including Web Projects… Apart from this step there are certain .NET Framework specific steps required to be done e.g. changes to the project file to indicate which .NET Framework version should be used for the project, similar type of changes in the solution file if need be and additionally for web projects changing the web.config file correctly based on the the framework version you are targeting… These changes are what I am referring to as “Project Upgrade”…
Once you click “Finish” button in Step 3 above you should see the below Framework Version dialog
Step 4: Choose whether or not to upgrade to .NET 4.0
I will click “Yes” on the button above but you can choose to click “No” if you are not yet ready to move to ASP.NET 4.0 on the server. As the dialog specifies you can change the target framework of your project eventually when you are ready by going to the project properties…
If I click “Yes” my web.config file will be modified to conform to ASP.NET 4.0 format... None of the additional items that you have added to your web.config file (e.g. appSettings, connectionStrings etc) will be altered but rather most of the assembly references in the web.config file will be modified to 4.0…
In addition with ASP.NET 4.0 there is a need for a new attribute on the compilation tag as shown below:
<compilation debug="true" targetFrameworkMoniker=".NETFramework,Version=v4.0">
<add assembly="System.Core, Version=22.214.171.124, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.DataSetExtensions, Version=126.96.36.199, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=188.8.131.52, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Xml.Linq, Version=184.108.40.206, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies>
The targetFrameworkMoniker attribute allows VS 2010 to identify that the web is a 4.0 web. This allows VS 2010 to customize the intellisense, toolbox, references etc to 4.0 for your project.
As part of this project upgrade VS will automatically inject targetFrameworkMoniker attribute into your web.config file. For a 4.0 web in VS 2010 and ASP.NET 4.0 this attribute is required, if you try to run a 4.0 web without this attribute in the web.config file then you will get an error At this point you should get below screen after the conversion is successful.
Step 5: Conversion Complete + Logs Screen
You can choose to open the conversion logs at this time or hit Close… At this point your project should be ready to be used…
Eventually I will write more about Conversion, Upgrade and details about it but in the meantime I hope this will help…