title: Fixing NuGet packages and references once and for all
body: <p><em>Windows 8.1 Enterprise x64, Visual Studio 2015, MVC 5, EF 6, VS Online using git</em></p>
  
  <p>I'm a relatively new developer with Visual Studio (about nine months), and ever since I started I've had an incredibly difficult time with references and NuGet packages. All of my references were working correctly on Friday when I shut my computer down for the weekend. I didn't touch the computer at all the entire weekend, now I've booted up today and I have a ton of reference errors:</p>
  
  <p><a href="https://i.stack.imgur.com/iMpl5.png" rel="noreferrer"><img src="https://i.stack.imgur.com/iMpl5.png" alt="list of errors"></a></p>
  
  <p><em>(There are 6,262 errors total but I obviously can't screenshot the entire thing.)</em></p>
  
  <p>Like I said, this sort of problem occurs very often, and it's incredibly frustrating. Things I've tried:</p>
  
  <ul>
  <li>Ensure all references throwing the errors actually are referenced</li>
  <li>Un/reinstall the packages throwing the errors in NuGet</li>
  <li>Completely delete the contents of the <code>packages</code> folder and let NuGet restore them (all reinstalled, views have the same errors as before)</li>
  <li>Ensure <strong>every single reference</strong> is set to <code>Copy Local</code></li>
  <li>Close the solution, delete all <code>bin</code> and <code>obj</code> folders, reboot computer, clean, rebuild</li>
  <li>Ensured all necessary references are in the relevant <code>web.config</code> (either inside <code>Views</code> or at the root)</li>
  <li>Check for NuGet option to restore missing packages (did not appear, all packages are in my local <code>packages</code> folder)</li>
  <li>Other things on SO that I'm sure I've forgotten to list here</li>
  </ul>
  
  <p>I'm at my wits' end with these packages and references. It's a different fix every time, and this time I can't figure it out. Am I missing some obvious fix, something I overlooked? Is there a way to somehow take a backup when this is working and restore it whenever things break? Any ideas whatsoever, whether helping with the current problem or for fixing the underlying problem, would be very much appreciated.</p>
  
  <p><strong>Additional note</strong></p>
  
  <p>The problem is NOT only with views--controllers are also throwing errors. Specifically:</p>
  
  <blockquote>
    <p>The type or namespace name 'Controller' could not be found (are you missing a using directive or an assembly reference?)</p>
  </blockquote>
  
  <p><em>(It literally says <code>Controller</code>, that's not something I changed for privacy or whatnot.)</em></p>
  
  <p>These are thrown despite the fact that I have <code>using</code> statements for all of the necessary namespaces. The <code>using</code> statements themselves work properly, but the error is thrown in the code. The automatic fix suggested is to manually reference everything: for example, <code>var sb = new StringBuilder();</code> wants me to change the line to <code>var sb = new System.Text.StringBuilder();</code>. Testing that fix does not correct the problem, the same error is thrown but on <code>System</code> instead of <code>StringBuilder</code>.</p>
  
  <p><strong>Additional requested information</strong></p>
  
  <ul>
  <li>I use git with VS Team Services (but packages are ignored with <code>.gitignore</code>).</li>
  <li>I and one other person work on this, but the other person hasn't touched it at all (not even pulling from the remote repo) in several weeks.</li>
  <li>References in the <code>.csproj</code> file are in the format <code>..\..\..\packages\</code> (correct for the location relative to the <code>.csproj</code> file).</li>
  <li>Targeting .NET 4.6 (always have been, that's not new)</li>
  <li>All references resolve, no exclamation marks in the references list.</li>
  </ul>