简体   繁体   English

当启动应用程序是控制台应用程序时,防止iisexpress在解决方案中运行网站

[英]Prevent iisexpress from running the websites in a solution when the startup app is a console app

I have a solution with a number of projects in it. 我有一个包含许多项目的解决方案。 Even if I set the web project's start options to: 即使我将web项目的启动选项设置为:

  1. Don't open a page. 不要打开页面。 Wait for a request from an external application. 等待来自外部应用程序的请求。
  2. Use custom webserver. 使用自定义Web服务器。 Base URL: http://localhost . 基本URL: http://localhost

And the startup project to: 启动项目:

  1. Single startup project 单一启动项目
  2. Select the console application (not website) 选择控制台应用程序(不是网站)

When I press start debugging, IIS express launches (shows up on the taskbar). 当我按下开始调试时,IIS express启动(显示在任务栏上)。 How do I prevent from IIS Express from launching? 如何阻止IIS Express启动? I am only running a console application, and don't want IIS Express running. 我只运行一个控制台应用程序,并且不希望IIS Express运行。

In fact, all of the websites in the solution launch in IIS, and they consume resources on my machine unnecessarily. 实际上,解决方案中的所有网站都在IIS中启动,并且它们不必要地消耗我机器上的资源。

There's easy way to do this: in web project's properties F4 (NOT right click-> properties) set "always start when debugging" to false 有简单的方法:在Web项目的属性F4(不是右键单击 - >属性)中设置“总是在调试时启动”为false

在此输入图像描述

In the Property Pages-> Start Options: Set Start Action = "Don't open a page..."; 在属性页面 - >开始选项:设置开始操作=“不要打开页面...”; Set Server -> Use custom server and leave Base URL blank. 设置服务器 - >使用自定义服务器并将基本URL留空。

For Visual Studio 2013, I configured it like this: 对于Visual Studio 2013,我将其配置如下:

Start Action: Don't open a page. 开始动作:不要打开页面。

Servers: External Host 服务器:外部主机

Project Url: http://NotAStartupApp/ 项目网址: http:// NotAStartupApp /

I uninstalled IIS Express in windows and it worked for me. 我在Windows中卸载了IIS Express,它对我有用。 After publishing my files from VS, automatically my settings changed to point to IIS Express and it wont change to IIS, no matter what, for my Website project. 从VS发布我的文件后,我的设置自动更改为指向IIS Express,无论如何,我的网站项目都不会更改为IIS。 Hope this works for someone. 希望这适用于某人。

To extend @Aleksey L.'s answer, you can actually do this with a plain text editor like Notepad. 为了扩展@Aleksey L.的答案,您实际上可以使用像记事本这样的纯文本编辑器来完成此操作。

In your projectname.csproj.user file, make sure your the AlwaysStartWebServerOnDebug node has a value set to False . projectname.csproj.user文件中,确保AlwaysStartWebServerOnDebug节点的值设置为False

projectname.csproj.user projectname.csproj.user

<Project >  
  <ProjectExtensions>
    <VisualStudio>
      <FlavorProperties>
        <WebProjectProperties>
            ..          
          <AlwaysStartWebServerOnDebug>False</AlwaysStartWebServerOnDebug>
            ..          
        </WebProjectProperties>
      </FlavorProperties>
    </VisualStudio>
  </ProjectExtensions>
</Project>

Alternatively, to do this without a text editor you can use Powershell 或者,要在没有文本编辑器的情况下执行此操作,您可以使用Powershell

$file = 'projectname.csproj.user'
$x = [xml] (Get-Content $file)
$x.Project.ProjectExtensions.VisualStudio.FlavorProperties.WebProjectProperties.AlwaysStartWebServerOnDebug = 'False'
$x.Save($file)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从控制台运行dotnet core应用程序时无法解决依赖关系 - Unable to resolve dependency when running dotnet core app from console 当我关闭启动表单时,如何防止应用程序终止? - How do I prevent the app from terminating when I close the startup form? 防止 ..Net 控制台应用程序打开浏览器 - Prevent a ..Net Console app from opening a browser 设置为“启动时”时,控制台应用程序无法通过任务计划程序启动 - Console app not launching via task scheduler when set to "At StartUp" 运行用于语音识别的控制台应用程序时的RaceOnRCWCleanup - RaceOnRCWCleanup when running console app for speech recognition 使用Mono运行控制台应用程序时出现奇怪的错误? - Weird error when running a console app with mono? 运行EConnect示例控制台应用程序时出现EntryPointNotFoundException - EntryPointNotFoundException when running EConnect sample console app 在应用运行时防止平板电脑进入睡眠状态 - Prevent tablet from sleeping while app is running 从C#解决方案中的控制台应用程序执行WPF - Execute WPF from a Console App in C# solution 在 Linux 作为服务运行时防止 a.Net Core 5 控制台应用程序结束的推荐方法 - Recommended way to prevent a .Net Core 5 console app from ending when run on Linux as a service
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM