title: dotnet publish Error: The process cannot access the file because it is being used by another process
body: <p>I get the following error when tring to run <code>dotnet publish</code>:</p>
  
  <blockquote>
    <p>The process cannot access the file because it is being used by another
    process.</p>
  </blockquote>
  
  <p>This appears to happen when you try to publish your app and you have been viewing the published version in the browser, for some reason it locks out the files.</p>
  
  <p>Full error message:</p>
  
  <blockquote>
    <p>C:\Program Files\dotnet\sdk\2.2.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(169,5): warning MSB3026: Could not copy "obj\Debug\netcoreapp2.2\TemplateWebApp.dll" to "bin\Debug\netcoreapp2.2\publish\TemplateWebApp.dll". Beginning retry 1 in 1000ms. The process cannot access the file '\cpft-bi-web01\d$\Websites\TemplateWebApp\bin\Debug\netcoreapp2.2\publish\TemplateWebApp.dll' because it is being used by another process.  [\cpft-bi-web01\d$\Websites\TemplateWebApp\TemplateWebApp.csproj]</p>
  </blockquote>
  
  <p>I can resolve this by closing the browser and the restarting the website on IIS Manager but this is really not ideal, does anyone know the cause of this?</p>