Tuesday, December 6, 2016

Convert Visual Studio Sharepoint 2010 project to Sharepoint 2013 project

Are you working on migration of the several sites from Sharepoint 2010 to Sharepoint 2013, having several standard Sharepoint 2010 Visual Studio projects (wsps) in solution which contain customizations. As we didn't find standard way of changing target platform in Visual Studio from Sharepoint 2010 to 2013,normally developers create new empty Sharepoint 2013 project in Visual Studio 2012 and manually copied all files there. Also we changed references to Microsoft.SharePoint.dll and all other Sharepoint assemblies from 14 to 15 (Sharepoint 2013 is built on top of .Net 4.5, so its assemblies are located in different GAC: C:\Windows\Microsoft.NET\assembly\, not in C:\Windows\assembly\ as it was before. Here is the good forum thread about why MS put .Net 4 to the new GAC: .NET 4.0 has a new GAC, why?). After that we packaged wsp and compare content with comparison tool.

The above described way worked, but it took some time to move all files from old project and verify that we didn't miss anything.

There are a better way to do it quickly and to ensure nothing left behind.

In order to change target platform to Sharepoint 2013 you need to do the following. Edit your .csproj file in the notepad and replace value for TargetFrameworkVersion tag from v3.5 to v4.5. Then add TargetOfficeVersion tag right after it:

<TargetOfficeVersion>15.0</TargetOfficeVersion>

So it should look like this after the changes:

image
Then go to Package subfolder in your project folder and edit Package.package file: add attribute sharePointProductVersion="15.0" after existing resetWebServer attribute.
After that just reload your .csproj in Visual Studio 2012 (it will automatic upgrade of .csproj), change references to the 15 API, recompile it and package wsp.





No comments:

Post a Comment