title: How to prevent content files to be removed during incremental build?
body: <p>I have a Visual Studio 2015 Update 3 solution with 3 projects:</p>
  
  <p>My top-level application is <code>MyApp</code> which has a project reference on <code>ClassLibrary2</code> which in turn has a project reference on <code>ClassLibrary1</code>:</p>
  
  <pre><code>MyApp -&gt; ClassLibrary2 -&gt; ClassLibrary1
  </code></pre>
  
  <p>The <code>ClassLibrary1</code> has a data file, <code>data.bin</code>, that is required for its normal execution. It is expected that this data file will be found in a <code>Resources/</code> sub-folder relative to where the <code>ClassLibrary1</code> assembly is when the application is executed. The structure of the <code>ClassLibrary1</code> is similar to:</p>
  
  <pre><code>ClassLibrary1.csproj
      Resources/
          data.bin
      MyClassBehaviorDrivenByData.cs
      ...
  </code></pre>
  
  <p>The <code>data.bin</code> file has its <code>Build Action</code> property set to <code>Content</code> (I have also tried with <code>None</code>) and its <code>Copy to Output Directory</code> set to <code>Copy If Newer</code>.</p>
  
  <p>If I do a full solution Rebuild, the <code>data.bin</code> file finds its way to the output directory of <code>MyApp</code>, as expected. However, if I do some changes in the <code>MyApp</code> project and build the solution, the <code>data.bin</code> file is <strong>deleted</strong> from the output directory of <code>MyApp</code> (note: the Output window shows that only <code>MyApp</code> is built since only the code of <code>MyApp</code> was changed).</p>
  
  <p>Workarounds:</p>
  
  <ol>
  <li><p>I could use post-build steps in <code>MyApp</code> to forcefully copy the data file to the output directory each time <code>MyApp</code> builds. However, this goes against the principle that the developer "owning" <code>ClassLibrary1</code> should not have to worry about modifying post-build scripts in consuming projects if he adds a new data file, modify existing ones or move them elsewhere.</p></li>
  <li><p>I could directly add a reference to <code>ClassLibrary1</code> from <code>MyApp</code>. However, this violates the desire to hide away the <code>ClassLibrary1</code> functionality/API under the <code>ClassLibrary2</code> API (i.e., I don't want <code>ClassLibrary1</code> API to leak into <code>MyApp</code>). </p></li>
  </ol>
  
  <p>My questions are: what causes the <code>data.bin</code> file to be deleted from <code>MyApp</code>'s output directory during incremental builds of <code>MyApp</code> and is there a way to prevent this to happen without using one of the 2 workarounds listed above?</p>