vscode-csharp icon indicating copy to clipboard operation
vscode-csharp copied to clipboard

Solution Build/Clean/Rebuild on Solutions open from Solution filters runs on the original solution

Open marcopelegrini opened this issue 7 months ago • 6 comments

Type: Bug

Issue Description

Solution Build/Clean/Rebuild on Solutions open from Solution filters runs on the original solution (sln file) instead of the slnf file

Steps to Reproduce

dotnet new sln -n MySolution
dotnet new console -n MyApp
dotnet sln MySolution.sln add MyApp/MyApp.csproj
dotnet new classlib -n MyLib
dotnet sln MySolution.sln add MyLib/MyLib.csproj
slnf-gen MySolution.sln --exclude '**/MyLib*'

Open the MySolution.slnf Build

Expected Behavior

Build runs on the MySolution.slnf

Actual Behavior

Build runs on MySolution.sln

Logs


dotnet build /Users/marco/Dev/test-solution/MySolution.sln --no-incremental /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary /p:Configuration=Debug /p:Platform="Any CPU" 
C# extension build result service is available.
  Determining projects to restore...
  All projects are up-to-date for restore.
  MyLib -> /Users/marco/Dev/test-solution/MyLib/bin/Debug/net9.0/MyLib.dll
  MyApp -> /Users/marco/Dev/test-solution/MyApp/bin/Debug/net9.0/MyApp.dll
 *  Terminal will be reused by tasks, press any key to close it. 

C# log

Activating task providers dotnet

C# LSP Trace Logs

non

Environment information

VSCode version: 1.101.1 C# Extension: 2.80.16 Using OmniSharp: false

Dotnet Information .NET SDK: Version: 9.0.300 Commit: 15606fe0a8 Workload version: 9.0.300-manifests.c678e91b MSBuild version: 17.14.5+edd3bbf37

Runtime Environment: OS Name: Mac OS X OS Version: 15.5 OS Platform: Darwin RID: osx-arm64 Base Path: /usr/local/share/dotnet/sdk/9.0.300/

.NET workloads installed: There are no installed workloads to display. Configured to use loose manifests when installing new manifests.

Host: Version: 9.0.5 Architecture: arm64 Commit: e36e4d1a8f

.NET SDKs installed: 6.0.427 [/usr/local/share/dotnet/sdk] 8.0.407 [/usr/local/share/dotnet/sdk] 9.0.300 [/usr/local/share/dotnet/sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 6.0.35 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.14 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.18 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 8.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 8.0.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 8.0.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 8.0.11 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 8.0.14 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 9.0.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.35 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.14 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.18 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 8.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 8.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 8.0.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 8.0.11 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 8.0.14 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 9.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found: x64 [/usr/local/share/dotnet/x64] registered at [/etc/dotnet/install_location_x64]

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
codespaces GitHub 1.17.3 github.codespaces-1.17.3
csdevkit ms-dotnettools 1.20.35 ms-dotnettools.csdevkit-1.20.35-darwin-arm64
csharp ms-dotnettools 2.80.16 ms-dotnettools.csharp-2.80.16-darwin-arm64
duplicate-finder tlevesque2 0.0.6 tlevesque2.duplicate-finder-0.0.6
EditorConfig EditorConfig 0.17.4 editorconfig.editorconfig-0.17.4
gitignore codezombiech 0.10.0 codezombiech.gitignore-0.10.0
hammerspoon virgilsisoe 0.5.2 virgilsisoe.hammerspoon-0.5.2
html-preview-vscode george-alisson 0.2.5 george-alisson.html-preview-vscode-0.2.5
identical-sublime-monokai-csharp-theme-colorizer maximetinu 1.2.3 maximetinu.identical-sublime-monokai-csharp-theme-colorizer-1.2.3
lua sumneko 3.14.0 sumneko.lua-3.14.0-darwin-arm64
opa tsandall 0.19.0 tsandall.opa-0.19.0
prettier-vscode esbenp 11.0.0 esbenp.prettier-vscode-11.0.0
rainbow-csv mechatroner 3.19.0 mechatroner.rainbow-csv-3.19.0
sarif-viewer MS-SarifVSCode 3.4.5 ms-sarifvscode.sarif-viewer-3.4.5
shell-format foxundermoon 7.2.5 foxundermoon.shell-format-7.2.5
supermaven Supermaven 1.1.12 supermaven.supermaven-1.1.12-darwin-arm64
text-power-tools qcz 1.51.0 qcz.text-power-tools-1.51.0
unique-lines bibhasdn 1.0.0 bibhasdn.unique-lines-1.0.0
vscode-azurefunctions ms-azuretools 1.17.3 ms-azuretools.vscode-azurefunctions-1.17.3
vscode-azureresourcegroups ms-azuretools 0.10.13 ms-azuretools.vscode-azureresourcegroups-0.10.13
vscode-dotnet-runtime ms-dotnettools 2.3.5 ms-dotnettools.vscode-dotnet-runtime-2.3.5
vscode-eslint dbaeumer 3.0.10 dbaeumer.vscode-eslint-3.0.10
vscode-html-css ecmel 2.0.13 ecmel.vscode-html-css-2.0.13
vscode-kubernetes-tools ms-kubernetes-tools 1.3.24 ms-kubernetes-tools.vscode-kubernetes-tools-1.3.24
vscode-markdownlint DavidAnson 0.60.0 davidanson.vscode-markdownlint-0.60.0
vscode-mocha-test-runner cstechnologies 0.3.3 cstechnologies.vscode-mocha-test-runner-0.3.3
vscode-regolint plex 0.2.0 plex.vscode-regolint-0.2.0
vscode-yaml redhat 1.18.0 redhat.vscode-yaml-1.18.0
vscodeintellicode-csharp ms-dotnettools 2.2.3 ms-dotnettools.vscodeintellicode-csharp-2.2.3-darwin-arm64
vulnerability-extension devprod 1.2025.619002 devprod.vulnerability-extension-1.2025.619002-darwin-arm64
xml DotJoshJohnson 2.5.1 dotjoshjohnson.xml-2.5.1

Extension version: 2.80.16 VS Code version: Code 1.101.1 (18e3a1ec544e6907be1e944a94c496e302073435, 2025-06-18T13:35:12.605Z) OS version: Darwin arm64 24.5.0 Modes:

System Info
Item Value
CPUs Apple M2 Pro (12 x 2400)
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: enabled_on
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) 5, 8, 12
Memory (System) 32.00GB (0.14GB free)
Process Argv
Screen Reader no
VM 0%

marcopelegrini avatar Jun 20 '25 22:06 marcopelegrini

Build is handled by the CDK extension when installed. Moving to https://github.com/microsoft/vscode-dotnettools/issues/2095

JoeRobich avatar Jun 22 '25 22:06 JoeRobich

@JoeRobich you're correct in a sense that CDK also has the issue. But C# has the same problem

See below where I open a folder with a solution and filter

  1. No CDK installed
  2. C# picks the solution
    • ideally it should ask which file to open - .sln or .slnf - there might be cases with more than one filter as well or more than one solution
  3. I've ran the command to select the slnf, C# confirms in the logs
  4. Nothing changes in the solution explorer
  5. Restore/Build all are ran in the solution file, not the filter.

https://github.com/user-attachments/assets/5541cd9b-4da4-4d0b-8e18-8098a05f8b6d

marcopelegrini avatar Jun 25 '25 03:06 marcopelegrini

Currently SLNX is only supported in CDK. There is the open feature request for support in the C# extension - https://github.com/dotnet/vscode-csharp/issues/7048

Image

JoeRobich avatar Jun 25 '25 04:06 JoeRobich

Sorry, I reread and see you mention slnf not slnx.

So for C# standalone you are right that the solution filename is written into the tasks.json. Let me reopen this issue to track a C# fix.

JoeRobich avatar Jun 25 '25 04:06 JoeRobich

OK so a little more testing of this scenario. It seems that we may not be re-requesting the ProjectDebugConfiguration when the .NET: Open solution command is used to choose a different solution.

In my folder I have a .sln and a .slnf.

  1. On first open of the folder the C# extension will select the .sln file.
  2. Generate build assets and the .sln filename is written into the tasks.json.
  3. Delete the .vscode folder.
  4. Execute the .NET: Open solution command and choose the slnf file.
  5. Generate build assets and still the .sln filename is written into the tasks.json.
  6. Delete the .vscode folder.
  7. Open settings
  8. Find dotnet.defaultSolution, choose the Workspace tab, and set the value to the .slnf filename
  9. Close VS Code and Restart
  10. On reopen the C# extension will use the defaultSolution to select the .slnf file.
  11. Generate build assets and the .slnf filename is written into the tasks.json.

JoeRobich avatar Jun 25 '25 04:06 JoeRobich

Ah, ok. It does re-request ProjectDebugConfiguration. The Roslyn project system is reusing the already loaded project information when switching from the .sln to the .slnf. Meaning the solution path associated with that project is not being updated.

JoeRobich avatar Jun 25 '25 05:06 JoeRobich