Regression: automatic solution discovery misses .sln/.slnx files after #9286
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 84/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- csharp, typescript, vscode
- Ambito
- devtools
Direzione di ricerca
Inizia in src/lsptoolshost/server/roslynLanguageServer.ts, in openDefaultSolutionOrProjects() e nella ricerca di solutionUris intorno alla riga 565. Riproduci i casi di una singola soluzione e di fallback, quindi aggiungi la copertura di regressione per .sln, .slnx e più soluzioni; il lavoro è completato quando entrambe le estensioni vengono individuate e i progetti al di fuori della soluzione selezionata non vengono caricati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Issue description
Automatic solution discovery in the standalone C# extension misses a workspace's single .sln file. The extension then falls back to loading every .csproj, including projects deliberately excluded from the solution. In my workspace, this causes a project-loading error and a "There were problems loading project" notification for an excluded project.
The regression was introduced by PR #9286: .slnx support, merged on May 22, 2026. The exact change is in roslynLanguageServer.ts, line 565 of merge commit d8833483c84164fe0bfb25695bb1ed8bdd395463:
- const solutionUris = await vscode.workspace.findFiles('**/*.sln', '**/node_modules/**', 2);
+ const solutionUris = await vscode.workspace.findFiles('**/*.slnx?', '**/node_modules/**', 2);
In VS Code glob syntax, ? matches one character; it does not make the preceding x optional. Therefore **/*.slnx? matches neither .sln nor .slnx.
Environment data
- OS: Arch Linux, x86_64
- VS Code: 1.139.0
- C# extension:
ms-dotnettools.csharp2.160.4 - Mode: standalone C# extension; C# Dev Kit is not installed
- Installed .NET SDKs: 9.0.318 and 10.0.401
dotnet.defaultSolution: unset- Workspace: one
.slnfile undersrc/, containing 12 projects; one additional.csprojexists outside the solution's project list
C# logs
Relevant excerpts from the affected workspace, with project names and paths anonymized:
2026-09-24 13:09:54.782 [info] Activating C# standalone...
2026-09-24 13:09:57.655 [error] [project/open] [LanguageServerProjectSystem] Error while loading <workspace>/src/ExcludedApp/ExcludedApp.csproj: Project '../Core/Core.csproj' targets 'net10.0'. It cannot be referenced by a project that targets '.NETCoreApp,Version=v6.0'.
2026-09-24 13:09:58.460 [info] [project/open] [LanguageServerProjectSystem] Completed (re)load of 13 project(s) in 00:00:02.8283748
The framework mismatch belongs to a project that is not in the solution. The regression is that automatic discovery loads it anyway.
Steps to reproduce
- Use the C# extension in standalone mode, with C# Dev Kit absent or disabled and
dotnet.defaultSolutionunset. - Open a folder containing exactly one solution, for example
src/App.sln. - Have at least one
.csprojunder that folder which is deliberately not included inApp.sln. Keep files from that excluded project closed. - Activate the C# extension by opening a C# file from an included project.
- Inspect the C# output: the extension uses
project/opento load all discovered projects, including the excluded project, instead of opening the solution. If the excluded project has an incompatible project reference, a project-loading error notification is shown.
Expected behavior
The single solution is discovered and opened automatically. Only its projects and their required references are loaded. Discovery should recognize both .sln and .slnx files.
Actual behavior
The glob finds no solutions. openDefaultSolutionOrProjects() takes its zero-solutions branch and enumerates **/*.csproj, ignoring the intended solution membership.
I verified the installed 2.160.4 extension contains this pattern and that the workspace has only one solution. The same pattern is also present in the upstream source inspected during diagnosis.
Suggested fix
Use a glob that explicitly matches the two extensions:
const solutionUris = await vscode.workspace.findFiles('**/*.{sln,slnx}', '**/node_modules/**', 2);
Regression coverage should check automatic discovery with one .sln, one .slnx, and multiple solutions, and ensure projects outside the selected solution are not loaded by the fallback path.
Workaround
Setting an explicit solution path should bypass the broken discovery branch:
{
"dotnet.defaultSolution": "src/App.sln"
}
The workaround follows from the loading code; it has not yet been applied or verified in the affected VS Code session.
- Lingua principale
- TypeScript
- Stelle
- 3.1k
- Fork
- 736
- Merge medio
- 21h 46m
- PR unite (30g)
- 38
Preparare l'ambiente
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di dotnet/vscode-csharp
-
Infrastructure Test
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
dotnet/vscode-csharp#9791 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
untriaged
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
dotnet/vscode-csharp#9816 ·
I maintainer di solito rispondono entro 1 giorno
-
untriaged
Difficoltà 4/5 3-5 giorni Idoneità per principianti 15/100
dotnet/vscode-csharp#9814 ·
I maintainer di solito rispondono entro 1 giorno
-
C# crashApertaC#DK untriaged
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
dotnet/vscode-csharp#9807 ·
I maintainer di solito rispondono entro 1 giorno
-
Editor-Formatting Resolved-Configuration Issue
Difficoltà 3/5 1-2 giorni Idoneità per principianti 65/100
dotnet/vscode-csharp#9804 · 6 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di dotnet/vscode-csharp
Issue simili
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
supabase/agent-skills#611 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 68/100
polka-codes/test#345 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 92/100
GoogleChromeLabs/project-sesame#217 ·
I maintainer di solito rispondono entro 12 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
solana-foundation/solana-com#2202 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100