diff --git a/Fsdk/Process.fs b/Fsdk/Process.fs index 9b88ba59..7da5298b 100644 --- a/Fsdk/Process.fs +++ b/Fsdk/Process.fs @@ -496,7 +496,7 @@ module Process = commandNamesByOrderOfPreference // FIXME: it returns the first result, but we should return all (array) - let VsWhere(searchPattern: string) : string = + let VsWhere(searchPattern: string) : Option = if Misc.GuessPlatform() <> Misc.Platform.Windows then failwith "vswhere.exe doesn't exist in other platforms than Windows" @@ -523,14 +523,15 @@ module Process = let procResult = Execute(vswhereCmd, Echo.Off) - let firstResult = + let entries = procResult .UnwrapDefault() .Split( Array.singleton Environment.NewLine, StringSplitOptions.RemoveEmptyEntries ) - .First() - .Trim() - firstResult + if entries.Any() then + entries.First().Trim() |> Some + else + None diff --git a/fsxc/Fsxc.fs b/fsxc/Fsxc.fs index 8f92ea8d..77cb91e8 100644 --- a/fsxc/Fsxc.fs +++ b/fsxc/Fsxc.fs @@ -788,7 +788,10 @@ let fsi = { CommandLineArgs = System.Environment.GetCommandLineArgs() } "dotnet" #else match Misc.GuessPlatform() with - | Misc.Platform.Windows -> Process.VsWhere "**\\fsc.exe" + | Misc.Platform.Windows -> + match Process.VsWhere "**\\fsc.exe" with + | None -> failwith "fsc.exe not found" + | Some fscExe -> fscExe | _ -> "fsharpc" #endif diff --git a/scripts/make.fsx b/scripts/make.fsx index 99cab4d4..42fc565e 100644 --- a/scripts/make.fsx +++ b/scripts/make.fsx @@ -91,7 +91,9 @@ let FindBuildTool() : string * string = #if !LEGACY_FRAMEWORK "dotnet", "build" #else - (Process.VsWhere "MSBuild\\**\\Bin\\MSBuild.exe"), String.Empty + match Process.VsWhere "MSBuild\\**\\Bin\\MSBuild.exe" with + | None -> failwith "msbuild not found?" + | Some msbuildExe -> msbuildExe, String.Empty #endif let BuildSolution diff --git a/scripts/runTests.fsx b/scripts/runTests.fsx index dc1a6da8..102ccd4a 100755 --- a/scripts/runTests.fsx +++ b/scripts/runTests.fsx @@ -72,7 +72,10 @@ let fsharpCompilerCommand = "dotnet" #else match Misc.GuessPlatform() with - | Misc.Platform.Windows -> Process.VsWhere "**\\fsc.exe" + | Misc.Platform.Windows -> + match Process.VsWhere "**\\fsc.exe" with + | None -> failwith "fsc.exe not found" + | Some fscExe -> fscExe | _ -> "fsharpc" #endif diff --git a/test/testProcess.fsx b/test/testProcess.fsx index a6e28a52..3dc35aab 100755 --- a/test/testProcess.fsx +++ b/test/testProcess.fsx @@ -26,7 +26,9 @@ let command = if Misc.GuessPlatform() = Misc.Platform.Windows then // HACK: we should call fsx here but then we would get this problem in // the tests: error FS0193: The process cannot access the file 'D:\a\fsx\fsx\test\bin\FSharp.Core.dll' because it is being used by another process. - Process.VsWhere "**\\fsi.exe" + match Process.VsWhere "**\\fsi.exe" with + | None -> failwith "fsi.exe not found" + | Some fsiExe -> fsiExe else // FIXME: extract PREFIX from build.config instead of assuming default "/usr/local/bin/fsx"