How to detect old versions when deploying the .NET Framework 3.0 (formerly WinFX)

I received an interesting question from a customer this weekend. They are working on a setup package that will include the .NET Framework 3.0 (formerly the WinFX runtime components) as a prerequisite, and they wanted to automatically run the vs_uninst_winfx.exe cleanup tool to make sure that there were not any previous beta versions on the system that would cause setup to fail. This cleanup tool does not have any silent switches, and it is only designed as an end user tool and not a redistributable setup component, so I advised the customer against including this.

However, it is possible to implement logic in a setup wrapper to accomplish the underlying goal of ensuring that no previous beta versions are present on the system. I previously outlined an algorithm to accomplish this for the .NET Framework 2.0, and a similar algorithm will also work for the .NET Framework 3.0.

Here is an overview of the algorithm that .NET Framework 2.0 and 3.0 setup use to determine whether any previous beta products are on the system:

For each (beta product code)
{

Call MsiQueryProductState to check if the install state for the product code equals INSTALLSTATE_DEFAULT

if (install state == INSTALLSTATE_DEFAULT)
{

Call MsiGetProductInfo to retrieve the INSTALLPROPERTY_INSTALLEDPRODUCTNAME property for the product code
Add the value of the INSTALLPROPERTY_INSTALLEDPRODUCTNAME property to the list of beta products that need to be uninstalled

}

}

If (list of beta products is not empty)
{

If (setup is running in full UI mode)
{

Display UI with a list of product names that need to be uninstalled via Add/Remove Programs

}

Exit setup with return code 4113

}

The difference between the .NET Framework 2.0 and 3.0 is the location of the list of beta product codes. You can find the beta product codes for the .NET Framework 3.0 by using these steps:

  1. Download the .NET Framework 3.0 web download bootstrapper and save it to your hard drive
  2. Extract the contents by running dotnetfx3setup.exe /x:c:\dotnetfx3
  3. Open the file c:\dotnetfx3\setup.sdb in a text editor such as notepad
  4. Look for the list of product codes in the [PrevProductIds] section of setup.sdb