简单的dotnetcore应用程序未在VS代码

时间:2017-06-01 20:58:31

标签: c# asp.net-core visual-studio-code

我尝试按照此处的说明操作:https://docs.microsoft.com/en-us/aspnet/core/tutorials/web-api-vsc

我做了:

mkdir todoapi
cd todoapi
dotnet new webapi

当我在VS Code中打开Startup.cs时,我没有收到任何警告消息,询问以下内容:

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".

我的本​​地设置有什么问题?

我只是想从withi VS代码运行这个程序。

如果我在调试模式下运行,我会收到此错误:

The preLaunchTask 'build' terminated with exit code 1.

在powershell终端中,'dotnet'命令也不起作用。应该吗?

更新

我重新启动VS COde,现在它在终端中接收命令: DOTNET

现在,当我跑步时,我得到了这个:

  

启动:必须配​​置launch.json。将“程序”更改为路径   到您想要调试的可执行文件。

我的launch.json有:

"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"
            }
        },

1 个答案:

答案 0 :(得分:1)

尝试:

dotnet restore      //restore dependencies
dotnet build        //build project
dotnet run          //run project