Upgrading a SharePoint solution written for 2010 to SharePoint 2013 can be a tedious process even for an experienced SharePoint Consultant. When first opening a Visual Studio 2010 project in Visual Studio 2012 there are a number of updates performed and a number of references fixed. However there are many SharePoint-specific references that need to be changed throughout a Visual Studio project or solution and many of these are not apparent.
Note: Visual Studio 2012 or later is required as Visual Studio 2010 cannot target the .Net 4.5 framework. Though Visual Studio is backwards compatible, older versions cannot target newer frameworks.
Project File (.csproj)
The project file (extension .csproj) is an XML type file that contains a lot of the Visual Studio project’s properties. There are two key updates that need to be made to this file: the TargetFrameworkVersion attribute needs to be changed from “v3.5” to “v4.5 and the TargetOfficeVersion attribute needs to be added if it does not already exist and set to 15.0. If this attribute needs to be added it can be placed below the TargetFrameworkVersion or anywhere within the same PropertyGroup element.
References to the SharePoint object model, even ones that were automatically added by Visual Studio when creating the project, may need to be re-added to the solution. Some references don’t automatically update to their version 15.0 counterparts, removing and re-adding these references fixes this problem.
Any packages included in your solution or product may not automatically update their targeted version. If not fixed this could cause resources to be deployed to the wrong location. Updating this version is simple: open your package(s)’ properties and set the SharePoint Product Version attribute to 15.0
Update 184.108.40.206 and Layouts Folder Location
Throughout your solution there may be references to 220.127.116.11, typically in application pages. These can be changed to 18.104.22.168 using Visual Studio’s ‘find and replace all’ feature which you can open with the keyboard shortcut ctrl+F.
Likewise throughout your solution you’ll want to append “/15/” to any references to the “/_Layouts” folder and the “/_ControlTemplates” folder, this includes any references to sub-folders.. This is because Microsoft moved the hive, a change which allows SharePoint 2013 to run legacy 2010 solutions but since we’re upgrading our solution to be SharePoint 2013 compatible we need to target the new hive location.
Once these changes have been made, simply save and rebuild your solution! Let us know if this tip was helpful in the comments section below.