-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
When a process cannot be started, it would be useful for the exception to include the ProcessStartInfo or equivalent.
For example, I got this in the VS output window - I assume it's missing a certain dotnet.exe but I don't know which. I've encountered this in other situations.
Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Failed to launch testhost with error: System.AggregateException: One or more errors occurred. ---> System.ComponentModel.Win32Exception: The system cannot find the file specified
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.ProcessHelper.LaunchProcess(String processPath, String arguments, String workingDirectory, IDictionary`2 envVariables, Action`2 errorCallback, Action`1 exitCallBack, Action`2 outputCallBack)
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.LaunchHost(TestProcessStartInfo testHostStartInfo, CancellationToken cancellationToken)
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.<>c__DisplayClass38_0.<LaunchTestHostAsync>b__0()
at System.Threading.Tasks.Task`1.InnerInvoke()
We already special case two codes
https://github.com/danmosemsft/runtime/blob/58e6ab1054b8809b3c91fcd75d1dbfff559e9573/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs#L612-L616
We would special case ERROR_DIRECTORY, ERROR_FILE_NOT_FOUND, ERROR_INVALID_PARAMETER, ERROR_INVALID_NAME, ERROR_PATH_NOT_FOUND, and ERROR_ACCESS_DENIED and for those include psi.FileName and psi.WorkingDirectory in the message. (Or just do it in all cases) and analogous in Unix:
runtime/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs
Line 528 in 1923bba
| throw new Win32Exception(errno); |