发布已经运行的dotnet应用程序 [英] Publishing a dotnet application that's already running

查看:53
本文介绍了发布已经运行的dotnet应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个脚本来简化发布.NET Core网站的过程.当我对已经运行的服务器运行 dotnet publish 时,我遇到了一个问题.该服务器是安装了dotnet捆绑软件的IIS,因此IIS使用其应用程序池启动dotnet.

I'm attempting to create a script to simplify the process of publishing a .NET Core website. I'm running into an issue when I run dotnet publish against an already running server. The server is IIS with the dotnet bundle installed, so IIS uses its app pool to start dotnet.

这是我的批处理文件.我很高兴使用另一种脚本类型:

Here's my batch file. I'm happy to use another script type:

cd src/app
dotnet build --no-incremental
dotnet publish --framework netcoreapp1.0 --configuration Release --output ../../dist

运行脚本时出现此错误:

When I run the script I get this error:

该进程无法访问文件'C:\ inetpub \ wwwroot \ app \ dist \ app.dll',因为它正在被另一个进程使用."

"The process cannot access the file 'C:\inetpub\wwwroot\app\dist\app.dll' because it is being used by another process."

这很有道理,看来我需要停止,部署和重新启动dotnet.我可以从脚本中执行此操作吗?还是我解决这个问题的方法不对?

This makes sense, it appears I need to stop, deploy, and restart dotnet. Can I do this from the script? Or is my approach to this problem wrong?

推荐答案

最好的方法是将 app_offline.htm 文件拖放到应用程序文件夹中.这将使IIS在复制新版本时停止您的应用程序并向用户提供 app_offline.htm 文件的内容.复制完新版本的应用程序后,请删除 app_offline.htm 文件,然后IIS将启动您的应用程序.您可以在

The best way is to drop an app_offline.htm file to your application folder. This will make IIS stop your application and serve the contents of the app_offline.htm file to the user while you are copying the new version. Once you complete copying the new version of your application remove the app_offline.htm file and IIS will start your application. You can find more details on running ASP.NET Core applications with IIS in my post.

这篇关于发布已经运行的dotnet应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆