Unable to run unit tests with dotnet cli
Open 💬 4 comments Opened Feb 17, 2026 by jmbryan4
💡 Likely answer: A maintainer (etraut-openai, contributor)
responded on this thread — see the highlighted reply below.
What version of Codex CLI is running?
codex-cli 0.101.0
What subscription do you have?
Plus
Which model were you using?
gpt-5.3-codex high
What platform is your computer?
Darwin 25.2.0 arm64 arm
What terminal emulator and version are you using (if applicable)?
Ghostty
What issue are you seeing?
Codex is unable to run unit tests on a .NET 10 unit test project.
It either fails or hangs.
thread ID 019c6d83-a37d-7573-88d6-b3a2592ad504
some example output of what it says:
dotnet test now fails due the .NET 10 + Microsoft.Testing.Platform opt-in requirement, so I’m checking the test project settings and then I’ll run with the correct flag to validate the suite.
• The same VSTest-target error persists even without filters. I’m trying the explicit MTP opt-in property on the command line next to see if this environment ignores the project-level setting.
What steps can reproduce the bug?
Try running a test project via dotnet cli with MTP runner.
see: https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-test
also see: https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-with-dotnet-test
minimal-mtp-dotnet10-tests.zip
unzip and run tests in project. see README
dotnet test --solution minimal-mtp-dotnet10-tests.slnx
What is the expected behavior?
tests run successfully
4 Comments
potentially related to https://github.com/openai/codex/issues/1276
This is definitely not related to #1276 because that issue pertains to cloud environments, and you're running the CLI on a local environment.
This is likely related to either the sandbox or the shell environment. You could check on the sandbox by attempting to run it in "Full Access" (yolo) mode. If that doesn't fix it, you'll probably need to do some additional debugging and investigation on your own to figure out why it's not working.
i am running into this issue as well, seems to be connected to sandbox preventing socket access - it also breaks dotnet build which usually uses a build server. If build server is disabled via a env variable, build works ok. For test, codex had to create a c# test runner to be able to run tests. both run without issue on with Full Access on. i've experienced this both on linux and macos.
i've asked codex to explain what it found and its workarounds:
Summary
Standard .NET build and test commands are not reliably usable inside the Codex desktop sandbox because several parts of the .NET toolchain use background processes, IPC, or local sockets.
There are two separate problems:
dotnet buildmay use the MSBuild server, reusable MSBuild nodes, the shared Roslyn compiler, and .NET diagnostics IPC. These must all be explicitly disabled.dotnet teststill fails because VSTest unconditionally attempts to bind a TCP listener for communication with its test host.Environment
workspace-writeMicrosoft.NET.Test.Sdk17.11.1Problem 1:
dotnet buildA plain command such as:
is not safe/reliable in the sandbox because the .NET build toolchain may start or communicate with:
VBCSCompiler);These facilities use local IPC or sockets that can be rejected by the sandbox or cause the command to hang.
The build only worked reliably after disabling all of them:
Relevant settings:
DOTNET_CLI_USE_MSBUILD_SERVER=0disables the persistent CLI MSBuild server.MSBUILDDISABLENODEREUSE=1disables reusable MSBuild nodes.-nr:falsealso disables MSBuild node reuse.-p:UseSharedCompilation=falsedisables the shared Roslyn compiler process.-m:1avoids parallel MSBuild workers.DOTNET_EnableDiagnostics=0andCOMPlus_EnableDiagnostics=0disable runtime diagnostic IPC.--disable-build-serversdisables available build servers.It would be helpful if Codex either applied these settings automatically for sandboxed .NET builds or documented a supported socket-free build command.
Problem 2:
dotnet testApplying the same restrictions allows the build phase of
dotnet testto finish, but the test phase still aborts before executing any tests:The failure is:
No test is executed. The failure occurs when VSTest tries to bind its internal TCP listener.
The build-related flags do not affect this listener because it is part of VSTest’s controller/test-host communication protocol, not MSBuild or .NET diagnostics.
Expected behavior
Codex should support ordinary .NET build and test workflows without requiring project-specific workarounds.
Possible solutions include:
dotnet buildanddotnet testand apply the necessary sandbox profile automatically.Workaround used
For builds, I disabled every known background server and IPC feature using the command shown above.
For tests, that was insufficient because VSTest still required a TCP listener. I therefore bypassed VSTest:
AssemblyLoadContext.[Fact]methods through reflection.DYLD_LIBRARY_PATH.dotnet runner.dll.This allowed focused tests to run without VSTest sockets.
It is not a general replacement for a test runner because it bypasses normal test discovery, theories, fixtures, parallelization, timeouts, output capture, and other VSTest/xUnit runner behavior.