Miscellaneous Debris

Avner Kashtan's Frustrations and Exultations

Upgrading all projects to .NET 3.5

A simple macro to change the Target Framework for a project from .NET 2.0 to .NET 3.5, hacked together in a few minutes. This will fail for C++/CLI projects, and possibly VB.NET projects (haven't checked). Works fine for regular C# projects, as well as web projects:

 

For Each proj As Project In DTE.Solution.Projects
   Try
       proj.Properties.Item("TargetFramework").Value = 196613
       Debug.Print("Upgraded {0} to 3.5", proj.Name)
   Catch ex As Exception
       Debug.Print("Failed to upgrade {0} to 3.5", proj.Name)
   End Try

Next proj

Why 196613, you ask? Well, when I see such a number my first instinct is to feed it into calc.exe and switch it to hexadecimal. And I was right: 196613 in decimal converts to 0x00030005 - You can see the framework version hiding in there. Major version in the high word, minor in the low word. The previous TargetFramework number was 131072 - 0x00020000, or 2.0.

 

(Nitpickers might point out that I could simply set it to &30005 rather than messing with the obscure decimal number. They would be correct - but I got to this number through the debugger, so that's how it will stay)

Comments

anas said:

where i can write that ? in the .net 2. project ?

can i write a another one that reverse the operation ?

# May 25, 2008 1:31 PM

Avner Kashtan said:

Write it as a macro in Visual Studio 2008 (Tools -> Macro). Then simply run it with F5 from the Macro editing environment, while your solution is open.

To reverse the operation, just replace the number with the one for .NET 2.0 (&20000).

# May 25, 2008 5:58 PM

cool music blog said:

Great blog article.Thanks Again. Want more.

# September 5, 2012 10:18 AM

study English said:

Thanks-a-mundo for the post.Really looking forward to read more. Cool.

# September 5, 2012 12:30 PM

The Remote Work is Possible due to Virtual Private Networks. said:

Looking forward to reading more. Great blog.Much thanks again. Really Cool.

# September 10, 2012 7:04 AM

crork said:

2B3zs9 I appreciate you sharing this blog.Much thanks again. Fantastic.

# October 19, 2012 5:39 AM

Broadway said:

Greetings from Florida! I'm bored to death at work so I decided to browse your site on my iphone during lunch break. I really like the info you provide here and can't wait to take a look when I get home.

I'm surprised at how fast your blog loaded on my cell phone .. I'm not even using WIFI,

just 3G .. Anyhow, amazing blog!

# April 15, 2013 7:15 PM

Social bookmarks said:

5TzyRJ Muchos Gracias for your article. Awesome.

# April 19, 2013 11:55 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)