0

I'm using only the Visual Studio Code. From CLI I created a solution with 2 projects.

  • Api
  • Acceptane tests

Debugging it separately work perfect, but in case when I want to debug a test and an endpoint in the same time - doesn't work.

launch.json file

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": ".NET Core Launch (API)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceFolder}/ContentDownloader.API/bin/Debug/net6.0/ContentDownloader.API.dll",
            "args": [],
            "cwd": "${workspaceFolder}/ContentDownloader.API",
            "stopAtEntry": false,
            "requireExactSource": false,
            "serverReadyAction": {
                "action": "openExternally",
                "pattern": "\\bNow listening on:\\s+(https?://\\S+)"
            },
            "env": {
                "ASPNETCORE_ENVIRONMENT": "Development"
            }
        },
        {
            "name": ".NET Core Attach",
            "type": "coreclr",
            "request": "attach"
        }
    ]
}

I try do it like:

  • dotnet run at solution/API/ here

  • via a Debug Test button I run debugger for particular test enter image description here (this is an acceptance test, it request to the api and check the results)

  • at output I have:

...\dotnet\sdk\6.0.100\Microsoft.Common.CurrentVersion.targets(5100,5): warning MSB3026: can't copy "SomeSolution\API\obj\Debug\net6.0\apphost.exe" do "bin\Debug\net6.0\API.exe". The process cannot access the file '...\SomeSolution\API\bin\Debug\net6.0\API.exe' because it is being used by another process.  [...\SomeSolution\API\API.csproj]

...because it is being used by another process.

I understand what it means :) but I have no idea or found a way to solve my problem, I tried to write my own task / launch.json, but all without success

Please advise

szkut
  • 353
  • 2
  • 22
  • it looks like very similar to: https://stackoverflow.com/questions/2625239/unable-to-copy-a-file-from-obj-debug-to-bin-debug but I dont know how to add Pre-build event while performing `Debug Test` – szkut Sep 11 '22 at 20:23
  • It looks like this is a system env problem. I check for double sure my old laptop where i have linux mint and its working ok. described problem is at win 10. I know how to deal with it via visual studio, but as I have to work with this code at linux and windows I want to learn visual studio code. any advice how to deal with pre build event at vsc? – szkut Sep 12 '22 at 17:27

0 Answers0