First time you create a new project in Visual Studio 2012 the target framework is set us .NET 4.5. A lot of the fellow developers end up creating the project in .NET4.5 in accident.
Figure 1 – Default target framework in the new project window is .NET Framework 4.5
In this blog post, I’ll show you how to tweak the registry to default the target framework to .NET 4 just to avoid accidently creating projects in .NET 4.5.
WARNING: This solution is neither recommended nor supported by Microsoft. Editing the registry can lead to serious problems if not done correctly. Always backup your registry before editing.
Figure 2 – Path to the registry key ‘FxVersion’ to change the default framework to 4.0
Steps to change the default Target Framework to DotNet 4.0 in Visual Studio
- Open registry by typing Regedit in the command or run prompt
- Navigate to the path HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\NewProjectDialog and look for the key ‘FxVersion’.
- You’ll notice ‘FxVersion’ is currently set to 4.5
- Double click FxVersion and change the value to 4.0
- Close the Registry and try to create a new project in Visual Studio 2012
- Voila! The default target version should now be .NET Framework 4
Figure 3 – Default target framework set to .NET 4.0 after setting FxVersion to 4.0
Note – If you changed the value of the framework in the new window to let’s say .NET 3.5 then the value of the FxVersion key will change to 3.5 as well. So, I have created a .bat file that gets called when Visual Studio is loaded which basically resets the value of the key FxVersion to 4.0 to ensure that it remains as the default target framework for all new project.