运行 IIS Express 从命令行 .Net Core

huangapple go评论74阅读模式
英文:

Running IIS Express from the Command Line .Net Core

问题

在我正在参与的项目中,我们正在将我们的 Episerver CMS 网站从 CMS11 (.net framework) 升级到 Optimizely CMS12 (.Net core) ,为了在 CLI 中运行 IIS Express(而不需要从 VS/Rider 运行应用程序),并启动 NPM 开发,我们编写了以下 .bat 脚本。

@ECHO OFF

ECHO 启动站点
start iisexpress /config:.vs\*PROJECT_NAME*\config\applicationhost.config /siteid:2
cd %~dp0\src\Site
start npm run develop

由于从框架升级到核心,现在我们通过 appsettings.json 配置项目而不是 applicationhost.config (XML),在其中定义要从哪些站点绑定启动 (siteid:2)。

我一直在寻找一种在 .json 中通过绑定实现相同功能的方法,但没有找到合适的解决方案。是否有人有任何关于解决方法的想法?

英文:

In a project im working on, we are upgrading our Episerver CMS website from CMS11 (.net framework) to Optimizely CMS12 (.Net core) for a customer.

To run IIS Express using CLI (to not have the need to run the application from VS/Rider) and start NPM develop, we have written this .bat script.

@ECHO OFF

ECHO starting site
start iisexpress /config:.vs\*PROJECT_NAME*\config\applicationhost.config /siteid:2
cd %~dp0\src\Site
start npm run develop

As a result of upgrading from framework to core, we are now configuring the project through appsettings.json instead of applicationhost.config (XML), where we define which site bindings to be launched from (siteid:2).

I've been looking for a way to do the same through bindings in .json, with no luck. Does anyone have any ideas for a solution?

答案1

得分: 1

我建议在本地使用Kestrel而不是IIS Express,并且只需使用以下命令启动站点:dotnet run

您还可以使用dotnet watch在源代码文件更改时自动重新构建/重新启动站点。

链接:https://learn.microsoft.com/en-us/aspnet/core/getting-started/?view=aspnetcore-7.0&tabs=windows#run-the-app

英文:

I would recommend using Kestrel instead of IIS Express locally and simply start the site with: dotnet run

You can also use dotnet watch to automatically rebuild/restart the site when source code files change.

https://learn.microsoft.com/en-us/aspnet/core/getting-started/?view=aspnetcore-7.0&tabs=windows#run-the-app

huangapple
  • 本文由 发表于 2023年1月9日 17:21:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/75055212.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定