How to fix .NET Framework install errors that ask for tmpXXXX.tmp

I have heard from several customers who have had problems trying to repair the .NET Framework or install a .NET Framework service pack and saw an error dialog asking for the source location for tmpXXXX.tmp. I wanted to try to explain why this can happen and also describe a way that I normally recommend to fix this issue.

Why does this happen?

The .NET Framework hotfix setup wrapper creates patch files on the fly in the %temp% directory that are named tmpXXXX.tmp (where XXXX is a randomly generated ending), and then deletes the file after applying the patch. When attempting to install any .NET Framework hotfix or repair the .NET Framework, Windows Installer will perform a component health check. If any of the components installed as part of the patch have been damaged/deleted, Windows Installer will trigger a repair and search for the files in the original install location. In this case, the original install location does not exist because it was deleted from %temp%.

How can I workaround this?

I posted a complete set of steps that you can use to clean up your system and reinstall the .NET Framework at http://blogs.msdn.com/b/astebner/archive/2008/03/07/8108332.aspx

<update date="5/6/2011"> Removing the old instructions in this post and pointing to updated steps. </update>