Skip to content

VS Code C# Extension creates bin/obj folders in subfolders when adding new .cs files #8304

@siudzinski

Description

@siudzinski

Type: Bug

Issue Description

When adding a new .cs file in a C# project using VS Code, unwanted bin and obj folders are created inside the folder where the file is added (e.g., inside a namespace folder), regardless of where the .csproj file is located. This does not happen when adding files using JetBrains Rider or Visual Studio.

Steps to Reproduce

Open a C# solution in VS Code.
Navigate to a subfolder.
Add a new .cs file (e.g., Test.cs).
Observe that bin and obj folders are created in the same folder as the new file.

Expected Behavior

bin and obj folders should only be created at the project root (next to the .csproj file), not inside subfolders or namespace folders.

Actual Behavior

Every time a new .cs file is added in a subfolder, bin and obj folders are created in that subfolder, cluttering the project structure.

Logs

Environment information

VSCode version: 1.100.2
C# Extension: 2.78.15
Using OmniSharp: false

Dotnet Information

Host:
Version: 9.0.5
Architecture: x64
Commit: e36e4d1a8f
RID: win-x64

.NET SDKs installed:
No SDKs were found.

.NET runtimes installed:
Microsoft.AspNetCore.App 9.0.5 [C:\Users\tomek\AppData\Roaming\Code\User\globalStorage\ms-dotnettools.vscode-dotnet-runtime.dotnet\9.0.5x64aspnetcore\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 9.0.5 [C:\Users\tomek\AppData\Roaming\Code\User\globalStorage\ms-dotnettools.vscode-dotnet-runtime.dotnet\9.0.5x64aspnetcore\shared\Microsoft.NETCore.App]

Other architectures found:
None

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
blazor-snippet-pack adrianwilczynski 2.6.1 adrianwilczynski.blazor-snippet-pack-2.6.1
code-coverage markis 1.12.0 markis.code-coverage-1.12.0
copilot GitHub 1.322.0 github.copilot-1.322.0
copilot-chat GitHub 0.27.1 github.copilot-chat-0.27.1
csdevkit ms-dotnettools 1.19.63 ms-dotnettools.csdevkit-1.19.63-win32-x64
csharp ms-dotnettools 2.78.15 ms-dotnettools.csharp-2.78.15-win32-x64
docker docker 0.6.0 docker.docker-0.6.0-win32-x64
EditorConfig EditorConfig 0.17.2 editorconfig.editorconfig-0.17.2
material-theme zhuangtongfa 3.19.0 zhuangtongfa.material-theme-3.19.0
prettier-vscode esbenp 11.0.0 esbenp.prettier-vscode-11.0.0
remote-containers ms-vscode-remote 0.413.0 ms-vscode-remote.remote-containers-0.413.0
volar Vue 2.2.10 vue.volar-2.2.10
vscode-docker ms-azuretools 1.29.6 ms-azuretools.vscode-docker-1.29.6
vscode-dotnet-runtime ms-dotnettools 2.3.3 ms-dotnettools.vscode-dotnet-runtime-2.3.3
vscode-eslint dbaeumer 3.0.10 dbaeumer.vscode-eslint-3.0.10
vscode-icons vscode-icons-team 12.13.0 vscode-icons-team.vscode-icons-12.13.0
vscode-todo-highlight wayou 1.0.5 wayou.vscode-todo-highlight-1.0.5

Extension version: 2.78.15
VS Code version: Code 1.100.2 (848b80aeb52026648a8ff9f7c45a9b0a80641e2e, 2025-05-14T21:47:40.416Z)
OS version: Windows_NT x64 10.0.26100
Modes:

System Info
Item Value
CPUs Intel(R) Core(TM) i5-10400F CPU @ 2.90GHz (12 x 2904)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
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
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 15.92GB (4.46GB free)
Process Argv --crash-reporter-id 0b7027df-d80f-494a-bc7b-6011c0991cd8
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492:30256859
vscod805cf:30301675
binariesv615:30325510
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
2e7ec940:31000449
pythontbext0:30879054
cppperfnew:31000557
dwnewjupytercf:31046870
pythonrstrctxt:31112756
nativeloc2:31192216
5fd0e150:31155592
dwcopilot:31170013
6074i472:31201624
dwoutputs:31242946
customenabled:31248079
hdaa2157:31222309
copilot_t_ci:31222730
e5gg6876:31282496
pythoneinst12:31285622
bgtreat:31268568
4gafe986:31271826
c7cif404:31309971
pythonpulldiagcf:31298646
996jf627:31283433
pythonrdcb7cf:31303019
usemplatestapi:31297334
0aa6g176:31307128
7bj51361:31289155
747dc170:31275177
9hi5e907:31309499
pylancecolor:31309108
aj953862:31281341
generatesymbolt:31295002
convertfstringf:31295003
gendocf:31295004

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions