title: Prevent Visual Studio from automagically changing the physical path of IIS virtual directory?
body: <p>I have a Visual Studio "solution" which contains a Web application project (among a few other projects).  Visual studio "typical" setup seems to be to insist that the output directory for binaries is smack in the root of the project source directory. In particular, each time the web application project is opened, Visual Studio will reset the physical path of the IIS virtual directory to point to the project directory.</p>
  
  <p>This is problematic on many levels:</p>
  
  <ol>
  <li>It's never wise to mix binary output directories and source trees</li>
  <li>If the web application is buried deep within a directory hierarchy of other source, wherein many projects produce libraries which may be used as support libraries in the web application, then all the other supporting projects must have their binary output directories set to a bin directory a some non-obvious, nonsensical location somewhere in the source tree.</li>
  <li>This "typical" VS setup does not have your web app setup duplicate the "production" setup you would get from a publish: there may be files in your source tree (an old .js file there there from a repository extraction, for example) that are not referenced in your projects, and so would not be in the production published package, but are there in your debugging setup.</li>
  </ol>
  
  <p>It is very possible and very easy to configure all the projects in a Visual Studio solution to build to a bin directory in some subdirectory cleanly placed outside the source tree.  It is also easy to ensure that the web app build places all content cleanly in this directory.  It is also easy to configure an IIS virtual directory to point to this build output directory.  And then Visual Studio, unannounced and unbidden, screws this up by arbitrarily changing the physical directory of the carefully configured virtual IIS app, to point to the middle of one's source tree.</p>
  
  <p>How can this crazy-making behaviour be stopped?  I.e. <strong>how do I prevent Visual Studio from automagically re-setting the physical path of the virtual web directory each time the web app project is opened?</strong></p>
  
  <p>This question has been asked many times here on Stack Overflow, but I have seen no real answers:</p>
  
  <p>The response to this question (<a href="https://stackoverflow.com/questions/27544123/iis8-5-is-automatically-changing-physical-path-property">IIS8.5 is automatically changing Physical Path property</a>) simply indicates how to control the order in which Visual Studio does its repointing.</p>
  
  <p>This question and response (<a href="https://stackoverflow.com/questions/3093433/visual-studio-creating-iis-virtual-directories-when-solution-opened">Visual Studio creating IIS virtual directories when solution opened</a>) simply confirm the behaviour.</p>
  
  <p>The response to this question (<a href="https://stackoverflow.com/questions/21046198/opening-projects-changes-iis-settings">Opening projects changes iis settings</a>) is simply wrong, as are some of the comments.</p>
  
  <p>These questions (<a href="https://stackoverflow.com/questions/15646726/visual-studio-2012-changes-iis-application-directory-without-asking">Visual Studio 2012 changes IIS application directory without asking</a>), (<a href="https://stackoverflow.com/questions/39763835/visual-studio-changes-local-iis-configuration">Visual Studio changes local IIS configuration</a>) have no responses.</p>
  
  <p>Basically, no one has said it can't be done, but no one has give a decent solution either.</p>