IIS -> Lock .NET Core application DLL file
When I try to overwrite .NET Core application DLL file using FTP on production IIS server file is locked and it cannot be overwritten.
To deploy new version I need to stop application in IIS to release lock, then overwrite. It is not possible to deploy without stopping application.
See app_offline.htm: https://docs.asp.net/en/latest/hosting/aspnet-core-module.html#asp-net-core-module-app-offline-htm
If you end up desiring a PowerShell way of doing it, you can use the IIS Admin cmdlets: https://technet.microsoft.com/en-us/library/ee790599.aspx
Stop-WebAppPool -Name $appPoolName
... deploy ...
Start-WebAppPool -Name $appPoolName
Thanks for explanation @Tratcher . I am not sure if this is on your plans but this worked for previous ASP.NET MVC I think? Do you plan to implement this feature or not?
@GuardRex I cannot do it because it is shared hosting enviroment and don't have permission to stop AppPool
Can you make it to 'just work' with msdeploy.exe and Azure? If I understand correctly the web site needs to be restarted to prevent file locking. -enableRule:AppOffline works but the whole website is offline for few minutes which is not a great user experience especially given that we deploy few times per day.
See also http://stackoverflow.com/q/40276582/14131
@chuchuva maybe, but all magic comes with a cost. Previous versions of ASP.NET did some complicated shadow copying to work around the file locking problems.
Magic or not, It worked well. I kinda miss it now after the migration to ASP.NET core...
Agreed with @HarelM. We've run into issues with this from our automated deployments to just end user experience. We've gone from deploying about 10 times a day with the old MVC to maybe a daily deployment at night and accepting that the people using the Core app are going to be annoyed when we take it offline. While not a show stopper, it's added friction towards Core adoption.
👍
Not supporting overlapped recycling is a regression.
Are there plans to revisit this feature and put it on the road map? It's very inconvenient/unfriendly to require everybody deploying a .Net Core website to manually implement a staging-slot strategy if they want to support zero downtime deployments.
Having this feature would make the transition to .Net Core websites much smoother for many people, and would allow for faster adoption of .Net Core websites.
We would like to know as well. Putting a app_offline.htm inside the applications directory does not work.
I've only just realised this 'feature' after moving a number of sites over to AspNetCore. I can't believe it's deemed to be acceptable to take your sites offline for a few minutes every time you want to publish!
This is bad enough for me as a leader of a small team - are those practicing continuous integration on a large scale shunning AspNetCore? There is no way they would be able to have their site going offline for minutes every hour to republish!
Are you deploying use FTP or xcopying? Or are you using webdeploy?
I'm publishing via webdeploy to IIS.
We are currently working around this issue by just deleting the web.config first (effectively killing the application), but this is not really an acceptable solution in the long run.
@DaleMckeown ideally with a continuous integration workflow you'd have multiple servers behind a load balancer. You'd then pull one server, update it, put it back en move on to the next. Ofcourse this is not always possible (like in our case), so you'll have to live with a few minutes downtime. In our case the app is back up within 30s, so this is not really an issue.
@DaleMckeown
I'm publishing via webdeploy to IIS.
There are a few options that can be used to make deployment using webdeploy work well (it supports renaming locked files and dropping app offline automatically). Is that the case by default @shirhatti ?
@ajeckmans
We are currently working around this issue by just deleting the web.config first (effectively killing the application), but this is not really an acceptable solution in the long run.
Does that mean you're doing xcopy deployment?
There are a few options that can be used to make deployment using webdeploy work well (it supports renaming locked files and dropping app offline automatically). Is that the case by default @shirhatti ?
Thanks David - sounds better than what I am currently doing (manually stopping the site & app pool in IIS). Can you point to some resources so I can investigate the implications of these approaches?
@DaleMckeown some info untilI find the source of truth https://github.com/Microsoft/vsts-tasks/issues/5259#issuecomment-346202503
@davidfowl We're using webdeploy to deploy to our testserver (which btw never gives us problems), from there we copy the files to our live servers using robocopy
@ajeckmans
We are currently working around this issue by just deleting the web.config first
When the web.config is removed from the deployment, IIS will serve sensitive files from the deployment. An attacker could simply request files continuously day and night until your 30s window opens up.
@DaleMckeown
Following @ajeckmans advice if you ever want to get into the weeds a bit with a PS approach to do that, you can script the process to drop AppPools one at a time for deployment across a web farm. For an example of how that can be done, see https://github.com/guardrex/aspnetcore-iis-ps-publish ... but just look at that as an experimental example and not a production-quality script. I haven't played with that for a while, but it should (in theory) still work.
@guardrex you're right. We copy an app_offline.htm to the dir first, then we remive the web.config, copy over the application, put back the web.config and remove the app_offline (all with a script ofc). Unfortunately just placing the app_offline file in the websites directory does not break the lock on the dlls. We need to remove the web.config, an action we don't need to do for the older asp.net full apps (like old webforms etc)