title: how to update self contained asp.net core app and avoid file locks
body: <p>I have a self hosted asp.net core app deployed and in use in an enterprise environment on Windows Server 2012.</p>
  
  <p>I am looking for a way to automate the update process, I am currently doing this through a bat file but keep getting windows file lock errors where the file cannot be deleted. The process I am following in the bat file is as follows:</p>
  
  <ol>
  <li><p>kill the dotnet core process for the web app</p></li>
  <li><p>clear the directory (after sleep for a couple of seconds)</p></li>
  <li><p>copy the updates over</p></li>
  <li><p>restart the web app</p></li>
  </ol>
  
  <p>I am getting the errors in 2 where I try to clear out the existing directory which still has file locks even though I have killed the process - "Cannot delete output file - access is denied".</p>
  
  <p>My question is how can I upgrade the self contained asp.net core web app in place and avoid the file locks? If the site is offline for a few seconds it is not an issue.</p>
  
  <p>Thanks</p>