Web Application not refreshing after deployment without manual app pool recycle

I am currently seeing an issue with deploying from Octopus Deploy Every time I deploy a web application through the tool and browse to the application, I do not see the version being refreshed. I can verify this by looking at the version displayed on the site as well as functionality being missing. My current workaround is to recycle the app pool on each web server after each deployment.
I noticed happening around the time I introduced app autostart/warmups as described here:


I am not sure if this is related. My autostart method is just doing a simple query to keep the database context warm at this time.

I tried to include app pool stopin my Deploy.ps1 script in the beginning of the script as follows.

Write-Host “Starting shut down of app pool:” $appPoolName
Write-Host “Current app pool state:” (Get-WebAppPoolState $appPoolName).Value

Stop-WebAppPool $appPoolName

Write-Host “Current app pool state:” (Get-WebAppPoolState $appPoolName).Value
Start-Sleep -Seconds 1
until ( (Get-WebAppPoolState -Name $appPoolName).Value -eq “Stopped” )

Write-Host “Current app pool state:” (Get-WebAppPoolState $appPoolName).Value

At the end of my, Deploy.ps1, I will start the app pool with the following.

Start-WebAppPool $appPoolName

The logs written from the script is saying the app pool was stopped. But I do not see anything in the Event Log being written even after modifying it to do so in the Advance Setting of the App Pool.

I am not sure what could be causing my issue with deployment and if I am properly recycling the app pool.

Any suggestions would be appreciated. Thanks!