Sunday, February 17, 2013

Convert Visual Studio Sharepoint 2010 project to Sharepoint 2013 project

Recently we performed migration of the several sites from Sharepoint 2010 to Sharepoint 2013. We have several standard Sharepoint 2010 Visual Studio projects (wsps) in solution which contain our customizations. As we didn’t find standard way of changing target platform in Visual Studio from Sharepoint 2010 to 2013, we created 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 described way worked, but it took some time to move all files from old project and verify that we didn’t miss anything.

Rainer Dümmler showed me the easier way to do that and with his approval I post it in my blog. 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.

Thanks for Rainer Dümmler who shared this trick with me. All credits go to him. Unfortunately he doesn’t have a blog yet, but I hope that it will be fixed in future :).

No comments:

Post a Comment