Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Language server fails to recognize new files added via relative path outside project root

Aperta
#9,360 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
csharp, typescript, vscode

Direzione di ricerca

Riproduci il problema con il workspace multi-root e il glob csproj riportati nel report, quindi esamina il percorso di caricamento del workspace/progetto di C# language-server e il log C# fornito. Verifica il comportamento quando viene creato e aperto un nuovo file .cs esterno. Il lavoro è completato quando il file viene tracciato dal progetto e le funzionalità del linguaggio funzionano senza riavviare VS Code.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

C#DK untriaged

Type: Bug

Issue Description

I have a workspace configured where a csproj file is stored in a different root than the actual source files. I then use a .code-workspace and <Compile Include=".\..\Scripts\**\*.cs" /> to make the source files visible to the language server. When I create a new source file, VSCode doesn't recognize it properly and I get the error "The active document is not part of the open workspace. Not all language features will be available." Interestingly enough, I have a similar problem when I open my solution in Visual Studio and create a new file. Restarting the entire IDE solves the issue but only until the next file is created.

Steps to Reproduce

I have my setup on Github.

  1. Create a multi-root workspace
{
    "folders": [
        {
            "name": "ScriptsDev",
            "path": "."
        },
        {
            "name": "Scripts",
            "path": "./../Scripts"
        }
    ]
}
  1. Write a csproj that includes external files using globbing
<Project Sdk="Microsoft.NET.Sdk">
    <ItemGroup>
        <Compile Include=".\..\Scripts\**\*.cs" />
    </ItemGroup>
</Project>
  1. Now try adding a new .cs file in Scripts. It will show up in VSCode but when you try editing it, the C# extension will show the aforementioned error message.

Expected Behavior

The language server should recognize the newly created file and import it into the project. I should then be able to use all language features without needing to restart VSCode.

Actual Behavior

When I open the new file, I cannot access my dependencies or my own types. Then, the C# extension shows a pop up with this error: The active document is not part of the open workspace. Not all language features will be available.

Logs

Extension version: 2.140.8
VS Code version: Code 1.121.0 (f6cfa2ea2403534de03f069bdf160d06451ed282, 2026-05-19T11:51:53+02:00)
OS version: Windows_NT x64 10.0.26100
Modes:

C# log
2026-05-29 20:32:34.070 [info] Locating .NET runtime version 10.0.5
2026-05-29 20:32:34.196 [info] Dotnet path: C:\Program Files\dotnet\dotnet.exe
2026-05-29 20:32:34.196 [info] Activating C# + C# Dev Kit...
2026-05-29 20:32:34.336 [info] info: Program[0]
2026-05-29 20:32:34.336 [info]       Server started with process ID 3712
2026-05-29 20:32:34.999 [info] [Program] Language server initialized
2026-05-29 20:32:35.000 [info] [Program] Monitoring client process 4984 for exit
2026-05-29 20:32:35.859 [info] [initialized] [Microsoft.CodeAnalysis.LanguageServer.FileBasedPrograms.FileBasedProgramsEntryPointDiscovery] Finished discovery in 'c:\Program Files\Epic Games\BatmanArkhamCity\BmGame\ScriptsDev' in 6 milliseconds
2026-05-29 20:32:38.071 [info] [serviceBroker/connect] [WorkspaceProjectFactoryService] Project C:\Program Files\Epic Games\BatmanArkhamCity\BmGame\ScriptsDev\ScriptsDev.csproj loaded by C# Dev Kit
2026-05-29 20:43:37.551 [warning] [textDocument/diagnostic] [LSP] Ignoring diagnostics request for untracked document: file:///c:/Program Files/Epic Games/BatmanArkhamCity/BmGame/Mods/CharacterSwappingScript/scripts/Patches/test.cs
2026-05-29 20:43:37.551 [warning] [textDocument/diagnostic] [LSP] Ignoring diagnostics request for untracked document: file:///c:/Program Files/Epic Games/BatmanArkhamCity/BmGame/Mods/CharacterSwappingScript/scripts/Patches/test.cs
2026-05-29 20:43:37.551 [warning] [textDocument/diagnostic] [LSP] Ignoring diagnostics request for untracked document: file:///c:/Program Files/Epic Games/BatmanArkhamCity/BmGame/Mods/CharacterSwappingScript/scripts/Patches/test.cs
2026-05-29 20:44:21.297 [info] Locating .NET runtime version 10.0.5
2026-05-29 20:44:21.499 [info] Dotnet path: C:\Program Files\dotnet\dotnet.exe
2026-05-29 20:44:21.499 [info] Activating C# + C# Dev Kit...
2026-05-29 20:44:21.668 [info] info: Program[0]
2026-05-29 20:44:21.668 [info]       Server started with process ID 15312
2026-05-29 20:44:22.227 [info] [Program] Language server initialized
2026-05-29 20:44:22.239 [info] [Program] Monitoring client process 12200 for exit
2026-05-29 20:44:22.641 [info] [initialized] [Microsoft.CodeAnalysis.LanguageServer.FileBasedPrograms.FileBasedProgramsEntryPointDiscovery] Finished discovery in 'c:\Program Files\Epic Games\BatmanArkhamCity\BmGame\ScriptsDev' in 6 milliseconds
2026-05-29 20:44:22.666 [info] [initialized] [Microsoft.CodeAnalysis.LanguageServer.FileBasedPrograms.FileBasedProgramsEntryPointDiscovery] Finished discovery in 'c:\Program Files\Epic Games\BatmanArkhamCity\BmGame\Scripts' in 2 milliseconds
2026-05-29 20:44:22.675 [info] [initialized] [Microsoft.CodeAnalysis.LanguageServer.FileBasedPrograms.FileBasedProgramsEntryPointDiscovery] Finished discovery in 'c:\Program Files\Epic Games\BatmanArkhamCity\BmGame\Mods' in 8 milliseconds
2026-05-29 20:44:24.798 [info] [serviceBroker/connect] [WorkspaceProjectFactoryService] Project C:\Program Files\Epic Games\BatmanArkhamCity\BmGame\ScriptsDev\ScriptsDev.csproj loaded by C# Dev Kit
2026-05-29 20:44:32.306 [info] [textDocument/diagnostic] [Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager] .NET BuildHost started from c:\Users\Jonkler\.vscode\extensions\ms-dotnettools.csharp-2.140.8-win32-x64\.roslyn\Microsoft.CodeAnalysis.LanguageServer.exe reloading to start from C:\Program Files\dotnet\dotnet.exe to match necessary SDK location.
2026-05-29 20:44:33.160 [warning] [textDocument/diagnostic] [LanguageServerProjectLoader] Project C:\Users\Jonkler\AppData\Local\Temp\roslyn-canonical-misc\c8f30402-aff3-4a4f-b03b-723166e14ed6\Canonical.csproj has unresolved dependencies
2026-05-29 20:44:33.189 [info] [textDocument/diagnostic] [LanguageServerProjectLoader] Successfully completed load of c:\Program Files\Epic Games\BatmanArkhamCity\BmGame\Scripts\Test.cs
2026-05-29 20:44:33.206 [info] [textDocument/diagnostic] [LanguageServerProjectLoader] Restoring Canonical.csproj: Running dotnet restore on C:\Users\Jonkler\AppData\Local\Temp\roslyn-canonical-misc\c8f30402-aff3-4a4f-b03b-723166e14ed6\Canonical.csproj
2026-05-29 20:44:33.206 [info] [textDocument/diagnostic] [Microsoft.CodeAnalysis.LanguageServer.DotnetCliHelper] Using dotnet executable configured on the PATH
2026-05-29 20:44:33.745 [info] [textDocument/diagnostic] [LanguageServerProjectLoader] Restoring Canonical.csproj:   Determining projects to restore...
2026-05-29 20:44:34.029 [info] [textDocument/diagnostic] [LanguageServerProjectLoader] Restoring Canonical.csproj:   Restored C:\Users\Jonkler\AppData\Local\Temp\roslyn-canonical-misc\c8f30402-aff3-4a4f-b03b-723166e14ed6\Canonical.csproj (in 69 ms).
2026-05-29 20:44:34.054 [info] [textDocument/diagnostic] [LanguageServerProjectLoader] Restore complete
2026-05-29 20:44:34.054 [info] [textDocument/diagnostic] [LanguageServerProjectLoader] Completed (re)load of all projects in 00:00:01.9633818
2026-05-29 20:44:34.551 [info] [workspace/didChangeWatchedFiles] [LanguageServerProjectLoader] Successfully completed load of c:\Program Files\Epic Games\BatmanArkhamCity\BmGame\Scripts\Test.cs
2026-05-29 20:44:34.551 [info] [workspace/didChangeWatchedFiles] [LanguageServerProjectLoader] Completed (re)load of all projects in 00:00:00.0060601

C# LSP Trace Logs log

Environment Information

VSCode version: 1.121.0
C# Extension: 2.140.8
Using OmniSharp: false

Dotnet Information .NET SDK: Version: 10.0.204 Commit: e7aa4b537d Workload version: 10.0.200-manifests.e0989437 MSBuild version: 18.3.3+e7aa4b537

Runtime Environment:
OS Name: Windows
OS Version: 10.0.26100
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\10.0.204\

.NET workloads installed:
There are no installed workloads to display.
Configured to use workload sets when installing new manifests.
No workload sets are installed. Run "dotnet workload restore" to install a workload set.

Host:
Version: 10.0.8
Architecture: x64
Commit: 94ea82652c

.NET SDKs installed:
10.0.204 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 10.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.27 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 10.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.27 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 10.0.8 [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:
DOTNET_CLI_TELEMETRY_OPTOUT [true]
DOTNET_CLI_UI_LANGUAGE [en-US]
DOTNET_MULTILEVEL_LOOKUP [0]

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
catppuccin-vsc Catppuccin 3.19.0 catppuccin.catppuccin-vsc-3.19.0
catppuccin-vsc-icons Catppuccin 1.26.0 catppuccin.catppuccin-vsc-icons-1.26.0
catppuccin-vsc-pack catppuccin 1.0.2 catppuccin.catppuccin-vsc-pack-1.0.2
clang-format xaver 1.9.0 xaver.clang-format-1.9.0
cmake-tools ms-vscode 1.23.52 ms-vscode.cmake-tools-1.23.52
cpp-devtools ms-vscode 0.5.13 ms-vscode.cpp-devtools-0.5.13
cpptools ms-vscode 1.32.2 ms-vscode.cpptools-1.32.2-win32-x64
cpptools-extension-pack ms-vscode 1.5.1 ms-vscode.cpptools-extension-pack-1.5.1
cpptools-themes ms-vscode 2.0.0 ms-vscode.cpptools-themes-2.0.0
csdevkit ms-dotnettools 3.20.199 ms-dotnettools.csdevkit-3.20.199-win32-x64
csharp ms-dotnettools 2.140.8 ms-dotnettools.csharp-2.140.8-win32-x64
csharpier-vscode csharpier 10.0.3 csharpier.csharpier-vscode-10.0.3
even-better-toml tamasfe 0.21.2 tamasfe.even-better-toml-0.21.2
intellij-idea-keybindings k--kato 1.7.7 k--kato.intellij-idea-keybindings-1.7.7
powershell ms-vscode 2025.4.0 ms-vscode.powershell-2025.4.0
uc EliotVU 0.8.4 eliotvu.uc-0.8.4
vscode-dotnet-runtime ms-dotnettools 3.0.2 ms-dotnettools.vscode-dotnet-runtime-3.0.2
C# Settings
Setting Value
preferCSharpExtension false
compilerDiagnosticScope openFiles
analyzerDiagnosticScope openFiles
enableXamlTools true
useServerGC true
System Info
Item Value
CPUs AMD Ryzen 7 3700X 8-Core Processor (16 x 3600)
GPU Status 2d_canvas: enabled
GPU0: VENDOR= 0x10de, DEVICE=0x2504 [NVIDIA GeForce RTX 3060], DRIVER_VENDOR=NVIDIA, DRIVER_VERSION=32.0.15.9186 ACTIVE
GPU1: VENDOR= 0x10de, DEVICE=0x2504 [NVIDIA GeForce RTX 3060], DRIVER_VERSION=32.0.15.9186
GPU2: VENDOR= 0x1414, DEVICE=0x008c [Microsoft Basic Render Driver], DRIVER_VERSION=10.0.26100.8328
Machine model name:
Machine model version:
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
trees_in_viz: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 15.93GB (9.40GB free)
Process Argv
Screen Reader no
VM 0%
Lingua principale
TypeScript
Stelle
3.1k
Fork
736
Merge medio
21h 21m
PR unite (30g)
42

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di dotnet/vscode-csharp

Tutte le issue di dotnet/vscode-csharp

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.