I made a new project with "dotnet new" and VS Code already doesn't understand the project structure.
I did
dotnet new -n MyApp
, cd'd into the directory, and did dotnet build
and dotnet run
to make sure everything is working correctly. It builds and runs fine, as expected. Opening the folder in vs code, and it can't generate a launch.json
at all.
Here's a link to the code, does your VS Code know how to make a launchjson? https://github.com/MrZoraman/MyApp
I've let VS Code generate tons of launch.json
files and it usually figures out all the stuff on its own. I feel like I'm having a stroke here, why all of the sudden is VS Code only able to generate this?:
Thanks for any and all help!GitHub
GitHub - MrZoraman/MyApp
Contribute to MrZoraman/MyApp development by creating an account on GitHub.
25 Replies
I also added an
extensions.txt
so you can see what extensions I have installed.You don't need a launch.json, why are you trying to generate one?
I want to press f5 to debug my project from anywhere instead of needing the file with my main method in it open
You... don't need that? Just hit F5
devkit takes care of that
if I clone that repository I linked and hit f5 in it, VS code does not know what to do.
it just opens the thing at the top to have me choose a debugger
even on the file that has my entry point, hitting f5 just brings up the top menu:
I know I can go and click the
C#
button and it'll run the file that is open, but that's different from just hitting f5 and having things workI just cloned your repo, waited a second for devkit to finish loading, and F5 works fine
You can tell that the C# extension hasn't loaded here because, for example, there's no
obj
folderdoes the C# extension make the obj folder on its own by just me opening the project in vs code?
Yes
During restore
so if that
obj
folder isn't being made, then my c# extension must not be loaded then?Which will happen automatically as it loads
alright my obj folder is being created automatically so my c# extension is loading
Then just hit F5
I'm expecting to see "Hello World!" in my debug console when I hit f5. That doesn't happen and from your screenshot I can't tell if it happened for you or not.
I've confirmed that my extension is loaded because the
obj
folder was made, but when I hit f5 I am prompted to select a debugger still.Yes, that's how VS Code works. First time through, you need to select a startup project
After you select a startup project, it'll be remembered
with the launch.json I can configure all of that so that I don't need to dig around for my project's entry point when I first run it.
Sure, but you had to dig around to set up a launch.json
Just last night vs code managed to generate a launch.json that found my project's entry point and everything, and then tonight I can't get it to do it, and I don't know what I'm doing differently this night than what I did last night.
6 of one, half dozen of the other
Thank you very much for helping me out @333fred , I really appreciate you taking the time to help me troubleshoot!
I eventually found this stackoverflow: https://stackoverflow.com/questions/75572318/problem-on-configuring-vscode-for-c-it-doesnt-generate-launch-json-and-tasks which is slightly different, but the suggested "generate assets" command did the trick
found the entry dll and everything
Last night I clicked this button and VS Code generated the following launch.json and this is what I was expecting it to do again tonight.