Search code examples
asp.netubuntuasp.net-coreasp.net-core-2.1kestrel-http-server

Reload ASP.NET Core app when dll files change (bin deploy)


Environment: ASP.NET Core 2.1, Ubuntu.

In old style ASP.NET, when I did a bin deploy (uploaded some dll files for example), the webapp would detect that and reload itself - very useful.

With Core it doesn't do that. I need to stop and restart the dotnet MyApp.dll process.

How do I make it detect changes to binaries and reload?


Solution

  • There's nothing I'm aware of that will do this for you. IIS watches things like the bin directory, web.config, etc. and recycles the App Pool when it detects changes, but that's because it knows to. It's also a full-featured web server, and App Pool recycling on file changes is one of those features. Kestrel, which I assume your using is not. It's a very simple web server that does just what it needs to do as strictly a web server. That's why a more traditional web server like IIS, Apache, Nginx, etc. is normally used as a reverse proxy in front of Kestrel - to provide more advanced functionalities.

    All that said, though, this is really just a matter of your release strategy. Personally, I'd encourage you to go with something far more robust that copy-pasting DLLs, but if you want to go that route, you can also script it. Create a shell script to copy the bin directory and restart your app. Your release should be one rails as much as possible. Every time human intervention is called for, you have a potential point of failure, because humans are inherently fallible. A script, however, once tested and ensured to work, will pretty much work every time, because it always does the same things in the same order.