【问题标题】:Issue using VSCode tasks with dotnet run将 VSCode 任务与 dotnet run 一起使用时出现问题
【发布时间】:2019-11-07 14:43:29
【问题描述】:

我在父文件夹中有两个项目:

parentFolder
   | webApiFolder
   | testsFolder

使用终端,我需要将--project 参数传递给dotnet run。因此,我认为只创建一个任务并运行该任务会更容易。但是,我无法完成任务。

任务:

{
            "label": "run api",
            "command": "dotnet",
            "type": "process",
            "args": [
                "run",
                "--project ${workspaceFolder}\\WebApi\\mercury-ms-auth.csproj"
            ],
            "problemMatcher": "$msCompile"
        }

输出:

> Executing task: C:\Program Files\dotnet\dotnet.exe run --project G:\Git_CS\mercury-ms-auth\WebApi\mercury-ms-auth.csproj <

Couldn't find a project to run. Ensure a project exists in g:\Git_CS\mercury-ms-auth, or pass the path to the project using --project.
The terminal process terminated with exit code: 1

但是,如果我运行 dotnet run --project G:\Git_CS\mercury-ms-auth\WebApi\mercury-ms-auth.csproj,则可以完美启动项目。

同样,我的test and code coverage 任务也完美运行:

{
            "label": "test with code coverage",
            "command": "dotnet",
            "type": "process",
            "args": [
                "test",
                "${workspaceFolder}/Tests/Tests.csproj",
                "/p:CollectCoverage=true",
                "/p:CoverletOutputFormat=cobertura"
            ],
            "problemMatcher": "$msCompile"
        }

【问题讨论】:

    标签: .net-core visual-studio-code vscode-tasks


    【解决方案1】:

    一种解决方案是 "type": "shell" 并传递整个命令。

    {
        "label": "run api",
        "command": "dotnet run --project ${workspaceFolder}\\WebApi",
        "type": "shell",
        "problemMatcher": "$msCompile"
    }
    

    【讨论】:

    • 很好用。好决定。令人沮丧,因为另一种方式应该可行,但使用不当。
    猜你喜欢
    • 1970-01-01
    • 2011-03-15
    • 2011-05-27
    • 1970-01-01
    • 1970-01-01
    • 2023-04-07
    • 2010-10-26
    • 2020-06-17
    • 1970-01-01
    相关资源
    最近更新 更多