Possible issue where machine.config can be overwritten by .NET Framework 2.0 SP2 setup

Description of the issue

I heard from someone recently who noticed that some information was removed from the file machine.config after installing the .NET Framework 2.0 SP2.  Their scenario looked like the following:

  1. Install Windows XP or Windows Server 2003
  2. Install the .NET Framework 3.5 (which installs 2.0 SP1 and 3.0 SP1 behind the scenes, and which adds some information about 3.5 assemblies to the 2.0 machine.config)
  3. Install the .NET Framework 2.0 SP2
  4. Look at the contents of machine.config (located at C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config on an x86 OS or C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\CONFIG\machine.config on an x64 OS)

In the above scenario, the entries added to machine.config during .NET Framework 3.5 installation in step 2 were removed from machine.config during .NET Framework 2.0 SP2 installation in step 3.

How to work around this issue

If you run into a scenario where machine.config is incorrectly overwritten when installing the .NET Framework 2.0 SP2, you can work around it in one of the following ways:

  1. If you have not yet installed the .NET Framework 2.0 SP2, you can manually back up your copy of machine.config, then copy it back after installing the .NET Framework 2.0 SP2.
  2. If you have already installed the .NET Framework 2.0 SP2, you can repair/re-install other products that updated machine.config (such as the .NET Framework 3.5), or you can manually re-add the information to machine.config that was removed by the .NET Framework 2.0 SP2 installation process.
  3. Instead of installing the standalone .NET Framework 2.0 SP2 package, you could instead install the .NET Framework 3.5 SP1 package (which will also install the .NET Framework 2.0 SP2 and 3.0 SP2 for you behind the scenes).  The .NET Framework 3.5 SP1 installation process will add the necessary information to machine.config that may otherwise be missing in this scenario.

What can cause this issue

.NET Framework 2.0 SP2 setup follows the standard Windows Installer file replacement logic for unversioned files, which causes it to not replace machine.config if that file was updated by some other program after it was originally installed.  However, we have seen some cases where the last modified time stamp does not get updated during .NET Framework 3.5 setup.  If this happens, then the installation of the .NET Framework 2.0 SP2 does not correctly recognize that some other program has updated machine.config, and as a result, the .NET Framework 2.0 SP2 installation process overwrites machine.config with a default copy that is included with the .NET Framework 2.0 SP2 installer.

One note – so far, we have only seen this issue affect computers that have an MSI-based version of the .NET Framework 2.0 installed (Windows XP, Windows Server 2003).  The issue does not appear to affect versions of Windows that include the .NET Framework 2.0 as an OS component (Windows Vista, Windows Server 2008, Windows 7).

<update date="12/29/2009"> Added another possible workaround for this issue - install the .NET Framework 3.5 SP1 package instead of just installing the .NET Framework 2.0 SP2 package. </update>