在dotnet运行中使用VSCode任务时出现问题

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

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","args": [
                "test","${workspaceFolder}/Tests/Tests.csproj","/p:CollectCoverage=true","/p:CoverletOutputFormat=cobertura"
            ],"problemMatcher": "$msCompile"
        }
kxkxkxkx 回答:在dotnet运行中使用VSCode任务时出现问题

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

{
    "label": "run api","command": "dotnet run --project ${workspaceFolder}\\WebApi","type": "shell","problemMatcher": "$msCompile"
}
本文链接:https://www.f2er.com/3143930.html

大家都在问