Debugger not working, keeps prompting to select environment
Environment data
dotnet --info output:
.NET Command Line Tools (1.0.4)
Product Information:
Version: 1.0.4
Commit SHA-1 hash: af1e6684fd
Runtime Environment:
OS Name: Windows
OS Version: 6.1.7601
OS Platform: Windows
RID: win7-x64
Base Path: C:\Program Files\dotnet\sdk\1.0.4
VS Code version: 1.14.0
C# Extension version: 1.11.0
Steps to reproduce
- Open *.cs file for console app in vs code.
- Press F5 to begin debug session.
Expected behavior
Program will run in debug mode.
Actual behavior
The "Select Environment" dialog comes up. I get option for Node.JS, .NET Core, and PowerShell. I select the .NET Core option and nothing happens. Hitting F5 again results in the "Select Environment" dialog coming up again, and this goes on and on.
Do you also have a folder open? Or only source files? To my knowledge at least, VS Code doesn't support debugging without a folder open.
The best way to debug a .NET Core application is to open the folder that contains your project. If you do it this way the C# extension has code to try and figure out what you want to debug. See https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger.md#once-for-each-project.
If you do have a folder open, you can use the template that gets generated if you hit F5 and you don't already have a launch.json. But it will not 'just work' -- you will need to manually configure how you build your project, and what the output of that builds is. For this reason I highly recommend following the previously mentioned instructions instead.
Hi Gregg,
That's done the trick. I opened the folder and then waited for vs code to prompt me to restore and have it generate assets for me. As you seemed to have alluded to, hitting F5 right away will restore, but assets will be missing and you'll have to do some manual configuration.
For anyone reading after, this is what did the trick (thanks to Gregg):
- Open the folder containing the *.cs file you wish to debug, I then had to open the program.cs file that I was debugging.
- Wait a second for vs code to detect that a restore and asset placement needs to be done. Click Yes on the prompts.
- Debug should now work!
Thanks for the info, Gregg!
Thanks for confirming! Glad to help.