我在哪里可以找到.NET Core Launch(Blazor Standalone)启动配置文件的示例?在你给我推荐https://learn.microsoft.com/en-us/aspnet/core/blazor/debug?tabs=visual-studio-code&view=aspnetcore-3.1#vscode 之前,我已经查看过该链接。然而该网页上没有实际的配置文件示例。
我在哪里可以找到.NET Core Launch(Blazor Standalone)启动配置文件的示例?在你给我推荐https://learn.microsoft.com/en-us/aspnet/core/blazor/debug?tabs=visual-studio-code&view=aspnetcore-3.1#vscode 之前,我已经查看过该链接。然而该网页上没有实际的配置文件示例。
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (Blazor Standalone)",
"type": "coreclr",
"request": "launch",
"program": "dotnet",
"args": [
"run"
],
"cwd": "${workspaceFolder}/src/Project.UI",
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
{
"name": ".NET Core Debug Blazor Web Assembly in Chrome",
"type": "pwa-chrome",
"request": "launch",
"timeout": 30000,
"url": "https://localhost:5001",
"webRoot": "${workspaceFolder}/src/Project.UI",
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}"
}
]
}
"${workspaceFolder}/src/Project.UI"
替换为您的项目位置。 - Colin Bacon你需要首先为 Blazor WebAssembly 创建一个构建任务(task.json)。
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/BlazorSVgTest.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
]
}
然后创建一个启动任务(launch.json),启用调试功能。
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/BlazorSVgTest.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
]
}
好的,在重新审视后,我现在明白了。在 launch.json 中,我需要添加一行 "url": "https://localhost:{PORT}"
并使用 Properties/launchSettings.json
中提到的第一个端口。
为了让浏览器打开,我添加了 "browser": "edge"
,但它不会自动打开页面,所以我仍然需要手动导航到 URL,但我可以接受这个。如果有人知道如何使其工作,请随时分享。我的 launch.json
如下:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch and Debug Standalone Blazor WebAssembly App",
"type": "blazorwasm",
"request": "launch",
"url": "https://localhost:7051",
"browser": "edge"
}
]
}