Skip to content

Commit

Permalink
make tool paths returned for the netcore host in line with the values…
Browse files Browse the repository at this point in the history
… returned for the full-framework FSAC host (#305)
  • Loading branch information
baronfel authored and Krzysztof-Cieslak committed Sep 5, 2018
1 parent 80b30b7 commit 8e96d98
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/FsAutoComplete.Core/Environment.fs
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,7 @@ module Environment =
|> List.map (fun (version, sku) -> programFilesX86 </> "Microsoft Visual Studio" </> version </> sku)

let msbuild =
#if SCRIPT_REFS_FROM_MSBUILD
if not(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) then
//well, depends on mono version, but like this is mono >= 5.2 (msbuild on mono 5.0 sort of works)
"msbuild"
#else
if Utils.runningOnMono then "xbuild" // mono <= 5.0
#endif
if Utils.runningOnMono then "msbuild" // we're way past 5.0 now, time to get updated
else
let legacyPaths =
[ programFilesX86 </> @"\MSBuild\14.0\Bin"
Expand Down Expand Up @@ -107,13 +101,16 @@ module Environment =
|> List.tryFind Directory.Exists

let fsi =
if Utils.runningOnMono then "fsharpi"
// on netcore on non-windows we just deflect to fsharpi as usual
if Utils.runningOnMono || not Utils.isWindows then "fsharpi"
else
// if running on windows, non-mono we can't yet send paths to the netcore version of fsi.exe so use the one from full-framework
Option.getOrElse "" fsharpInstallationPath </> "fsi.exe"

let fsc =
if Utils.runningOnMono then "fsharpc"
if Utils.runningOnMono || not Utils.isWindows then "fsharpc"
else
// if running on windows, non-mono we can't yet send paths to the netcore version of fsc.exe so use the one from full-framework
Option.getOrElse "" fsharpInstallationPath </> "fsc.exe"

let fsharpCoreOpt =
Expand Down
50 changes: 50 additions & 0 deletions src/FsAutoComplete.Core/Utils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,56 @@ let isAScript fileName =
let ext = Path.GetExtension fileName
[".fsx";".fsscript";".sketchfs"] |> List.exists ((=) ext)

/// Determines if the current system is an Unix system.
/// See http://www.mono-project.com/docs/faq/technical/#how-to-detect-the-execution-platform
let isUnix =
#if NETSTANDARD1_6
System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(
System.Runtime.InteropServices.OSPlatform.Linux) ||
System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(
System.Runtime.InteropServices.OSPlatform.OSX)
#else
int System.Environment.OSVersion.Platform |> fun p -> (p = 4) || (p = 6) || (p = 128)
#endif

/// Determines if the current system is a MacOs system
let isMacOS =
#if NETSTANDARD1_6
System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(
System.Runtime.InteropServices.OSPlatform.OSX)
#else
(System.Environment.OSVersion.Platform = PlatformID.MacOSX) ||
// osascript is the AppleScript interpreter on OS X
File.Exists "/usr/bin/osascript"
#endif

/// Determines if the current system is a Linux system
let isLinux =
#if NETSTANDARD1_6
System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(
System.Runtime.InteropServices.OSPlatform.Linux)
#else
isUnix && not isMacOS
#endif

/// Determines if the current system is a Windows system
let isWindows =
#if NETSTANDARD1_6
System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(
System.Runtime.InteropServices.OSPlatform.Windows)
#else
match System.Environment.OSVersion.Platform with
| PlatformID.Win32NT | PlatformID.Win32S | PlatformID.Win32Windows | PlatformID.WinCE -> true
| _ -> false
#endif

let runningOnNetCore =
#if NETSTANDARD1_6
true
#else
false
#endif

let runningOnMono =
try not << isNull <| Type.GetType "Mono.Runtime"
with _ -> false
Expand Down

0 comments on commit 8e96d98

Please sign in to comment.