Created
May 6, 2010 07:11
-
-
Save kevinmcmahon/391885 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Reflection.Assembly]::LoadWithPartialName("System.Xml.Linq") | Out-Null | |
#specify the root of your source tree below | |
$path = "C:\Code\chatsworth" | |
$ns = "http://schemas.microsoft.com/developer/msbuild/2003" | |
$xname = [System.Xml.Linq.XName]::Get("PropertyGroup",$ns) | |
$tfname = [System.Xml.Linq.XName]::Get("TargetFrameworkVersion",$ns) | |
$xws = New-Object System.Xml.XmlWriterSettings | |
$xws.OmitXmlDeclaration = $true | |
$xws.Indent = $true | |
function updatefx($filename) | |
{ | |
#Write-Host $filename | |
$xml = [System.Xml.Linq.XDocument]::Load($filename) | |
$result = $xml.Descendants($xname) | |
foreach ($i in $result) | |
{ | |
$fxelem = $i.Element($tfname) | |
if($fxelem) | |
{ | |
$i.SetElementValue($tfname,"v4.0") | |
} | |
} | |
$xw = [System.Xml.XmlWriter]::Create($filename, $xws) | |
$xml.Save($xw) | |
$xw.Close() | |
} | |
$csprojs = Get-ChildItem $path *.csproj -Recurse | |
foreach ($file in $csprojs) | |
{ | |
updatefx $file.FullName | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment