title: Once a build fails in TFS 2010, all builds after it on the same agent fail until the service is restarted
body: <p>This is an extension of an earlier issue I had, which I posted about here: <a href="https://stackoverflow.com/questions/24703871/vb-net-method-appears-to-be-called-multiple-times-when-it-actually-isnt-and-re">VB.Net Method appears to be called multiple times when it actually isn't, and returns inconsistent results</a></p>
  
  <p>At that time I had thought the issue was fully resolved, but I've since learned that there were multiple issues.  I have worked out all the kinks with the code and logic, and now I've narrowed down the last remaining issue.</p>
  
  <p>Builds will run perfectly fine until one legitimately fails.  After that point, all the builds <strong>on that specific agent</strong> will fail, even if there were no actual errors with the subsequent builds.  When they fail, I see the exact same symptoms as I did in the other thread, which I will summarize here:</p>
  
  <ul>
  <li>A method that is only called once appears to be called multiple times as evidenced by the build messages</li>
  <li>The build messages will show there is 1 error, but there are no errors in the logs generated by that method (The line to write the error to the log comes immediately after the line where the error is added to the result log, in the same if statement)</li>
  <li>Restarting the build service on the build server "fixes" the problem until the next time a build legitimately fails, at which point the cycle starts again</li>
  </ul>
  
  <p>Build server setup:</p>
  
  <ul>
  <li>Windows Server 2008 R2</li>
  <li>VS 2010 Premium</li>
  <li>Build uses a custom library</li>
  <li>There are 4 build agents, one for each environment (Dev, QA, UAT, Prod)</li>
  </ul>
  
  <p>The build and deploy custom library is written in VB using .Net Framework 4.5, and it calls on another library that is written using .Net Framework 4.5 as well.</p>
  
  <p>The build template doesn't use msbuild.  It's strictly WF that's been stripped down to the bare minimum and only calls commandline programs (Like robocopy) or custom .net classes.</p>
  
  <p>I have verified that if a build fails for one agent (such as Dev), then all builds using that agent will fail.  When it happens, ONLY builds that run on that particular agent will fail, other agents run just fine.  I have not had a chance to test yet if just restarting the agent will "fix" it, or if I have to restart the entire service.</p>
  
  <p>I have tried clearing the Visual Studio cache for the user account running the builds, but that didn't help at all.  I also have a GUI interface that I designed that does all the same things as the build, and uses all the same code, and I am not able to get it to repeat the behavior.</p>
  
  <p>I've enabled logs on the build controller per these steps: <a href="http://blogs.msdn.com/b/aseemb/archive/2010/04/16/how-to-enable-build-agent-or-build-controller-s-logs.aspx" rel="nofollow noreferrer">How to enable build agent or build controller’s logs?</a> however they were no help when this problem occurred (There were no errors logged, nothing was different in the logs for builds that were fine vs. ones that bugged out)</p>
  
  <p>I'm not sure what my next troubleshooting steps should be, I know the problem isn't with my code, and I'm having no luck searching the internet via Google, MSDN, StackOverflow, or picking the brains of my peers at other organizations.</p>
  
  <p>I'm wondering if this could be a bug due to running code that requires .Net Framework 4.5 in TFS 2010 build, since it only officially supports up to 4.0.</p>