Search code examples
.netvisual-studio.net-corevisual-studio-2017

Running testcases in visual studio is throwing "System.ArgumentException: Illegal characters in path"


Recently, I moved from .net framework to .net core, Previously, when I was on the .net framework the unit test cases were running smoothly in visual studio. But after changing to .net core everything is running smoothly but on running the unit test cases the following error is being thrown:

System.ArgumentException: Illegal characters in path.

with the below message being displayed on the output console:

[26-02-2019 11:36:25 Informational] ------ Run test started ------ [26-02-2019 11:36:26 Error] System.ArgumentException: Illegal characters in path. at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional) at System.IO.Path.Combine(String path1, String path2) at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers.DotnetHostHelper.TryGetExecutablePath(String executableBaseName, String& executablePath) at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers.DotnetHostHelper.GetDotnetPath() at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable`1 sources, IDictionary`2 environmentVariables, TestRunnerConnectionInfo connectionInfo) at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources) at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyExecutionManager.StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler eventHandler) [26-02-2019 11:36:26 Error] System.ArgumentException: Illegal characters in path. at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional) at System.IO.Path.Combine(String path1, String path2) at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers.DotnetHostHelper.TryGetExecutablePath(String executableBaseName, String& executablePath) at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers.DotnetHostHelper.GetDotnetPath() at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable`1 sources, IDictionary`2 environmentVariables, TestRunnerConnectionInfo connectionInfo) at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources) at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyExecutionManager.StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler eventHandler)

I also looked at some other solution but none on them were helpful to me.


Solution

  • You have a wrong character (like ") in your PATH environment variable.

    You can view your PATH by running set PATH in cmd, or by enter to Control Panel -> System -> Advanced System Settings -> Environment Variables.

    Please share your PATH with us.