VB.Net: Targeting .Net 2.0 using VS2008

I’ve switched to Visual Studio 2008 a while back; it seems more stable than 2005 and I just seem to get projects done faster in the newer version.

However, 2008 by default uses .Net 3.5 and most of my computers are still at 2.0 version. I’ve been very careful to target new projects at 2.0 but when I go to install them, it still requires the installation of 3.5 — that was quite annoying. However, I’ve found the fix.

When you create new projects in 2008, be sure to target them to 2.0 in the Create Project dialog. When you add the Setup project, also be sure to set it to 2.0. Now you’d think that’s all you have to do create a 2.0 project in VS2008, but you’d be wrong! 🙂

To check your project, double-click “My Project” in Solution Explorer, select the Compile tab and click the Advanced Compile Options…” button at the bottom. Now, you’ll see the Target framework at the bottom of the next dialog; make sure it is set to .NET Framework 2.0.

Now, to check your setup project, double-click the Microsoft .NET Framework entry under the Detected Dependencies in Solution Explorer. That will open up the Launch Conditions tab. You should see the .Net Framework under the Launch Conditions folder; click on it and then look at your Properties window. Under the Version property, you’d expect to see 2.0 but it is set to 3.5 — that’s why the Setup msi requires .Net 3.5 instead of using the existing 2.0 framework. Simply change the Version to 2.0, recompile the project and setup project, and you are good to go at 2.0!

You’d think that targeting the setup project should update the Launch Conditions; maybe it’s just a bug. 🙂

UPDATE: The above fixes the MSI installer, but if you try to use the setup program, it will try to install .Net 3.5! There is yet one more place to change: right-click on your setup project is Solution Explorer and select properties. Press the Prerequisites and unselect .Net 3.5 and select .Net 2.0.

Leave a Reply

Your email address will not be published. Required fields are marked *