microsoft / vscode-remote-release

Visual Studio Code Remote Development: Open any folder in WSL, in a Docker container, or on a remote machine using SSH and take advantage of VS Code's full feature set.
https://aka.ms/vscode-remote
Other
3.61k stars 275 forks source link

Devcontainer: `dotnet test` with MSTest V2 project fails running from bind mount in "Open Folder in Container", succeeds running from volume mount in "Open Repository in Container". #2268

Closed sabrsorensen closed 4 years ago

sabrsorensen commented 4 years ago

The above versions are where I first encountered this issue, however I have confirmed this occurs when targeting .NET Core 2.1, 2.2, 3.0, and 3.1 and using the appropriate dotnet/core/sdk tag for the .NET version.

This looks similar to #560, however mounting node_modules as a volume isn't an appropriate workaround for this circumstance.

Steps to Reproduce:

  1. Open a local folder with a .NET Core project using MSTestV2 in a devcontainer, for example.
  2. Run dotnet test from the bind-mounted source code, in the repo linked above this would be under /workspaces/devcontainer.mstest.repro.

Expected result (based on the repro repo linked above):

# dotnet test
Test run for /workspaces/devcontainer.mstest.repro/devcontainer.mstest.repro.unit.tests/bin/Debug/netcoreapp3.1/devcontainer.mstest.repro.unit.tests.dll(.NETCoreApp,Version=v3.1)
Microsoft (R) Test Execution Command Line Tool Version 16.3.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...

A total of 1 test files matched the specified pattern.

Test Run Successful.
Total tests: 1
     Passed: 1
 Total time: 0.9571 Seconds

Actual result:

# dotnet test
Test run for /workspaces/devcontainer.mstest.repro/devcontainer.mstest.repro.unit.tests/bin/Debug/netcoreapp3.1/devcontainer.mstest.repro.unit.tests.dll(.NETCoreApp,Version=v3.1)
Microsoft (R) Test Execution Command Line Tool Version 16.3.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...

A total of 1 test files matched the specified pattern.
An exception occurred while invoking executor 'executor://mstestadapter/v2': Input/output error                                                                                                          

Test Run Failed.
Additionally, path to test adapters can be specified using /TestAdapterPath command. Example  /TestAdapterPath:<pathToCustomAdapters>.

Does this issue occur when you try this locally?: No Does this issue occur when you try this locally and all extensions are disabled?: No

Specifying the TestAdapterPath as mentioned in the error output does not resolve the issue, dotnet test reports that it cannot locate the adapter at that path, no matter how the path is formatted. https://github.com/microsoft/vstest/issues/1648 indicates that TestAdapterPath may not be supported in .NET Core any longer, so that may be an unrelated issue. Copying the source code to any directory actually within the container then running dotnet test from that directory will execute successfully, so this seems to be limited to running from the bind mount workspace.

It's only on bind mounts/Open Folder in Container that this occurs, dotnet test runs successfully if I use Open Repository in Container to access the repro repo linked above and run the command from the volume mounted workspace.

Thank you for your time looking through this, please let me know if there's anything I can help with.

Chuxel commented 4 years ago

@sabrsorensen Hmm - This does not repro on Mac or Windows 10 when using the new WSL2 engine for Docker. It only repros in the Windows hyper-v one. Unfortunately, this likely means it has something to do with dotnet test and the Docker for Windows implementation itself rather than this extension.

You can repro this directly by running the following from PowerShell from the local folder with the test project:

docker run -it --rm -v ${PWD}:/workspace mcr.microsoft.com/dotnet/core/sdk:3.1 dotnet test /workspace

Since this is coming from inside dotnet itself, would you mind raising this over on either the dotnet/sdk or microsoft/vstest repos to get the right engineering team to investigate further? I unfortunately can't move it myself.

Chuxel commented 4 years ago

@sabrsorensen Ironically, Docker 2.2.0.3 just came out today that may have fixed this. Can you retry? I'm no longer seeing it in Docker 2.2.1.0 (Edge), and I see a number of Windows bind mount issues were fixed in 2.2.0.3.

sabrsorensen commented 4 years ago

@Chuxel Thanks for digging into this! I can confirm that upgrading to Docker 2.2.0.3 on Windows has addressed the issue, I'm able to run dotnet test from the bind mounted workspace successfully.