Click here to Skip to main content
Click here to Skip to main content

Converting Multiple SharePoint 2010 Projects to SharePoint 2013

, 6 Jan 2013
Rate this:
Please Sign up or sign in to vote.
How to convert multiple SharePoint 2010 projects to SharePoint 2013
Converting/migrating SharePoint 2010 projects to SharePoint 2013 involves changing TargetOfficeVersion to be 15.0, and changing TargetFrameworkVersion to be v4.0 or v4.5 in the Visual Studio csproj file.

When you have multiple SharePoint 2010 projects in your solution, it will not be an easy task!

The following PowerShell script is my trial to simplify converting multiple projects, hope it will help.
Just change the value of the $path variable to be your solution path (the folder containing your SharePoint projects).

# Path containing SharePoint 2010 projects 
$path = "<Your Solution Folder Path>"

cd $path
$files = get-childitem -recurse -filter *.csproj

foreach ($file in $files)
{
    "Filename: {0}" -f $($file.Name)
    $proj = [xml](Get-Content $file.FullName)

    $ns = new-object Xml.XmlNamespaceManager $proj.NameTable
    $ns.AddNamespace("dns", 
    "http://schemas.microsoft.com/developer/msbuild/2003")
    $projectTypeGuids = $proj.SelectSingleNode
    ("//dns:Project/dns:PropertyGroup/dns:ProjectTypeGuids", $ns)
 
 # Check to see if the project type is SharePoint 
 if ($projectTypeGuids."#text" 
 -like "*BB1F664B-9266-4fd6-B973-E1E44974B511*")
 {
  $targetOfficeVersion = $proj.SelectSingleNode
  ("//dns:Project/dns:PropertyGroup/dns:TargetOfficeVersion", $ns)
  if($targetOfficeVersion -eq $null)
  {
   # Create TargetOfficeVersion element if not exist
   $targetOfficeVersion = $proj.CreateElement("TargetOfficeVersion")
   $targetOfficeVersion = $proj.SelectSingleNode
   ("//dns:Project/dns:PropertyGroup", $ns).AppendChild($targetOfficeVersion)
  }

  # Change target office version
  $targetOfficeVersion.InnerText = "15.0"

  # Change target framework version
  $targetFrameworkVersion = $proj.SelectSingleNode
  ("//dns:Project/dns:PropertyGroup/dns:TargetFrameworkVersion", $ns)
  $targetFrameworkVersion.InnerText = "v4.5"

      # Remove empty namespaces
  $proj = [xml] $proj.OuterXml.Replace(" xmlns=`"`"", "")
  $proj.Save($file.FullName)
 }
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Adel Refaat
LINK Development
Egypt Egypt
No Biography provided
Follow on   Twitter   Google+

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 6 Jan 2013
Article Copyright 2013 by Adel Refaat
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid