microsoft / microsoft/vscode-dotnettools

[BUG] C# Dev Tools VS Code extension does not detect C# project when workspace is a .code-workspace file

Open
#2,020 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area-solution bug
Dominant language
No language data
Stars
321
Forks
54
Avg merge
2d 19h
Merged PRs (30d)
2

Description

Describe the Issue

When opening a plain folder workspace in VS Code, the extension kicks in and sees my C# project. A .sln is generated, IntelliSense works, and I can successfully debug the code.

When I open a .code-workspace file, things no longer work. No solution is created and it is not possible to start a debug session.

Steps To Reproduce

Open a CMD prompt and type:

  1. mkdir wstest ; cd wstest
  2. mkdir development ; cd development
  3. open a text editor and create a development.code-workspace file containing:
{
  "folders": [
    { "path": "." },
    { "path": "../web-server-cs" },
  ]
}
  1. cd ..
  2. mkdir web-server-cs
  3. cd web-server-cs
  4. dotnet new webapi -n MyWebApi
  5. cd ..\development
  6. code development.code-workspace

VS Code will be launched. Click the Program.cs file to force the C# extension to be installed. Reload VS Code.

Result: the ASP.NET project will not be seen by the extension. No Solution will show up in the status bar. The SOLUTION EXPLORER pane does show up on the left side, but no solution appears inside, just the Open Solution blue button.

Testing further, following these steps:

  1. Close VS Code
  2. cd ..\web-server-cs
  3. dotnet new sln
  4. dotnet sln add .\MyWebApi\
  5. cd ....\development
  6. code development.code-workspace

This time, the SOLUTION EXPLORER pane does see the project, and things work fine.

Expected Behavior

I expect that the C# project should be detected, IntelliSense should work and launching a debugging session should be possible, even if no solution file is manually created. I tried adding the preview "solution-less" option in the settings.json, but it didn't work.

Environment Information
  • Windows 11 24H2
  • .NET 9.0 installed through Visual Studio Community 2022, with Desktop .NET components selected. All latest versions installed using Visual Studio Installer. dotnet --list-sdks shows I have SDK version 9.0.300 installed, and no previous version installed.
  • VS Code 1.100.1
  • C# Dev Kit 1.19.63

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue using development.code-workspace and the folder/project layout in the steps, then compare project discovery with a plain folder workspace. The issue names no implementation files or tests, so trace the extension's project-discovery path first; done means the project is detected without a manually created solution and IntelliSense and debugging work.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, vscode
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.