title: MSBuild, OutputPath to a lib directory is not honoured
body: <p>I spent hours now but I simply don't get it:</p>
  
  <p>Why is a <strong>lib</strong> sub directory not honoured by the VS "fast up-to-date check"?
  If a lib output dir for libraries is set, the solution is always rebuild - if changes have been made or not does not matter. If <strong>\lib</strong> sub dir is removed it works. Why? </p>
  
  <p>Here is what I tested so far:</p>
  
  <p>Refer to the next code snippet. That one works perfectly. If several dependent project are asked to build multiple times they actually build only once if no changes have been made. The Visual Studio FastUpToDateCheck kicks in.</p>
  
  <p>But if you change the line </p>
  
  <p><code>&lt;OutputPath&gt;$(SolutionDir)bin\$(Configuration)\$(Platform)&lt;/OutputPath&gt;</code></p>
  
  <p>to </p>
  
  <p><code>&lt;OutputPath&gt;$(SolutionDir)bin\$(Configuration)\$(Platform)\lib\&lt;/OutputPath&gt;</code></p>
  
  <p>it constantly rebuilds. Any ideas why?</p>
  
  <p>ComponentBuild.props located next to .sln file </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
  
    &lt;PropertyGroup&gt;
      &lt;AutoGenerateBindingRedirects&gt;true&lt;/AutoGenerateBindingRedirects&gt;
      &lt;IntermediateOutputPath&gt;$(SolutionDir)obj\$(Configuration)\$(MSBuildProjectName)\&lt;/IntermediateOutputPath&gt;
      &lt;UseCommonOutputDirectory&gt;False&lt;/UseCommonOutputDirectory&gt;
      &lt;DisableFastUpToDateCheck&gt;false&lt;/DisableFastUpToDateCheck&gt;
    &lt;/PropertyGroup&gt;
  
    &lt;PropertyGroup Condition=" '$(OutputType)' == 'Library' "&gt;
      &lt;!-- To distinguish by \lib\ does not work, a rebuild is triggered since the up-to-date check fails --&gt;
      &lt;!-- &lt;OutputPath&gt;$(SolutionDir)bin\$(Configuration)\$(Platform)\lib\&lt;/OutputPath&gt; --&gt;
      &lt;OutputPath&gt;$(SolutionDir)bin\$(Configuration)\$(Platform)&lt;/OutputPath&gt;   
      &lt;OutDir&gt;$(OutputPath)&lt;/OutDir&gt;
    &lt;/PropertyGroup&gt;
  
    &lt;PropertyGroup Condition=" '$(OutputType)' == 'Exe' "&gt;
      &lt;OutputPath&gt;$(SolutionDir)bin\$(Configuration)\$(Platform)\&lt;/OutputPath&gt;
      &lt;OutDir&gt;$(OutputPath)&lt;/OutDir&gt;
    &lt;/PropertyGroup&gt;
  &lt;/Project&gt;
  </code></pre>
  
  <p>The file is included in csproj files just before <code>Import Microsoft.CSharp.targets</code>:</p>
  
  <p>.csproj file:</p>
  
  <pre><code>    &lt;!-- position of include is important, OutputType of project must be defined already --&gt;
      &lt;Import Project="$(SolutionDir)ComponentBuild.props" Condition="Exists('$(SolutionDir)ComponentBuild.props')" /&gt; 
      &lt;Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /&gt;
      &lt;PropertyGroup&gt;
        &lt;PostBuildEvent&gt;
        &lt;/PostBuildEvent&gt;
      &lt;/PropertyGroup&gt;
  </code></pre>
  
  <p>The behaviour becomes more weird, the more I test. 
  I created two simple library projects A and B. B depends on A. I added above mentioned import and the FastUpToDateCheck works.
  After adding lib path to the library outputtype, it works when nothing else is changed. But when lib B project is cleaned, every subsequent builds do rebuild project B. </p>
  
  <p>When adding lib path to the exe outputtype as well. The FastUpToDateCheck works again. </p>
  
  <p>Then I removed the lib path again from output type exe, but the FastUpToDateCheck surprisingly still works - always. Even when cleaning the build, changing a class or deleting all obj and bin folders.</p>
  
  <p>BUT as soon as  I removed the lib path from the lib outputtype as well, i.e. I set back all to the original state, it FAILS. It rebuilds every time. The first line of the diagnostic output is</p>
  
  <blockquote>
    <p>Project 'ClassLibrary1' is not up to date. Missing output file
    'c:\Users\hg348\Documents\Visual Studio
    2015\Projects\BuildTest\bin\Debug\AnyCPU\lib\ClassLibrary1.dll'</p>
  </blockquote>
  
  <p>It still looks into lib path even though it isn't set any more.
  I think there is some nasty caching involved.</p>
  
  <p>Can someone please verify this?</p>