title: How to stop Visual Studio adding assemblies to my web.config?
body: <p>Every time i build, or publish, a web-site, Visual Studio attempts to check out the <strong>web.config</strong> file so that it can add numerous assemblies that are not required.</p>
  
  <p>In other words:</p>
  
  <p><strong>web.config</strong> before:</p>
  
  <pre><code>&lt;configuration&gt;
     &lt;system.web&gt;
        &lt;compilation&gt;
           &lt;assemblies&gt;
           &lt;/assemblies&gt;
        &lt;/compilation&gt;
     &lt;/system.web&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p><strong>web.config</strong> after:</p>
  
  <pre><code>&lt;configuration&gt;
     &lt;system.web&gt;
        &lt;compilation&gt;
           &lt;assemblies&gt;
               &lt;add assembly="Microsoft.ReportViewer.Common... /&gt;
               &lt;add assembly="Microsoft.ReportViewer.WinForms... /&gt;
               &lt;add assembly="System.DirectoryServices... /&gt;
               &lt;add assembly="System.Windows.Forms... /&gt;
               &lt;add assembly="ADODB... /&gt;
               &lt;add assembly="System.Management... /&gt;
               &lt;add assembly="System.Data.OracleClient... /&gt;
               &lt;add assembly="Microsoft.Build.Utilities... /&gt;
               &lt;add assembly="Microsoft.ReportViewer.ProcessingObjectModel... /&gt;
               &lt;add assembly="System.Design... /&gt;
               &lt;add assembly="Microsoft.Build.Framework... /&gt;
           &lt;/assemblies&gt;
        &lt;/compilation&gt;
     &lt;/system.web&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>None of these assemblies are required, and most don't exist on the target test, or production, servers.</p>
  
  <p>i keep deleting them every time i build, but it's getting <em>real</em> annoying real fast.</p>
  
  <p>Right now my workaround is to leave web.config read-only - so Visual Studio cannot add assemblies to it.</p>
  
  <hr>
  
  <h2>Update</h2>
  
  <p>Screenshots as proof:</p>
  
  <p><strong>Project Property Pages before</strong>:</p>
  
  <p><a href="https://i.stack.imgur.com/iLTVm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iLTVm.png" alt="link text"></a>
  </p>
  
  <p><strong>Web.Config before:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/iRPiZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iRPiZ.png" alt="alt text"></a></p>
  
  <p><strong>Project Property Pages after:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/axCcy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/axCcy.png" alt="alt text"></a></p>
  
  <p><strong>Web.config after:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/aRbCz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aRbCz.png" alt="alt text"></a></p>
  
  <h2>Update Two</h2>
  
  <p>It should be pointed out explicitly that the web-site works without these extraneous references being added. My interim solution is to keep web.config read-only, and hit <strong>Cancel</strong> whenever Visual Studio complains that it's read-only as it tries to modify it. If i can just stop Visual Studio from trying to modify it in the first place...</p>
  
  <hr>
  
  <h2>Update Three</h2>
  
  <p>It looks like it's not possible. Someone can feel free to give the correct answer, "<strong>You cannot stop Visual Studio from adding assemblies to your web.config</strong>." and i'll mark it.</p>
  
  <p>The only reason i'm keeping the question up is that hopefully someone knows the super-secret option, or registry key, or project or solution setting, to tell Visual Studio to stop thinking.</p>
  
  <hr>
  
  <h2>Update Four</h2>
  
  <p>i didn't accept the accepted answer, and i'd unaccept it if i could. i'm still hoping for the panacea. But right now i'm leaning towards:</p>
  
  <ul>
  <li>Answer: cannot be done (<a href="https://stackoverflow.com/questions/1401897/how-to-stop-visual-studio-adding-assemblies-to-my-web-config/1460570#1460570">manu08</a>)</li>
  <li>Workaround: filtered GAC assemblies registry key (<a href="https://stackoverflow.com/questions/1401897/how-to-stop-visual-studio-adding-assemblies-to-my-web-config/1433819#1433819">Nebakanezer</a>)</li>
  </ul>
  
  <hr>
  
  <p>How do i stop Visual Studio from adding assemblies to my web.config?</p>
  
  <h2>References</h2>
  
  <ul>
  <li><a href="http://www.velocityreviews.com/forums/t605986-visual-studio-keeps-adding-oracle-assemblies-to-webconfig.html" rel="nofollow noreferrer">ASP Net - Visual Studio keeps adding Oracle assemblies to web.config</a></li>
  <li><a href="http://forums.asp.net/p/1158168/1907089.aspx#1907089" rel="nofollow noreferrer">Why are the Visual Studio Add-In Assemblies being added to my web.config?</a></li>
  <li><a href="http://forums.asp.net/p/1308472/2573440.aspx#2573440" rel="nofollow noreferrer">Visual Studio Adds Assembly Reference To web.config</a></li>
  <li><a href="http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_22900555.html" rel="nofollow noreferrer">removing VsWebSite.Interop Assembly from Web.Config</a></li>
  <li><a href="http://www.eggheadcafe.com/forumarchives/vstudiogeneral/Nov2005/post24312075.asp" rel="nofollow noreferrer">Visual Studio 2005 automatically adding references to web.config on build</a></li>
  </ul>