Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to "Hot Publish" a .NET Core application?

I am looking to move some .NET Core applications into production and with the old .NET framework you could update the compiled DLL's for the application's code at any point.

The next time the application pool recycled, you would get your new code - or you could recycle the app pool manually.

With .NET Core, it appears that the running application locks the DLL and it cannot be overwritten until either the process is closed through inactivity, or is ended via Task Manager (Window's server here).

Is the a preferred method to publish a new version without having to set a maintenance window for all the users? This is on a Windows 2012 R2 server running the .NET Core framework via IIS 8 and the App Pool having no managed code.

like image 441
RemarkLima Avatar asked Apr 13 '17 18:04

RemarkLima


People also ask

How do I publish a .NET core application in IIS?

Publishing on IIS Open the project in Visual Studio, click with the mouse's right button on the project and choose the Publish option. Select the Folder tab on the left, fill or select your application folder and click Publish.

Where can I host a .NET core application?

In general, to deploy an ASP.NET Core app to a hosting environment: Deploy the published app to a folder on the hosting server. Set up a process manager that starts the app when requests arrive and restarts the app after it crashes or the server reboots.


2 Answers

For ASP.NET Core hosted with Kestrel runs in separate process and IIS works like Reverse Proxy. So there is not way for DLL release unless you implement it you your application.

Set up a hosting environment for ASP.NET Core on Windows with IIS, and deploy to it section Deploy the application, item 4.

If you want to avoid downtime simply setup two websites on IIS with same set of settings, make an update on second website, put first down, and start second.

like image 162
Andrii Litvinov Avatar answered Sep 25 '22 01:09

Andrii Litvinov


I think the simplest way is to copy all files into a fresh folder and changing the physical path of the web site.

For example, you have all web sites under C:\WebSites, you also have a subfolder for each web site such as C:\WebSites\MyWebSite and a subfolder for each version, such as C:\WebSites\MyWebSite\V01.00.

To deploy a new version V01.01, create a new subfolder C:\WebSites\MyWebSite\V01.01 copy all files to that folder and change the physical path of the web site.

You can easily change the physical path with PowerShell:

Import-Module WebAdministration
Set-ItemProperty -Path "IIS:\Sites\MyWebSite" -name "physicalPath" -value "C:\WebSites\MyWebSite\V01.01"

This is a form of "hot publishing". Additionally you can easily roll back to the previous version if something goes wrong.

Another alternative is to use symbolic links, for example C:\WebSites\MyWebSite may point to C:\WebSiteVersions\MyWebSite\V01.00. To deploy a new version, copy all files to C:\WebSiteVersions\MyWebSite\V01.01 then change the symbolic link so that C:\WebSites\MyWebSite points to C:\WebSiteVersions\MyWebSite\V01.01, and finally recycle the application pool. Click here to see code for doing that

There is also another option called "blue green deployment" strategy. This strategy requires configuring a single server web farm and two web sites. Please see this article for a complete description.

like image 32
Jesús López Avatar answered Sep 23 '22 01:09

Jesús López