4

I have a live ASP .NET Core site running I built using dotnet publish..

Now I want to update the site with as little down time as possible - hopefully none!

I note during development if the debugger is not attached I can make changes to Views .cshtml files and they are reflected without havint to restart the server so presumably I can just drop the new Views into my live site? How about everything else such as the Controller *.dlls?

I looked but couldn't find any official docs on this :(

markmnl
  • 11,116
  • 8
  • 73
  • 109

3 Answers3

1

No, you can't do it absolutely 'transparent'

IIS is running your website process and dll/exe files are locked. To unlock them - you need to stop the site.

I use following actions:

  1. copy zip with new site to production server
  2. make an appsettings.json file copy on "backup dir" on production server
  3. stop the site in IIS manager. Downtime begins
  4. delete all files from website directory - they are not locked anymore (IIS stopped site)
  5. extract new files from zip package
  6. copy "production" appsettings.json from "backup dir" (overwrite one in zip)
  7. start site in IIS Manager, open it locally in browser. Downtime ends.

On my site, all downtime is less than one minute (copy files, re-start kestrel). If this is unacceptable for you - you need several instances with some sort of "progressive update".

Dmitry
  • 16,110
  • 4
  • 61
  • 73
  • OK, in my case not using IIS, but same I guess (using Nginx). I tired just replacing the files but had to restart kestrel to see the updates.. – markmnl Dec 16 '16 at 10:46
0

You can not do it on files compiled even on IIS or Kestrel

Force updating compiled files can corrupt entire app and make many unexpected errors. Always turn off your app and then update. Updating is only safe with files not compiled like Views. If you rly need save your SLA make web-farm strategy (then you will can upgrade each instance without breaking runtime of app like @Dmitry sad)

J. Doe
  • 2,651
  • 1
  • 13
  • 31
0
  • Rename the old dll file to myapp.dll.old (the app will keep working)
  • Copy over the new one
  • Recycle IIS application pool

These answers suggest similar technique https://stackoverflow.com/a/66580629/56621 and https://stackoverflow.com/a/41149978/56621

Alex from Jitbit
  • 53,710
  • 19
  • 160
  • 149