Reputation: 4811
I tried to follow the instructions here: https://learn.microsoft.com/en-us/aspnet/core/tutorials/web-api-vsc
I did:
mkdir todoapi
cd todoapi
dotnet new webapi
When I opened Startup.cs in VS Code, I didn't get any warn message asking me the following:
Select Yes to the Warn message "Required assets to build and debug are missing from 'TodoApi'. Add them?"
Select Restore to the Info message "There are unresolved dependencies".
What is wrong with my local setup?
I just want to run this program from withi VS code.
If I run in debug mode I get this error:
The preLaunchTask 'build' terminated with exit code 1.
In the powershell terminal the command 'dotnet' doesn't work either. Should it?
Update
I re-started VS COde and now it picks up the command in terminal: dotnet
Now when I run I get this:
launch: launch.json must be configured. Change 'program' to the path to the executable file that you would like to debug.
My launch.json has:
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceRoot}/bin/Debug/<target-framework>/<project-name.dll>",
"args": [],
"cwd": "${workspaceRoot}",
"stopAtEntry": false,
"console": "internalConsole"
},
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceRoot}/bin/Debug/<target-framework>/<project-name.dll>",
"args": [],
"cwd": "${workspaceRoot}",
"stopAtEntry": false,
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}",
"windows": {
"command": "cmd.exe",
"args": "/C start ${auto-detect-url}"
},
"osx": {
"command": "open"
},
"linux": {
"command": "xdg-open"
}
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceRoot}/Views"
}
},
Upvotes: 1
Views: 3760
Reputation: 1566
Try:
dotnet restore //restore dependencies
dotnet build //build project
dotnet run //run project
Upvotes: 1