asp.net-core - 在.NET Core中构建和运行时如何禁用浏览器启动

标签 asp.net-core visual-studio-code

我正在使用macOS开发带有.NET Core的Web API,并将其部署到Linux。我对使用浏览器完全没有兴趣。但是,如果从Visual Studio代码构建和运行(是否调试),则每次启动时,浏览器都会启动

我必须关闭选项卡,移开浏览器,进入Paw,在这里我实际测试了API,然后回到VS Code。

每次都这样做很烦人。

是否没有禁用浏览器启动的配置?

谢谢

最佳答案

简短答案

打开.vscode/launch.json文件并禁用launchBrowser

更多细节

  • dotnet new webapi
  • 打开VS代码。
  • 添加所需的 Assets 以进行构建和调试。

  • 此时,存在一个.vscode目录,其中包含一个launch.json文件。打开该文件,然后禁用或删除以下内容。
    "launchBrowser": {
        "enabled": true,
        "args": "${auto-detect-url}",
        "windows": {
            "command": "cmd.exe",
            "args": "/C start ${auto-detect-url}"
        },
        "osx": {
            "command": "open"
        },
        "linux": {
           "command": "xdg-open"
        }
    },
    

    另请参阅:https://code.visualstudio.com/docs/editor/debugging#_launch-configurations

    关于asp.net-core - 在.NET Core中构建和运行时如何禁用浏览器启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43957547/

    相关文章:

    c# - 我该如何解决 'Microsoft.AspNetCore.NodeServices.HostingModels.NodeInvocationException'

    asp.net-core - Hook 到 IdentityServer4 session cookie 滑动过期

    .NET Core 3 System.Text.Json 嵌套对象序列化

    asp.net-core - ASP.NET Core 3 Razor 页面 DataAnnotation Compare 属性返回 "Could not find a property named <n>"

    c# - 使用依赖注入(inject)将 token 获取从startup.cs传递到HomeController.cs

    asp.net-mvc - 带有 ASP.NET MVC 项目的 Visual Studio 代码

    python - 如何在 VS Code 中运行 Python 脚本之前自动保存更改

    windows - Windows 11 上的 Visual Studio Code 中的图形故障/伪影

    javascript - [通告*1]是什么意思(VS代码)

    java - Azure Java函数 "jar being added does not exist."