dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.88k stars 676 forks source link

preLaunchTask not run on Blazor WebAssembly Hosted app #6518

Open StamValsam opened 1 year ago

StamValsam commented 1 year ago

Issue Description

Despite configuring a preLaunchTask to build (using dotnet build) on a Blazor WebAssembly Hosted app in the .vscode\launch.json and .vscode\tasks.json files, the task is not run. The task is run when the C# extension is disabled (however, this leads to the launch failing, as the ms-dotnettools.blazorwasm-companion also becomes disabled, leading to the error message "Configured debug type 'blazorwasm' is not supported.").

I searched for a similar issue, but I could not find one. My apologies in advance if there is such an issue and a solution. If that is the case, kindly provide the link.

Steps to Reproduce

  1. Create a new Blazor WebAssembly Hosted app by running 'dotnet new blazorwasm --hosted').
  2. Use the following configuration files in the .vscode folder:

launch.json:

{
"version": "0.2.0",
    "configurations": [
        {
            "name": "Launch and Debug Standalone Blazor WebAssembly App",
            "type": "blazorwasm",
            "preLaunchTask": "build",
            "request": "launch",
            "cwd": "${workspaceFolder}/Server",
            "hosted": true,
            "program": "${workspaceFolder}/Server/bin/Debug/net7.0/TestBlazorWasmApp.Server.dll",
            "url": "https://localhost:7220",
            "browser": "chrome"
        }
    ]
}

tasks.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}/TestBlazorWasmApp.sln"             
          ],
          "problemMatcher": "$msCompile"
       },
    ]
 }
  1. Select the "Launch and Debug Standalone Blazor WebAssembly App" debug configuration.
  2. Modify any source code file in order to cause deliberately a compiler error.
  3. Save the file.
  4. Debug (e.g. by pressing F5).

Expected Behavior

The dotnet build command should be executed before launching the apps. The build would result in an error and the apps would not be launched.

Actual Behavior

The apps launch immediately.

Environment information

VSCode version: 1.83.0 C# Extension: 2.5.30 Using OmniSharp: false

Dotnet Information .NET SDK: Version: 7.0.401 Commit: eb26aacfec Runtime Environment: OS Name: Windows OS Version: 10.0.19045 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\7.0.401\ Host: Version: 7.0.11 Architecture: x64 Commit: ecb34f85ec .NET SDKs installed: 7.0.401 [C:\Program Files\dotnet\sdk] .NET runtimes installed: Microsoft.AspNetCore.App 6.0.22 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.22 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.22 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Other architectures found: x86 [C:\Program Files (x86)\dotnet] registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation] Environment variables: Not set global.json file: Not found Learn more: https://aka.ms/dotnet/info Download .NET: https://aka.ms/dotnet/download
Visual Studio Code Extensions |Extension|Author|Version|Folder Name| |---|---|---|---| |blazorwasm-companion|ms-dotnettools|1.1.4|ms-dotnettools.blazorwasm-companion-1.1.4| |csharp|ms-dotnettools|2.5.30|ms-dotnettools.csharp-2.5.30-win32-x64| |gitlens|eamodio|14.3.0|eamodio.gitlens-14.3.0| |LiveServer|ritwickdey|5.7.9|ritwickdey.liveserver-5.7.9| |remote-containers|ms-vscode-remote|0.315.1|ms-vscode-remote.remote-containers-0.315.1| |sonarlint-vscode|SonarSource|3.22.0|sonarsource.sonarlint-vscode-3.22.0-win32-x64| |vscode-docker|ms-azuretools|1.26.1|ms-azuretools.vscode-docker-1.26.1| |vscode-dotnet-runtime|ms-dotnettools|1.8.0|ms-dotnettools.vscode-dotnet-runtime-1.8.0| |vscode-yaml|redhat|1.14.0|redhat.vscode-yaml-1.14.0|;
WellspringCS commented 1 month ago

I am seeing the same behavior. I'm using a dev container. Even if I change the preLaunchTask to an invalid option, VS Code doesn't notice or care. It just proceeds with the launch.