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

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

问题描述

我正在编写一个使用 WebListener ,而不是Kestrel。¹我将Visual Studio 2015与Update 3和 .NET Core 1.0.1 tools Preview 2(<在撰写本文时,a 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,并且他们将能够直接点击运行而不会出错。

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 Exp ress启动配置文件。通过项目属性>调试选项卡,可以编辑配置文件列表,但是当我选择 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,因为它可以让我自托管在Windows服务中,在未安装IIS的计算机上仍支持NTLM身份验证。 Kestrel仅在将NTLM托管在IIS中时才支持,而不是在其自身托管时。

推荐答案

更新:

此问题应通过Visual Studio 2017的最新版本(更新)解决。

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

初始答案:

史密斯答案,Visual Studio会在重启时继续还原设置。

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

由于找不到更好的解决方案,我只是拒绝了 launchsettings.json for Visual Studio。我在其他答案中留下了说明,这只是一个复制粘贴:

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. $。 b $ b
  7. 选中创建文件/写入数据权限的拒绝权限。

  8. 在所有打开的对话框和警告中单击确定以保存更改。

  9. 重新打开Visual Studio,发现它无法执行更新。

  1. Update your launchsettings.json for the last time.
  2. Close Visual Studio.
  3. Open security settings (right-click on launchsettings.json in Explorer -> Properties -> Security)
  4. Click Advanced -> Change Permissions
  5. Select "Authenticated Users" (or other user group under which Visual Studio is running on your machine) from the "Permissions entries" list and click Edit ->
  6. Check Deny for "Create files / write data" permission.
  7. Click OK in all open dialogs and warnings to save changes.
  8. Reopen Visual Studio and see it fail to do it's update.

希望它会有所帮助。

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

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