Converting multiple SharePoint 2010 projects to SharePoint 2013
Convertir los proyectos de SharePoint 2010 en proyectos de SharePoint 2013 (con el framework 4.5 y Visual Studio 2012)
Lanzar este script desde powershell, introduciendo la url del fichero de solución:
# 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)
}
}
Después de esto ya podemos observar que todos los proyectos están configurados con el Framework 4.5.
OJO: Falta realizar las siguientes modificaciones:
- Open your csproj in notepad.
- Change the Target Framework Version from v3.5 to v4.5 <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
- Set the Office Target Version to 15 by entering the following tag to the file below TargetFrameworkVersion tag. <TargetOfficeVersion>15.0</TargetOfficeVersion>
- Update all referenced assemblies;
- SharePoint assemblies from version 14.0.0.0 to 15.0.0.0
- .NET assemblies from 2.0 and 3.5 to 4.0 and 4.5
- Go to each file (eyeball and replace them one at a time):
- Replace all 14.0.0.0 in user controls and web parts to 15.0.0.0
- Replace all version 12.0.0.0 in Pagelayouts to 15.0.0.0. Look specifically at:
<%@Register TagPrefix=”SharePoint” Assembly=”Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” namespace=”Microsoft.SharePoint.WebControls”%> - Build the project to check for any compilation errors and re-adjust.
- Update list definitions to take advantage of the new view styles.
- For all user control and delegate references:Change from: ~/_controltemplates/..To: ~/_controltemplates/15/
- Change all reference of /_layouts/ to /_layouts/15/
- Go to the Package.Template.xml and add SharePointProductVersion=”15.0″
<?xml version=”1.0″ encoding=”utf-8″?>
<Solution xmlns=”http://schemas.microsoft.com/sharepoint/” SharePointProductVersion=”15.0″>
</Solution> - Make sure that the elements in package.package SharePoint Product Version is set to 15.0
A partir de ahora ya disponemos de los proyectos que teníamos en Visual Studio 2010 listos para Implementar (deployar) en Visual Studio 2012 y nuentro flamante SharePoint 2013.
Comments
Post a Comment