title: Can you remove a file from the Build Item group in a sql server project?
body: <p>My team has gone years (before I joined) of not adopting sql server database projects. Primarily because there are items that have circular references therefor can't build. I realize the recommended approach is to factor out or fix the circular references. </p>
  
  <p>However to prove we can use them without having to fix all that technical debt, I'd like to hook my sql server project's build process to remove the items from the <code>Build</code> item group. I'm very familiar with msbuild but so far nothing seems to be changing that file being included in the build and failing it.</p>
  
  <p><strong>Setting the file(s) to <code>None</code> instead of <code>Build</code> works fine, until we try to do a schema compare. Where it either sets them back to build, or adds them again with a new file name ending in <code>_1.sql</code></strong></p>
  
  <pre><code>&lt;Target Name="CustomSqlHook" BeforeTargets="CheckRequiredProperties;BeforeBuild;All;_SetupSqlBuildInputs;SqlBuild;SqlStaticCodeAnalysis;ResolveArtifactReferences;Build"&gt;
      &lt;Message Text="Build Before: @(Build)" Importance="high" /&gt;
      &lt;Message Importance="High" Text="custom sql hooked" /&gt;
      &lt;Message Importance="High" Text="build items are @(Build-&amp;gt;Count())" /&gt;
      &lt;ItemGroup&gt;
        &lt;Build Remove="project\Views\uvw_survey_history.sql" /&gt;
      &lt;/ItemGroup&gt;
      &lt;Message Text="-------------------------" /&gt;
      &lt;Message Text="Build After: @(Build)" Importance="high" /&gt;
      &lt;Message Importance="High" Text="build items are @(Build-&amp;gt;Count())" /&gt;
  &lt;/Target&gt;
  </code></pre>
  
  <p>which shows the count of included items in the build group as going from 2978 to 2977. However the build still fails on the same file.
  <img src="https://i.stack.imgur.com/XgcqX.png" alt="sqlerror"></p>