如何禁用 ASP.NET Core 的 IIS Express 启动配置文件? [英] How can I disable the IIS Express launch profile for ASP.NET Core?

查看:22
本文介绍了如何禁用 ASP.NET Core 的 IIS Express 启动配置文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个使用 WebListener,而不是 Kestrel.¹ 我使用的是带有 Update 3 的 Visual Studio 2015 和.NET Core 1.0.1 工具预览版 2"(<一个 href="https://www.microsoft.com/net/core#windowsvs2015" rel="noreferrer">下载站点截至撰写本文时).

I'm writing an ASP.NET Core app (on the full .NET Framework) that uses WebListener, rather than Kestrel.¹ I'm using Visual Studio 2015 with Update 3, and ".NET Core 1.0.1 tools Preview 2" (the latest VS tooling on the download site as of this writing).

因为我使用的是 WebListener,并且因为 WebListener 不是与 IIS Express 兼容,我想在 Visual Studio 中禁用IIS Express"启动配置文件,这样当我的队友打开此解决方案时,他们的 Visual Studio 将默认运行控制台应用程序而不是 IIS Express,并且他们将能够点击 Run 而不会出错.

Because I'm using WebListener, and because WebListener is not compatible with IIS Express, I would like to disable the "IIS Express" launch profile in Visual Studio, so that when my teammates open this solution, their Visual Studios will default to running the console app instead of IIS Express, and they'll be able to just hit Run and not get errors.

但到目前为止,我还没有能够摆脱 VS 的IIS Express"启动配置文件.项目属性 > 调试选项卡让我编辑配置文件列表,但是当我选择IIS Express"配置文件时,删除"按钮被禁用.如果我直接编辑 launchSettings.json,并从配置文件"下删除IIS Express"元素,文件 > 保存操作会静默地将IIS Express"配置文件插入到保存到磁盘的 JSON 中!

But so far, I haven't been able to rid VS of the "IIS Express" launch profile. The Project Properties > Debug tab lets me edit the list of profiles, but when I select the "IIS Express" profile, the "Delete" button is disabled. If I edit launchSettings.json directly, and delete the "IIS Express" element from under "profiles", the File > Save operation silently inserts the "IIS Express" profile back into the JSON that it saves to disk!

显然微软真的希望始终拥有一个IIS Express"启动配置文件,即使它不一定与所有 ASP.NET Core 项目兼容.但值得一问:有没有人找到一种方法来禁用 ASP.NET Core 项目中的IIS Express"启动配置文件,并且只有自托管选项(s) 在启动配置文件选择器中?

Apparently Microsoft really wants to always have an "IIS Express" launch profile, even though it isn't necessarily compatible with all ASP.NET Core projects. But it's worth asking: Has anyone found a way to disable the "IIS Express" launch profile in an ASP.NET Core project, and have only the self-host option(s) in the launch-profile selector?

¹ 对于好奇的人,我使用 WebListener 是因为它可以让我在没有安装 IIS 的机器上自托管 Windows 服务并且仍然支持 NTLM 身份验证.Kestrel 仅在 IIS 中托管时才支持 NTLM,在自托管时不支持.

推荐答案

更新:

应使用 Visual Studio 2017 的最新版本(更新)修复此问题.

The issue should be fixed with the latest release (update) of Visual Studio 2017.

初始答案:

正如 ssmith 答案 中的评论所述,Visual Studio 会在重新启动时不断恢复设置.

As mentioned in comments in ssmith answer, Visual Studio keeps restoring the settings on restart.

由于找不到更好的解决方案,我只是拒绝了 Visual Studio 对 launchsettings.json 的写入权限.我在其他类似问题的回答中留下了说明,这里只是复制粘贴:

Since I could not find a better solution, I just denied the write permissions on launchsettings.json for Visual Studio. I left the instructions in my other answer for similar question, here is just a copy&paste:

  1. 最后一次更新您的 launchsettings.json.
  2. 关闭 Visual Studio.
  3. 打开安全设置(在资源管理器中右键单击 launchsettings.json -> 属性 -> 安全性)
  4. 点击高级 -> 更改权限
  5. 从权限条目"列表中选择经过身份验证的用户"(或在您的计算机上运行 Visual Studio 的其他用户组),然后单击编辑 ->
  6. 选中创建文件/写入数据"权限的拒绝.
  7. 在所有打开的对话框和警告中单击确定"以保存更改.
  8. 重新打开 Visual Studio,发现更新失败.

希望有帮助.

这篇关于如何禁用 ASP.NET Core 的 IIS Express 启动配置文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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