After consulting with my brains trust (thanks Damo), I tried one last thing. I manually copied the folders IISExpress had created in the c:\temp\IISExpress folder back into my MyDocuments\IISExpress folder, and VS seems happy. I’m calling this one closed for now.
This is only half solved. It looks like VS still insists on launching IISExpress with a specific command line switch pointing at the old config location.
I installed a new machine the other day and on loading a VS project that uses IISExpress, I got the following error:
Filename: \\?\UNC\[our My Docs Server]\MyDocs1\acoat\My Documents\IISExpress\config\applicationHost.config
Line number: 1
Error: Configuration file is not well-formed XML
Turns out that IISExpress is writing config information to my My Documents folder, but because I’ve got folder redirection turned on, this is a UNC path, not a local path. It looks like an applicationHost.config file is created, but it’s 0 bytes and the IISExpress process doesn’t have permission to write to it.
Fortunately, from IISExpress 8 onwards, there’s a registry key you can setr to point IISExpress at another home folder.
Changing the User Home Directory
IIS 8.0 Express supports changing the user's home directory, which is mapped to the %IIS_USER_HOME% variable in configuration. By default this path is located at %UserProfile%\Documents\IISExpress, but users can change this by setting a CustomUserHome registry property in HKCU\Software\Microsoft\IISExpress, or by specifying the "/userhome" parameter when launching iisexpress.exe.
So, I fired up RegEdit, added a new IISExpress key under HKCU\Software\Microsoft and then added a string key CustomUserHome set to "c:\Temp\IISExpress" (a folder I’d created manually) and IISExpress starts in the expected manner and creates all of its config, logs and tracelogfiles folders (and their accompanying files) there and starts successfully.