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

from:https://stackoverflow.com/questions/52204892/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?

------------

There are file watchers in Ubuntu that can issue restart commands whenever files are changed like systemd or inotify, but I would strongly advise against that. Uploads can pause or be slow and when uploading 50 files imagine restart after every single one every couple seconds. Server has no way to know when you have finished uploading last DLL. IIS has same problem, it's reliable in development because you refresh the page after the full DLL rebuild. But when in production you don't want random visitors to boot your site midway while it's still uploading. Errors, file locks, all kinds of weirds things can happen.

As pointed by Chris Pratt you want to script your deployment workflow. Idk what environment you are developing on, but if you have Visual Studio and WinSCP it's as easy as writing couple lines of code with Scripting and Task Automation.

Then your publish workflow can be for example as following:

  1. Hit publish in Visual Studio
  2. VS will execute winscp script after publish is finished
    • Authenticate on remote server
    • Upload publish folder to a remote folder
    • Remove old files
    • Prune logs
    • After all done issue systemctl restart kestrel-myapp command
  3. Then your site is deployed, cleaned and restarted in the most reliable fashion with a single click.
posted @   Yaoquan.Luo  阅读(45)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
点击右上角即可分享
微信分享提示