title: Assembly files locked by IIS and/or application provisioning
body: <h2>The Scenario</h2>
  
  <p>I'm using <a href="http://www.iis.net/downloads/microsoft/web-deploy" rel="nofollow">msdeploy</a> to deploy files to Web Server A (let's call it WebA) and <a href="http://www.iis.net/downloads/microsoft/web-farm-framework" rel="nofollow">Web Farm Framework</a>'s <a href="http://www.iis.net/learn/web-hosting/microsoft-web-farm-framework-20-for-iis-7" rel="nofollow">Application Provisioning</a> feature to synchronise to Web Server B (let's be imaginative and call it WebB).</p>
  
  <h2>The Problem</h2>
  
  <p>For just one specific WCF .NET web service, the msdeploy to WebA works okay, but the sync fails, reporting that a .NET assembly file is locked by the w3wp.exe process.</p>
  
  <h2>What have I tried?</h2>
  
  <p>Of course restarting IIS etc will unlock it and allow the sync, but I'm struggling to work out why it's locked in the first place. I believe IIS doesn't use the deployed files directly, instead copying them to the Temp ASP.NET Files directory and JIT-ing the svc file etc all in there as it does with regular ASP.NET.</p>
  
  <h2>The Question</h2>
  
  <p>Where can I begin to work out why the file would be locked by w3wp.exe? I don't <em>think</em> it'll be the service itself because the msdeploy.exe to WebA works okay and it's only the sync to WebB that fails. Could it be the Application Provisioning "service" on WebB that's locking the file? Why might it do that?</p>