dotnet / dotnet/vscode-csharp

How do I pass --nobuild to dotnet test when using 'Debug Tests' button?

Open
#5,205 0 comments 0 reactions 0 assignees View on GitHub
Test
Dominant language
TypeScript
Stars
3.1k
Forks
737
Avg merge
17h 56m
Merged PRs (30d)
21

Description

## Background
I have an aspnet core API project and a xunit test project. Ideally I would like to be able to debug the API and then also click this "Debug Tests" button to debug my tests as well.

![image](https://user-images.githubusercontent.com/1046234/167724374-2841bcb0-f090-44b2-9c6d-1c15f8810726.png)

## Problem
The test project has a project reference to the API so when I click Debug Tests, I get several errors. They are about not being able to copy the API project's files because they are in use. I assume this is because I am debugging the API project.

I figure in order to work around that I can build my tests before I start debugging the API project and then Debug the test without building it. `dotnet test` has the `--nobuild` option and [I see in the code here](https://github.com/OmniSharp/omnisharp-vscode/blob/2d3d83ea1f5924b67550e7e34e5580f9d7fedd73/src/features/dotnetTest.ts#L44) that same flag is available in what I _think_ is the command registered when I click that button.

What settings do I need to change to be able to use that nobuild flag? I don't see anything in settings and I'm not sure if this is something that I could use a `.runsettings` file for. I am also open to alternative solutions.

## Info
launch.json
```
{
"name": ".NET Core Launch",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/api/bin/Debug/net6.0/apidll",
"args": [],
"cwd": "${workspaceFolder}/api",
"stopAtEntry": false,
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
```

tasks.json
```
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/api/api.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.