Error: Installation failed for component Microsoft .NET Framework 3.5 (x64) 'package'. MSI returned error code 1603

The Microsoft .Net Framework 3.5 SP1 Setup may fail without any error message or the setup may crash almost at the end. You can find the below error messages in the log file:

[01/20/13,05:32:37] Microsoft .NET Framework 3.5 (x64) 'package': [2] Error: Installation failed for component Microsoft .NET Framework 3.5 (x64) 'package'. MSI returned error code 1603
[01/20/13,05:32:49] WapUI: [2] DepCheck indicates Microsoft .NET Framework 3.5 (x64) 'package' is not installed.

In the detail log file (dd_NET_Framework35_x64_MSI****.txt) at %temp% location, it had more information on the failure as mentioned below:

DDSet_Status: CExtensionElement::SetData szName=webHttp szType=System.ServiceModel.Configuration.WebHttpElement, System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 szXPath=system.serviceModel/extensions/behaviorExtensions/add
DDSet_Status: CFxInstaller::SetupExtensions Adding System.ServiceModel.Configuration.WebHttpElement, System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
DDSet_Status: CExtensionElement::AddToConfigFile _xPath=system.serviceModel/extensions/behaviorExtensions/add
DDSet_Status: CConfigEntry::IsPresent szPath=system.serviceModel/extensions/behaviorExtensions/add
DDSet_Status: CFxInstaller::SetupExtensions extensionElement.AddToConfigFile failed. value=System.ServiceModel.Configuration.WebHttpElement, System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Error code: 0x80004005.
DDSet_Status: CExtensionElement::SetData szName=webMessageEncoding szType=System.ServiceModel.Configuration.WebMessageEncodingElement, System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 szXPath=system.serviceModel/extensions/bindingElementExtensions/add
DDSet_Status: CFxInstaller::SetupExtensions Adding System.ServiceModel.Configuration.WebMessageEncodingElement, System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
DDSet_Status: CExtensionElement::AddToConfigFile _xPath=system.serviceModel/extensions/bindingElementExtensions/add
DDSet_Status: CConfigEntry::IsPresent szPath=system.serviceModel/extensions/bindingElementExtensions/add
DDSet_Status: CFxInstaller::SetupExtensions extensionElement.AddToConfigFile() failed. Value=System.ServiceModel.Configuration.WebMessageEncodingElement, System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Error code: 0x80004005

After my initial review, I found that that the issue occurred due to the below lines being added in the 32-bit web.config file located at C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG

<compilation tempDirectory="C:\Asp.net Temp Files\2.0.50727\x86">
<compilation tempDirectory="C:\Asp.net Temp Files\2.0.50727\x64">

In general the <compilation tempDirectory…> is never set to a value like this. It used to be always under C:\Windows\Microsoft.NET\v2.0.50727\Temporary ASP.NET files.  Later, I found WFServicesReg was barfing because the config file already contained the elements needed in the file so it was not able to re-add them, hence the failure code. Finally, I was able to resolve the issue after replacing the web.config files by web.config.default in both the locations (x86/x64 <C:\Windows\Microsoft.NET\Framework64\v2.0.50727\CONFIG  and C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG>. When I replaced the web.config with the default one, this allowed WFServicesReg to proceed as the elements weren’t there to begin with. The Microsoft .Net Framework 3.5 SP1 was installed successfully.

N.B.: Please take a back up of web.config files before replacing them. You may also have to repair applications which add custom entries in web.config files.