views:

127

answers:

2

I have a just converted a Visual Studio project from 2005 to 2008 to take advantage of the .NET 3.5 Framework features. My solution contains approximately 80 projects and I want to set the Target Framework to .NET Framework 3.5 for all of them. Is there a way I can do this without manually going in and changing them one-by-one in Properties -> Application -> Target Framework?

+2  A: 

You would need to edit all the .csproj files and change the line:

<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>

You could write a program that would scan your projects folders for all .csproj files, read them as text (or perhaps xml), update that line and then write them out again.

You might have an issue though if they're not already VS 2008 projects. So convert them first. And as you're doing that it'll probably be just as quick (if not quicker) to update the target framework version by hand.

Having said that, why not leave it alone until you make code changes the project anyway. As your code works now, and the only reason you want to update is to make use of the new features you're going to have to edit the project anyway.

ChrisF
Yeah. I have already found all the references to the previous framework in the .csproj files and changes them. I just wondering if I was missing some functionality in Studio. It seems not. Thanks though.
Spear
+1  A: 

In theory you could do a diff between the .csproj files before and after changing the framework version. .csproj is an XML file, so it's something you could write a program to parse and change.

In practice, I'd not do this, as there may be subtleties that this may miss. For instance: do installation projects work the same way? Web deployment projects?

Also, suppose it takes you a couple of seconds to do each one by hand. This will take about two or three minutes to do the whole solution. That may actually be faster than writing the code ... !

Jeremy McGee