title: VS Build fails for .NET project because of NuGet package restore errors
body: <p>I am working on an MVC.NET project using .NET 4.5.2 in Visual Studio 17 which is unable to build due to the error:</p>
  
  <blockquote>
    <p>The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see <a href="http://www.postsharp.net/links/nuget-restore" rel="nofollow noreferrer">http://www.postsharp.net/links/nuget-restore</a>.</p>
  </blockquote>
  
  <p>My version of PostSharp is 4.1.30.</p>
  
  <p>This error happens every time I build or rebuild the proejct and doesn't disappear after building several times in a row. The error is happening for several projects which reference PostSharp. </p>
  
  <p>The error only occurs after I make a change within the solution. If I checkout a fresh copy of Trunk, I can load the website. It's only after making a chance that these errors occur. The change can be small, such as adding a new controller file in an unrelated project to where the errors reference. </p>
  
  <p>I've tried restoring my NuGet packages, rebooting my machine, even deleting my repo and re-checking out a clean install of Trunk. How can I get past this error? I'm not sure if it's definitely related to PostSharp, or a more general NuGet error. </p>
  
  <p>After looking in the .csproj file to see what is causing the error in one of the projects, I found these lines:</p>
  
  <pre><code> &lt;Import Project="packages\PostSharp.4.1.25\tools\PostSharp.targets" Condition="Exists('packages\PostSharp.4.1.25\tools\PostSharp.targets')" /&gt;
   &lt;Target Name="EnsurePostSharpImported" BeforeTargets="BeforeBuild" Condition="'$(PostSharp30Imported)' == ''"&gt;
      &lt;Error Condition="!Exists('packages\PostSharp.4.1.25\tools\PostSharp.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://www.postsharp.net/links/nuget-restore." /&gt;
      &lt;Error Condition="Exists('packages\PostSharp.4.1.25\tools\PostSharp.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://www.postsharp.net/links/nuget-restore." /&gt;
    &lt;/Target&gt;
  </code></pre>
  
  <p>I tried removing it to see what would happen but perhaps unsuprisingly it didn't build and didn't report any errors. </p>