启动IIS Express以运行ASP.NET Core Apps

编程入门 行业动态 更新时间:2024-10-10 13:24:05
本文介绍了启动IIS Express以运行ASP.NET Core Apps的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我希望通过使用命令行从IIS Express启动我的ASP.NET Core应用程序来运行它.

I wish to run my ASP.NET Core App by launching it from IIS Express using command line.

我偶然发现了这篇文章

因此,实际上Visual Studio静默添加了两个环境变量 启动IIS Express时,可以将与ASP.NET Core相关的位设置为 注射.

So in fact Visual Studio silently adds the two environment variables when launching IIS Express, so that ASP.NET Core related bits can be injected.

LAUNCHER_ARGS:-调试-p"C:\ Program Files \ dotnet \ dotnet.exe" -a"exec \" C:\ Users \ lextm \ documents \ visual studio 2017 \ Projects \ WebApplication2 \ WebApplication2 \ bin \ Debug \ netcoreapp1.0 \ WebApplication2.dll \"" -pidFile"C:\ Users \ lextm \ AppData \ Local \ Temp \ 2 \ tmpFD6D.tmp" -wd"C:\ Users \ lextm \ documents \ visual studio 2017 \ Projects \ WebApplication2 \ WebApplication2"

LAUNCHER_ARGS: -debug -p "C:\Program Files\dotnet\dotnet.exe" -a "exec \"C:\Users\lextm\documents\visual studio 2017\Projects\WebApplication2\WebApplication2\bin\Debug\netcoreapp1.0\WebApplication2.dll\"" -pidFile "C:\Users\lextm\AppData\Local\Temp\2\tmpFD6D.tmp" -wd "C:\Users\lextm\documents\visual studio 2017\Projects\WebApplication2\WebApplication2"

-pidFile C:\Users\lextm\AppData\Local\Temp\2\tmpFD6D.tmp中的tmp文件始终可以更改.我如何添加LAUNCHER_ARGS作为环境变量,即使tmp文件更改,它也可以正常工作?

The tmp file in -pidFile "C:\Users\lextm\AppData\Local\Temp\2\tmpFD6D.tmp" can always change. How do I add LAUNCHER_ARGS as environment variable which will make it work even if the tmp file changes?

让我知道是否有更简便的方法来启动IIS Express,以使用命令行或powershell脚本运行ASP.NET Core Apps.

Let me know if there is any easier way to launch IIS Express to run ASP.NET Core Apps with command line or powershell scripts.

推荐答案

您正在寻找[System.IO.Path]::GetTempFileName()方法.它会在文件系统上创建空的临时文件,并返回其唯一名称.

You are looking for [System.IO.Path]::GetTempFileName() method. It creates empty temp file on file system and returns its unique name.

我当前正在使用以下PowerShell脚本来运行.NET Core 2.0应用程序:

I'm currently using the following PowerShell script to run my .NET Core 2.0 App:

$env:LAUNCHER_ARGS = "-p ""<path to dotnet.exe>"" -a ""exec \""<path to webapp main dll>\"""" -pidFile $([System.IO.Path]::GetTempFileName()) -wd ""<path to webapp root folder>"" -pr <project name>" $env:LAUNCHER_PATH = "<path to VSIISExeLauncher.exe>" & "<path to iisexpress.exe>" /config:"<path to applicationhost.config>" /site:"<webapp name>"

占位符(尖括号中的文本)必须填充相应的值.您可以通过从Visual Studio中运行项目并使用Process Explorer检查iisexpress.exe进程的环境变量来找到它们,如上面提供的链接中所示.

Placeholders (text within angle brackets) have to be filled with the corresponding values. You can find them out by running your project from Visual Studio and inspecting environment variables of iisexpress.exe process using Process Explorer as shown above in the link you provided.

更多推荐

启动IIS Express以运行ASP.NET Core Apps

本文发布于:2023-11-07 15:28:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1566820.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:ASP   Express   IIS   Apps   Core

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!