views:

48

answers:

1

Hi,

I have a solution with many, many projects. How do I change the target framework to .NET 4.0 without going to each one individually and manually changing the dropdown?

+1  A: 

Try comparing a 3.5 project file and a 4.0 project file and use a file based search/replace operation.

I think only these two version numbers differ:

<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;

<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
Sandor Drieënhuizen
I've searched the whole solution and not found the strings "TargetFrameworkVersion" or "ToolsVersion" ??
Carlos
Did you open a .csproj file in Notepad using Windows Explorer?
Sandor Drieënhuizen
No, I used the find/replace in VS2010.
Carlos
I see. I think the easiest way to go about is closing you solution (but not Visual Studio) and press Control+Shift+H to open the Find and Replace box. Look in the solution directory and all file types.
Sandor Drieënhuizen
But then how do I edit all the files?I fond this:http://www.codeproject.com/Articles/74805/Visual-Studio-2010-and-Target-Framework-Version.aspx
Carlos
The Find and Replace box you get by pressing Control+Shift+H can do that for you. Just replace `<Project ToolsVersion="3.5"` by `<Project ToolsVersion="4.0"` (I'm guessing the 3.5 here, check for the actual value yourself) and replace `<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>` by `<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>`.
Sandor Drieënhuizen
Aha! It seems to work. The toolsversions don't need changing, because I've already opened the files in VS2010.The critical point is that the find/replace appears to work differently when you don't have a solution loaded.
Carlos