1

I have two projects in a parent folder:

parentFolder | webApiFolder | testsFolder 

Using the terminal, I need to pass the --project parameter to dotnet run. As such, I figure it'd be easier to just create a task and run the task instead. However, I can't get the task to work.

Task:

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

Output:

> 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 

However, if I run dotnet run --project G:\Git_CS\mercury-ms-auth\WebApi\mercury-ms-auth.csproj, that launches the project perfectly.

Similarly, my test and code coverage task works perfectly:

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

2 Answers 2

4

One solution is to "type": "shell" and pass through the whole command.

{ "label": "run api", "command": "dotnet run --project ${workspaceFolder}\\WebApi", "type": "shell", "problemMatcher": "$msCompile" } 
Sign up to request clarification or add additional context in comments.

1 Comment

nice that works. good call. frustrating as the other way should work but ill use this.
1

Correct is:

"args": [ "run", "--project=${workspaceFolder}\\WebApi\\mercury-ms-auth.csproj" ], 

or

"args": [ "run", "--project", "${workspaceFolder}\\WebApi\\mercury-ms-auth.csproj" ], 

1 Comment

Thank you for contributing to the Stack Overflow community. This may be a correct answer, but it’d be really useful to provide additional explanation of your code so developers can understand your reasoning. This is especially useful for new developers who aren’t as familiar with the syntax or struggling to understand the concepts. Would you kindly edit your answer to include additional details for the benefit of the community?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.