asp.net-core - VS Code 不在 ASP.NET Core 项目中启动浏览器

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

这是我的 launch.json 文件。该项目在指定端口上正确构建和监听,但未启动浏览器。我在 Mac OSX 上,Chrome 是我的默认浏览器。项目构建后启动默认浏览器需要指定什么?

{
   "version": "0.2.0",
   "configurations": [
       {
           "name": ".NET Core Launch (web)",
           "type": "coreclr",
           "request": "launch", 
           "preLaunchTask": "build",
           "program": "${workspaceFolder}/src/ProjectName/bin/Debug/netcoreapp3.0/ProjectName.dll",
           "args": [],
           "cwd": "${workspaceRoot}/src/ProjectName",
           "stopAtEntry": false,
           "launchBrowser": {
                "enabled": true,
                "args": "${auto-detect-url}",
                "windows": {
                    "command": "cmd.exe",
                    "args": "/C start ${auto-detect-url}"
                },
                "osx": {
                    "command": "open"
                },
                "linux": {
                    "command": "xdg-open"
                }
            },
            "env": {
                "ASPNETCORE_ENVIRONMENT": "Development",
                "ASPNETCORE_URLS": "https://localhost:5001"
            },
            "sourceFileMap": {
                "/Views": "${workspaceRoot}/Views"
            }
       },
    ]
}

最佳答案

我遇到了同样的问题...

在某处读到 VSCode 启动浏览器的作用是在控制台中查找“Now listening on: https://localhost:XXXX”字符串以启动浏览器。

我在没有控制台输出的情况下使用 Serilog,所有日志都被写入文件,因此控制台没有这样的输出。

禁用 Serilog 并启动到浏览器开始工作。

检查你的控制台输出

关于asp.net-core - VS Code 不在 ASP.NET Core 项目中启动浏览器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59204217/

相关文章:

c# - 从 Visual Studio 启动 ASP.NET Core 不是从构建文件夹启动

angular - 在 Visual Studio Code 中调试 Angular2 应用程序

typescript - Visual Studio Code 使用的是哪个 TypeScript 版本?如何更新?

python - 为什么使用按钮运行脚本时会打开 quote> 提示

visual-studio-code - Visual Studio Code settings.json 中的自定义变量

php - VS Code php 标签自动完成

c# - 如何使用 Entity Framework Core 运行迁移 SQL 脚本

c# - .NET CORE 未选择部分 - 默认身份 UI 布局需要部分 View

c# - 如何将 XML 数据加载到数据结构中?

editor - 如何在 Visual Studio Code 中复制一行或所选内容?