Skip to content

Process.Start() failure should include path #39928

Description

@danmoseley

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:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions