microsoft / vscode-dotnettools

This is a feedback repository to capture issues logged for the C# Dev Kit and related extensions from Visual Studio Code
Other
231 stars 13 forks source link

[BUG] Run button does not start up correct project #635

Closed jtsom closed 1 year ago

jtsom commented 1 year ago

Type: Bug

Issue Description

In a multi-project solution, if the currently active file in the editor is NOT in the "start up" project (Web app, web api, etc.), clicking the Run button in the top right of the window:

image

does not start up the project. An error is generated and shown in a popup notification:

'D:\source\repos\Company.Api\Company.Api.Services\Company.Api.Services.csproj' does not support debugging. No launchable target found.

NOTE: Hitting the F5 Key WILL launch the application properly, no matter what editor window is active. As will the Run button in the Run and Debug pane:

image

Steps to Reproduce

In a multi project application, ie. one project is a Web Api, another project is a Services project, another is a Data Access project, have as the current active editor a file in any project that is NOT the Web Api project. Click the Run button at the top.

Expected Behavior

Project launches the appropriate Web Api project (in this case)

Actual Behavior

Error notification as shown above

Logs

C# log

None

C# LSP Trace Logs

Extension vscode.bat does not contribute csharpExtensionLoadPaths Extension vscode.clojure does not contribute csharpExtensionLoadPaths Extension vscode.coffeescript does not contribute csharpExtensionLoadPaths Extension vscode.configuration-editing does not contribute csharpExtensionLoadPaths Extension vscode.cpp does not contribute csharpExtensionLoadPaths Extension vscode.csharp does not contribute csharpExtensionLoadPaths Extension vscode.css does not contribute csharpExtensionLoadPaths Extension vscode.css-language-features does not contribute csharpExtensionLoadPaths Extension vscode.dart does not contribute csharpExtensionLoadPaths Extension vscode.debug-auto-launch does not contribute csharpExtensionLoadPaths Extension vscode.debug-server-ready does not contribute csharpExtensionLoadPaths Extension vscode.diff does not contribute csharpExtensionLoadPaths Extension vscode.docker does not contribute csharpExtensionLoadPaths Extension vscode.emmet does not contribute csharpExtensionLoadPaths Extension vscode.extension-editing does not contribute csharpExtensionLoadPaths Extension vscode.fsharp does not contribute csharpExtensionLoadPaths Extension vscode.git does not contribute csharpExtensionLoadPaths Extension vscode.git-base does not contribute csharpExtensionLoadPaths Extension vscode.github does not contribute csharpExtensionLoadPaths Extension vscode.github-authentication does not contribute csharpExtensionLoadPaths Extension vscode.go does not contribute csharpExtensionLoadPaths Extension vscode.groovy does not contribute csharpExtensionLoadPaths Extension vscode.grunt does not contribute csharpExtensionLoadPaths Extension vscode.gulp does not contribute csharpExtensionLoadPaths Extension vscode.handlebars does not contribute csharpExtensionLoadPaths Extension vscode.hlsl does not contribute csharpExtensionLoadPaths Extension vscode.html does not contribute csharpExtensionLoadPaths Extension vscode.html-language-features does not contribute csharpExtensionLoadPaths Extension vscode.ini does not contribute csharpExtensionLoadPaths Extension vscode.ipynb does not contribute csharpExtensionLoadPaths Extension vscode.jake does not contribute csharpExtensionLoadPaths Extension vscode.java does not contribute csharpExtensionLoadPaths Extension vscode.javascript does not contribute csharpExtensionLoadPaths Extension vscode.json does not contribute csharpExtensionLoadPaths Extension vscode.json-language-features does not contribute csharpExtensionLoadPaths Extension vscode.julia does not contribute csharpExtensionLoadPaths Extension vscode.latex does not contribute csharpExtensionLoadPaths Extension vscode.less does not contribute csharpExtensionLoadPaths Extension vscode.log does not contribute csharpExtensionLoadPaths Extension vscode.lua does not contribute csharpExtensionLoadPaths Extension vscode.make does not contribute csharpExtensionLoadPaths Extension vscode.markdown does not contribute csharpExtensionLoadPaths Extension vscode.markdown-language-features does not contribute csharpExtensionLoadPaths Extension vscode.markdown-math does not contribute csharpExtensionLoadPaths Extension vscode.media-preview does not contribute csharpExtensionLoadPaths Extension vscode.merge-conflict does not contribute csharpExtensionLoadPaths Extension vscode.microsoft-authentication does not contribute csharpExtensionLoadPaths Extension ms-vscode-remote.remote-wsl-recommender does not contribute csharpExtensionLoadPaths Extension ms-vscode.js-debug does not contribute csharpExtensionLoadPaths Extension ms-vscode.js-debug-companion does not contribute csharpExtensionLoadPaths Extension ms-vscode.vscode-js-profile-table does not contribute csharpExtensionLoadPaths Extension vscode.builtin-notebook-renderers does not contribute csharpExtensionLoadPaths Extension vscode.npm does not contribute csharpExtensionLoadPaths Extension vscode.objective-c does not contribute csharpExtensionLoadPaths Extension vscode.perl does not contribute csharpExtensionLoadPaths Extension vscode.php does not contribute csharpExtensionLoadPaths Extension vscode.php-language-features does not contribute csharpExtensionLoadPaths Extension vscode.powershell does not contribute csharpExtensionLoadPaths Extension vscode.pug does not contribute csharpExtensionLoadPaths Extension vscode.python does not contribute csharpExtensionLoadPaths Extension vscode.r does not contribute csharpExtensionLoadPaths Extension vscode.razor does not contribute csharpExtensionLoadPaths Extension vscode.references-view does not contribute csharpExtensionLoadPaths Extension vscode.restructuredtext does not contribute csharpExtensionLoadPaths Extension vscode.ruby does not contribute csharpExtensionLoadPaths Extension vscode.rust does not contribute csharpExtensionLoadPaths Extension vscode.scss does not contribute csharpExtensionLoadPaths Extension vscode.search-result does not contribute csharpExtensionLoadPaths Extension vscode.shaderlab does not contribute csharpExtensionLoadPaths Extension vscode.shellscript does not contribute csharpExtensionLoadPaths Extension vscode.simple-browser does not contribute csharpExtensionLoadPaths Extension vscode.sql does not contribute csharpExtensionLoadPaths Extension vscode.swift does not contribute csharpExtensionLoadPaths Extension vscode.theme-abyss does not contribute csharpExtensionLoadPaths Extension vscode.theme-defaults does not contribute csharpExtensionLoadPaths Extension vscode.theme-kimbie-dark does not contribute csharpExtensionLoadPaths Extension vscode.theme-monokai does not contribute csharpExtensionLoadPaths Extension vscode.theme-monokai-dimmed does not contribute csharpExtensionLoadPaths Extension vscode.theme-quietlight does not contribute csharpExtensionLoadPaths Extension vscode.theme-red does not contribute csharpExtensionLoadPaths Extension vscode.vscode-theme-seti does not contribute csharpExtensionLoadPaths Extension vscode.theme-solarized-dark does not contribute csharpExtensionLoadPaths Extension vscode.theme-solarized-light does not contribute csharpExtensionLoadPaths Extension vscode.theme-tomorrow-night-blue does not contribute csharpExtensionLoadPaths Extension vscode.tunnel-forwarding does not contribute csharpExtensionLoadPaths Extension vscode.typescript does not contribute csharpExtensionLoadPaths Extension vscode.typescript-language-features does not contribute csharpExtensionLoadPaths Extension vscode.vb does not contribute csharpExtensionLoadPaths Extension vscode.xml does not contribute csharpExtensionLoadPaths Extension vscode.yaml does not contribute csharpExtensionLoadPaths Extension adamhartford.vscode-base64 does not contribute csharpExtensionLoadPaths Extension albert.TabOut does not contribute csharpExtensionLoadPaths Extension dqisme.sync-scroll does not contribute csharpExtensionLoadPaths Extension fabianlauer.vs-code-xml-format does not contribute csharpExtensionLoadPaths Extension kreativ-software.csharpextensions does not contribute csharpExtensionLoadPaths Extension mechatroner.rainbow-csv does not contribute csharpExtensionLoadPaths Extension mhutchie.git-graph does not contribute csharpExtensionLoadPaths Extension mitchdenny.ecdc does not contribute csharpExtensionLoadPaths Extension ms-azuretools.vscode-azureappservice does not contribute csharpExtensionLoadPaths Extension ms-azuretools.vscode-azurefunctions does not contribute csharpExtensionLoadPaths Extension ms-azuretools.vscode-azureresourcegroups does not contribute csharpExtensionLoadPaths Extension ms-azuretools.vscode-azurestorage does not contribute csharpExtensionLoadPaths Extension ms-azuretools.vscode-cosmosdb does not contribute csharpExtensionLoadPaths Extension ms-dotnettools.csdevkit does not contribute csharpExtensionLoadPaths Extension ms-dotnettools.csharp does not contribute csharpExtensionLoadPaths Extension ms-dotnettools.vscode-dotnet-runtime does not contribute csharpExtensionLoadPaths Extension ms-dotnettools.vscodeintellicode-csharp does not contribute csharpExtensionLoadPaths Extension ms-vscode.azure-account does not contribute csharpExtensionLoadPaths Extension ms-vscode.hexeditor does not contribute csharpExtensionLoadPaths Extension ms-vscode.live-server does not contribute csharpExtensionLoadPaths Extension PKief.material-icon-theme does not contribute csharpExtensionLoadPaths Extension qufiwefefwoyn.kanagawa does not contribute csharpExtensionLoadPaths Extension quicktype.quicktype does not contribute csharpExtensionLoadPaths Extension rangav.vscode-thunder-client does not contribute csharpExtensionLoadPaths Extension RobHolme.hl7tools does not contribute csharpExtensionLoadPaths Extension sdras.night-owl does not contribute csharpExtensionLoadPaths Extension tintoy.msbuild-project-tools does not contribute csharpExtensionLoadPaths Extension VisualStudioExptTeam.vscodeintellicode does not contribute csharpExtensionLoadPaths Extension yokawasa.jwt-debugger does not contribute csharpExtensionLoadPaths

Environment information

VSCode version: 1.84.0-insider C# Extension: 2.6.24 Using OmniSharp: false

Dotnet Information .NET SDK: Version: 8.0.100-rc.2.23502.2 Commit: 0abacfc2b6 Runtime Environment: OS Name: Windows OS Version: 10.0.22621 OS Platform: Windows RID: win-x64 Base Path: C:\Program Files\dotnet\sdk\8.0.100-rc.2.23502.2\ .NET workloads installed: There are no installed workloads to display. Host: Version: 8.0.0-rc.2.23479.6 Architecture: x64 Commit: 0b25e38ad3 .NET SDKs installed: 3.1.426 [C:\Program Files\dotnet\sdk] 5.0.408 [C:\Program Files\dotnet\sdk] 6.0.123 [C:\Program Files\dotnet\sdk] 6.0.318 [C:\Program Files\dotnet\sdk] 6.0.415 [C:\Program Files\dotnet\sdk] 7.0.112 [C:\Program Files\dotnet\sdk] 7.0.203 [C:\Program Files\dotnet\sdk] 7.0.309 [C:\Program Files\dotnet\sdk] 7.0.402 [C:\Program Files\dotnet\sdk] 8.0.100-rc.2.23502.2 [C:\Program Files\dotnet\sdk] .NET runtimes installed: Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 8.0.0-rc.2.23480.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.23 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 8.0.0-rc.2.23479.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.23 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 8.0.0-rc.2.23479.10 [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: 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| |---|---|---|---| |azure-account|ms-vscode|0.11.6|ms-vscode.azure-account-0.11.6| |csdevkit|ms-dotnettools|0.6.3|ms-dotnettools.csdevkit-0.6.3-win32-x64| |csharp|ms-dotnettools|2.6.24|ms-dotnettools.csharp-2.6.24-win32-x64| |csharpextensions|kreativ-software|1.7.3|kreativ-software.csharpextensions-1.7.3| |ecdc|mitchdenny|1.8.0|mitchdenny.ecdc-1.8.0| |git-graph|mhutchie|1.30.0|mhutchie.git-graph-1.30.0| |hexeditor|ms-vscode|1.9.12|ms-vscode.hexeditor-1.9.12| |hl7tools|RobHolme|2.0.4|robholme.hl7tools-2.0.4| |jwt-debugger|yokawasa|0.4.2|yokawasa.jwt-debugger-0.4.2| |kanagawa|qufiwefefwoyn|1.5.1|qufiwefefwoyn.kanagawa-1.5.1| |live-server|ms-vscode|0.4.11|ms-vscode.live-server-0.4.11| |material-icon-theme|PKief|4.31.0|pkief.material-icon-theme-4.31.0| |msbuild-project-tools|tintoy|0.4.9|tintoy.msbuild-project-tools-0.4.9| |night-owl|sdras|2.0.1|sdras.night-owl-2.0.1| |quicktype|quicktype|12.0.46|quicktype.quicktype-12.0.46| |rainbow-csv|mechatroner|3.7.1|mechatroner.rainbow-csv-3.7.1| |sync-scroll|dqisme|1.3.1|dqisme.sync-scroll-1.3.1| |TabOut|albert|0.2.2|albert.tabout-0.2.2| |vs-code-xml-format|fabianlauer|0.1.5|fabianlauer.vs-code-xml-format-0.1.5| |vscode-azureappservice|ms-azuretools|0.25.1|ms-azuretools.vscode-azureappservice-0.25.1| |vscode-azurefunctions|ms-azuretools|1.13.1|ms-azuretools.vscode-azurefunctions-1.13.1| |vscode-azureresourcegroups|ms-azuretools|0.7.5|ms-azuretools.vscode-azureresourcegroups-0.7.5| |vscode-azurestorage|ms-azuretools|0.15.3|ms-azuretools.vscode-azurestorage-0.15.3| |vscode-base64|adamhartford|0.1.0|adamhartford.vscode-base64-0.1.0| |vscode-cosmosdb|ms-azuretools|0.20.0|ms-azuretools.vscode-cosmosdb-0.20.0| |vscode-dotnet-runtime|ms-dotnettools|1.8.1|ms-dotnettools.vscode-dotnet-runtime-1.8.1| |vscode-thunder-client|rangav|2.13.5|rangav.vscode-thunder-client-2.13.5| |vscodeintellicode|VisualStudioExptTeam|1.2.30|visualstudioexptteam.vscodeintellicode-1.2.30| |vscodeintellicode-csharp|ms-dotnettools|0.1.26|ms-dotnettools.vscodeintellicode-csharp-0.1.26-win32-x64|;

Extension version: 0.6.3 VS Code version: Code - Insiders 1.84.0-insider (58bdf2c7c40be6f4494ae35a09528708832cf357, 2023-10-18T05:50:15.982Z) OS version: Windows_NT x64 10.0.22621 Modes:

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i5-8500 CPU @ 3.00GHz (6 x 3000)| |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
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|undefined| |Memory (System)|31.78GB (11.14GB free)| |Process Argv|--crash-reporter-id 362817d9-b661-4b35-92b7-fe18e5872851| |Screen Reader|no| |VM|0%|
A/B Experiments ``` vsliv695:30137379 vsins829:30139715 vsliv368cf:30146710 vsreu685:30147344 python383cf:30185419 vspor879:30202332 vspor708:30202333 vspor363:30204092 vswsl492cf:30256198 vslsvsres303:30308271 pythontb:30258533 pythonptprofiler:30281269 vshan820:30294714 vscod805cf:30301675 bridge0708:30335490 bridge0723:30353136 vsaa593:30376534 pythonvs932:30404738 py29gd2263:30784851 vsclangdf:30492506 c4g48928:30535728 dsvsc012cf:30540253 pynewext54:30618038 vscrp:30624060 a9j8j154:30646983 showlangstatbar:30737417 ecj1e332:30687743 pythonfmttext:30716741 fixshowwlkth:30771523 showindicator:30805243 pythongtdpath:30726887 i26e3531:30792625 welcomedialog:30812478 pythonnosmt12:30779711 pythonidxpt:30768918 pythonnoceb:30776497 copilotsettingt:30808721 dsvsc013:30777762 dsvsc014:30777825 diffeditorv2:30786206 pythonmpsinfo:30859869 dsvsc015:30821418 pythontestfixt:30859590 pythonmypyd1:30859725 pythoncet0:30859736 pythontbext0:30864172 ```
WardenGnaw commented 1 year ago

The Debug Button in the file toobar will try to find the project that compiles this file. image

It will be different than what F5 (Start Debugging) will do because that will launch the current selected debug configuration.

For example, if you have a Solution with two console projects (Project A and Project B), if you have a Debug Configuration for Project A, but have the cs file open for Project B.

F5 will debug Project A but the debug file button will launch Project B.

Other Extensions such as Python will try to execute the current file, as .NET is project system based, we will have to assoicate the file with the project. If the file has multiple associations it should prompt which project you want to launch.

jtsom commented 1 year ago

The C# SDK needs an option, similar to Visual Studio, where the user can assign the default startup project "Set As Startup Project", so when clicking that Run button, the correct project will be launched (ie. the Web API, or Web UI project, as opposed to some library project in the solution.)

WardenGnaw commented 1 year ago

I will be closing this issue as a dupliate of https://github.com/microsoft/vscode-dotnettools/issues/72 as it seems you are looking for a Launch Startup Project experience.

Feel free to re-open if I am incorrect.

jtsom commented 1 year ago

@WardenGnaw It's not so much asking specifically for the Launch Startup Project, but that the current button / functionality does not work.

If the active editor window is NOT the project that is to be launched, there will be an ERROR. It took me a while to figure out why I was getting the error. It should do the SAME thing as the current F5 / Run button in the Debug tab - not throw an error.

VProfirov commented 7 months ago

Dear @WardenGnaw,

About your mention of

> The Debug Button in the file toobar will try to find the project that compiles this file.

Respectfully, how can I make the functionality of this button into a shortcut such that it works?

FYI: Currently I have assigned a shortcut to this functionality and the shortcut is displayed while hovering the button but it throws an error when the shortcut is used. However, when the corresponding button is pressed everything works as intended. (There is no "When" clause defined in the shortcut.) ERROR: "No C# project is currently loaded. Please create a C# project in order to debug." "Source: C# Dev Kit"

P.S. I did read #318 but the information shared there does not contribute to a solution to the context above mentioned.