I need to change the target framework for all projects. I have many solutions with hundreds of projects.
Anything new here or do I have to change every single proje
A PowerShell script that I used to do mine. Admittedly bruce force-ish.
Get-ChildItem . -Recurse -Filter *.*proj |ForEach {
$content = Get-Content $_.FullName
$content |ForEach {
$_.Replace("<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>", "<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>")
} |Set-Content $_.FullName
}
From bash:
$find . -name "*.csproj" -exec sed -b -i "s,<TargetFrameworkVersion>[^<]*</TargetFrameworkVersion>,<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>," {} \;
You can use a macro to do this, or remember that the VS project files are text files, which means a simple global search and replace can achieve the same, and is a more general technique for making the same change to lots of project files.
First back up an existing project file, then make the change you want (e.g., change the target framework). Use WinDiff or WinMerge to compare the new project file with the back up. This will tell you the change you need to make. Then use the Visual Studio IDE's Find and Replace in Files function to make the change to all your project files.
Target Framework Migrator by Pavel Samokha (VHQLabs)
http://visualstudiogallery.msdn.microsoft.com/47bded90-80d8-42af-bc35-4736fdd8cd13