Can I prevent specific directory files from being locked by the dotnet.exe process on IIS Windows server?

140 views Asked by At

I am using CodeDeplpy to deploy several IIS applications on a Windows 2019 server. During the deployment of one of my .Net Core 3.1 applications I noticed this error:

Permission denied @ unlink_internal - C:/inetpub/wwwroot/webApi/AutocheckerEntities.dll

To solve that I added a line that kills the whole dotnet.exe process (see below) in addition to stopping the app pool and the app itself (see below). I added the dotnet kill line as simply stopping the app pool & app did not get around the error.

appstop.ps1:

Stop-WebSite 'WebApi'
Stop-WebAppPool (Get-Website -Name WebApi).applicationPool
taskkill /IM "dotnet.exe" /F

appspec.yml:

version: 0.0
os: windows
files:
  - source: /
    destination: C:\inetpub\wwwroot\webApi
hooks:
   BeforeInstall:
     - location: CodeDeploy/appstop.ps1
       runas: administrator
   ApplicationStart:
     - location: CodeDeploy/appstart.ps1       
       runas: administrator

Is there a way to release temporarily the files in C:\inetpub\wwwroot\webApi directory without killing the whole dotnet.exe process? I have other dotnet applications on the same server and killing the process can affect those as well.

0

There are 0 answers