# This script recurses from the given directory to find all
# .csproj files and upgrade them to VS 2013.
$search_path = "."
$client_profile = [bool] 0
if($args.Length -ge 1)
{
if(($args[0] -eq "--help") -or
($args[0] -eq "-h") -or
($args[0] -eq "/?"))
{
echo "upgrade_dotnet"
echo "usage: upgrade_dotnet (--client) (path)"
$format = @(Expression={$_.Name}; Label="Argument"; width=10),
@(Expression={$_.Value}; Label="Description";)
$arguments = @{"path"="The start of the search path for .csproj files to convert."}
echo $arguments | Format-Table $format
}
else
{
$search_path = $args[0]
}
if($args.Length -ge 2)
{
$search_path = $args[1]
}
}
$projects = ls -recurse -Filter "*.csproj" $search_path
foreach ($p in $projects)
{
echo $p
$path = $p.FullName
$x = [XML](gc $path)
$x.Project.ToolsVersion = "12.0"
$profile = $x.Project.PropertyGroup[0].SelectSingleNode('TargetFrameworkProfile')
if(-not $profile)
{
# do nothing
}
else
{
$x.Project.PropertyGroup[0].TargetFrameworkProfile = ""
}
$x.Project.PropertyGroup[0].TargetFrameworkVersion = "v4.5.1"
$x.Save($path)
(Get-Content $path) |
Foreach-Object {$_ -replace "Client", ""} |
Set-Content $path
}