title: Automatically correct .vs/config/applicationhost.config
body: <p>Visual Studio 2015 has moved the IIS Express configuration file from My Documents into its own hidden .vs directory and tells IISExpress.exe to use that configuration file.</p>
  
  <p>While this may sound like a good idea when you have multiple web applications with conflicting configurations, in fact it's not when you have web applications with custom configurations at all. Because this config file is in a temporary directory which can be deleted when checking out code into a new location from source control, or when cleaning up things in general.</p>
  
  <p>The old location in the Documents folder is a central location and files there usually won't be deleted. If I need to make some changes to this file, like allowing the application to use Windows authentication, I edit this file once and I'm done. Now with the new location, I may need to make these changes multiple times. And since there's two config files (the old location still exists for me), it's even more confusing.</p>
  
  <p>Then you shouldn't commit anything from .vs into version control, so it's not even possible to share these customisations with other team members.</p>
  
  <p>What is the recommended way to update the applicationhost.config file so that it provides the environment required by the web application? Is there a tool that can run in a pre/post build step? Is there a customisation XML file that can be merged into the default file from .vs?</p>
  
  <p>Is it possible at all to just check out a web application from source control and let it work in a local IIS Express? Or will it always require manual corrections after getting the code and web.config?</p>
  
  <p>PS: I've forgotten one thing: There's the <code>&lt;UseGlobalApplicationHostFile&gt;</code> element in the project file which can be set to <code>true</code>, but as soon as I do that, I get an access denied error message every time I want to start the web application. So that doesn't seem to work well.</p>