Skip to content

Instantly share code, notes, and snippets.

@thoemmi
Last active August 29, 2015 14:15
Show Gist options
  • Save thoemmi/3151cc7664a28e1cd86d to your computer and use it in GitHub Desktop.
Save thoemmi/3151cc7664a28e1cd86d to your computer and use it in GitHub Desktop.
Updates .vcxproj files to Visual Studio 2013 while still building against VS2012 platform
function UpdateVcxprojFile($filename) {
$content = [xml](Get-Content -Path $filename)
$changed = $false
$toolsVersion = $content.Project.ToolsVersion
if ($toolsVersion -ne "12.0") {
$content.Project.ToolsVersion = "12.0"
$changed = $true
}
foreach ($propGroup in $content.Project.PropertyGroup) {
if ($propGroup.Label -ne "Configuration") {
# Only PropertyGroups with Label "Configuration" specify a build configuration
continue
}
# set PlatformToolset; "v110" means Visual Studio 2012
if ($propGroup.PlatformToolset -eq $null) {
# no PlatformToolset specified yet
$elem = $content.CreateElement('PlatformToolset', $content.DocumentElement.NamespaceURI)
$elem.InnerText = "v110"
$propGroup.AppendChild($elem) | out-null
$changed = $true
} elseif ($propGroup.PlatformToolset -ne "v110") {
# change PlatformToolset
$propGroup.PlatformToolset = "v110"
$changed = $true
}
}
if ($changed) {
Write-Output "Updating $filename"
&"tf" checkout /lock:none "$filename" /noprompt 2>&1 | Out-Null
$content.Save($filename)
}
}
gci *.vcxproj -Recurse | foreach {
UpdateVcxprojFile($_.Fullname)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment