Nov25

Updating a SharePoint 2010 Solution to SharePoint 2013 in Visual Studio

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.

Before:

<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>

 After:

<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>

<TargetOfficeVersion>15.0</TargetOfficeVersion>

Assembly References

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.

Package Version

Open the properties and set the SharePoint Product Version attribute to 15.0

Open the properties and set the SharePoint Product Version attribute to 15.0

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 14.0.0.0 and Layouts Folder Location

Throughout your solution there may be references to 14.0.0.0, typically in application pages. These can be changed to 15.0.0.0 using Visual Studio’s ‘find and replace all’ feature which you can open with the keyboard shortcut ctrl+F.

Update 14.0.0.0 and Layouts Folder Location

Update 14.0.0.0 to 15.0.0.0 using “find and replace all”

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.

Before After

/_Layouts/

/_Layouts/images/

/_Layouts/scripts/

/_ControlTemplates/

/_Layouts/15/

/_Layouts/15/images/

/_Layouts/15/scripts/

/_ControlTemplates/15

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.

Leave a Comment

Your email address will not be published. Required fields are marked *