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
234 stars 13 forks source link

Unable to run c# code created with dotnet console new #789

Open Blad3sy opened 11 months ago

Blad3sy commented 11 months ago

Type: Bug

c# code that I have recently created is not running when I click the run button : I simply recieve ' Unable the find the project that contains {path} ' Source : C# Dev Kit

I have tried 3+ versions of the Dev Kit from Pre-release to 0.5.148. Error persists.

Extension version: 1.2.2 VS Code version: Code 1.84.2 (1a5daa3a0231a0fbba4f14db7ec463cf99d7768e, 2023-11-09T10:51:52.184Z) OS version: Windows_NT x64 10.0.19045 Modes:

System Info |Item|Value| |---|---| |CPUs|AMD Ryzen 5 3400G with Radeon Vega Graphics (8 x 3700)| |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)|15.95GB (7.70GB free)| |Process Argv|--crash-reporter-id f25a25e5-61d7-4790-9418-ab58d3bc7aed| |Screen Reader|no| |VM|0%|
A/B Experiments ``` vsliv368cf:30146710 vsreu685:30147344 python383:30185418 vspor879:30202332 vspor708:30202333 vspor363:30204092 vswsl492:30256859 vslsvsres303:30308271 vserr242cf:30382550 pythontb:30283811 vsjup518:30340749 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 vscorecescf:30445987 vscod805cf:30301675 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 vsaa593:30376534 pythonvs932:30410667 py29gd2263:30899288 vscaac:30438847 vsclangdc:30486549 c4g48928:30535728 dsvsc012:30540252 azure-dev_surveyone:30548225 3biah626:30602489 89544117:30613380 2i9eh265:30646982 showlangstatbar:30737416 fixshowwlkth:30771522 showindicator:30805244 pythongtdpath:30769146 i26e3531:30792625 welcomedialogc:30910334 pythonnosmt12:30797651 pythonidxpt:30866567 pythonnoceb:30805159 asynctok:30898717 dsvsc013:30795093 dsvsc014:30804076 dsvsc015:30845448 pythontestfixt:30902429 pyreplss1:30897532 pythonmypyd1:30879173 pythoncet0:30885854 2e7ec940:30885897 pythontbext0:30879054 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 aa_t_chat:30882232 ```
WardenGnaw commented 11 months ago

@Blad3sy I was not able to reproduce it with a new console project.

DebugNewConsole

Could you share the exact steps that caused you to run into this issue?

@tmeschter FYI as Unable to find the project that contains {path} comes from erroring from querying the project system for the project file with the given file. Are there any issues with certain file path characters?

Blad3sy commented 11 months ago

@WardenGnaw There were no exact steps - this just begun happening one day (specifically Tuesday 5th December 2023). Whenever I create a new project, this error message pops up.

image

Below is a full video of this bug starting with me reinstalling the c# Dev Kit.

https://github.com/microsoft/vscode-dotnettools/assets/71397567/7c1edf35-02e4-41dd-ad8e-4cd8ec879763

I am however, able to run projects with dotnet run, but I have no automatic error highlighting in files either.

timheuer commented 11 months ago

Weird @Blad3sy , here's my repro with your same scenario either (tried with somewhat mirror of your directory). In your profile name are there any special characters at all? What OS locale do you have?

https://github.com/microsoft/vscode-dotnettools/assets/4821/fd13850a-32f2-4e79-9129-f2d6e47997b9

Blad3sy commented 11 months ago

@timheuer The full directory this folder and therefore file is in is: B:\VSCODE Programs\test ( B:\VSCODE Programs\test\Program.cs) B: is a seperate HDD to my main SSD with Windows 10 (Version 22H2 OS Build 19045.3693) installed on it.

Is there any other OS information you need? (I don't really know exactly what to give when you say OS locale, sorry!)

timheuer commented 11 months ago

OS locale

Any language specific settings? Or US-english OS?

Blad3sy commented 11 months ago

UK-English, nothing apart from that.

WardenGnaw commented 11 months ago

@Blad3sy From the video, you are adding a new console project via command line, but I don't think adds the project to the solution.

If you expand the Solution Explorer pane, do you see your new console application project listed?

I believe if the project is not in the solution, the project-system can not associate a file to the correct project so it fails. You will either have to add the project to your solution or launch via project, instead of launching via file.

tmeschter commented 11 months ago

I believe if the project is not in the solution, the project-system can not associate a file to the correct project so it fails. You will either have to add the project to your solution or launch via project, instead of launching via file.

That is correct. If the project isn't part of the solution we can't map from files back to projects.

Blad3sy commented 11 months ago

@WardenGnaw Sorry it took me so long to respond,

It is correct that the projects created with dotnet new console are not present in the Solution Explorer (as below) image

Running the project with dotnet run does work... I assume this means the problem is that new projects aren't being added to the solution. Is this intentional? This was not happening before about two weeks ago. Is there any way to make the command automatically add the .csproj to the solution?

Thanks.

kvenkatrajan commented 10 months ago

Can you try adding the crpoj to the solution using the Add Existing Project in the context menu? Since the intial release, we do not support adding project reference to solution when creating project via command line automatically - Im not sure how it could have worked in the past.

kvenkatrajan commented 9 months ago

@webreidi - possibly a feature request for future?