title: NuGet restoring PostSharp package before the build begins
body: <p>I am using PostSharp and I have the following target description in my project file:</p>
  
  <pre><code>&lt;Target Name="EnsurePostSharpImported" BeforeTargets="BeforeBuild" Condition="'$(PostSharp30Imported)' == ''"&gt;
    &lt;Error Condition="!Exists('..\..\packages\PostSharp.3.1.33\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.3.1.33\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>As far as I understand, this is added to the project when PostSharp is referenced through NuGet, and the error conditions check the following:  </p>
  
  <ul>
  <li>The <strong>first error condition</strong> breaks the build when PostSharp is not available (i.e. NuGet did not restore it successfully).</li>
  <li>The <strong>second error condition</strong> breaks the build when PostSharp was successfully restored by NuGet on the last build but was therefore not included in the project, so therefore a rebuild is necessary.</li>
  </ul>
  
  <p><strong>BUT</strong>, if I have the following configuration in <code>NuGet.Config</code> and <code>.csproj file</code>, is the second error condition even necessary?  </p>
  
  <p><strong><code>NuGet.Config</code> file:</strong></p>
  
  <pre><code>&lt;configuration&gt;
    &lt;packageRestore&gt;
      &lt;!-- Allow NuGet to download missing packages --&gt;
      &lt;add key="enabled" value="True" /&gt;
      &lt;!-- Automatically check for missing packages during build in Visual Studio --&gt;
      &lt;add key="automatic" value="True" /&gt;
    &lt;/packageRestore&gt;
    ...
  &lt;/configuration&gt;
  </code></pre>
  
  <p><strong><code>.csproj</code> file:</strong></p>
  
  <pre><code>&lt;RestorePackages&gt;true&lt;/RestorePackages&gt;
  </code></pre>
  
  <p>As far as I understand, NuGet will then restore the missing packages BEFORE the build even starts.  The second error condition will essentially break the build for no reason at all.</p>
  
  <p>Note: I am using Visual Studio 2013 and NuGet 2.8.</p>