Razor 页面的部署

Deployment of Razor pages

我在部署 Razor 页面项目时发现了 2 个问题(可能在其他 .net 核心项目中也存在):

  1. 当我部署主编译发布文件myprojectname.dll时,我需要在IIS 中停止该网站,否则我会失败,因为该文件正在使用。如果我在托管环境中无法控制 IIS 怎么办?
  2. 我必须重新部署文件 myprojectname.dll 甚至更改文本中的一个词。有什么简单的方法吗?

When I deploy the main compilied release file myprojectname.dll, I need to stop the website in IIS or I will fail because the file is using. How if I don't have control of IIS in the hosting environment?

解决方案是首先将 app_offline.htm 文件放入 IIS 文件夹以停止整个应用程序,然后在部署后删除 app_offline.htm 以启动应用程序。更详细的可以参考这个article.

此外,如果没有任何控制 IIS 的权限,您也无法在该服务器上发布和运行应用程序。

I have to re-deploy the file myprojectname.dll even changing a single word in the textual content. Is there any simple method?

如果你使用visual studio里面的web deploy来发布web应用,它会先检查你修改了什么文件,它只会发布你修改过的文件。但是如果你把所有文件编译成一个文件,它必须重新构建并将所有文件发布到远程文件夹。