RemarkLima
RemarkLima

Reputation: 12037

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.

Upvotes: 6

Views: 2033

Answers (2)

Jesús López
Jesús López

Reputation: 9241

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.

Upvotes: 2

Andrii Litvinov
Andrii Litvinov

Reputation: 13192

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.

Upvotes: 4

Related Questions