启动IIS Express以运行ASP.NET Core Apps [英] Launch IIS Express to run ASP.NET Core Apps

查看:62
本文介绍了启动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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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