Skip to content

Commit 828443e

Browse files
committed
Paket.Core: honor DOTNET_ROOT env var [note: UNTESTED, DO NOT MERGE yet]
Fixes #4141
1 parent 527c5f8 commit 828443e

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/Paket.Core/Common/ProcessHelper.fs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,14 @@ let isValidPath (path:string) =
6868
|> Array.filter (fun char -> path.Contains(char.ToString()))
6969
|> Array.isEmpty
7070

71-
/// Gets the list of valid directories included in the PATH environment variable.
71+
/// Gets the list of valid directories included in the DOTNET_ROOT and PATH environment variables.
7272
let pathDirectories =
73-
splitEnvironVar "PATH"
73+
let pathEnvVarItems = splitEnvironVar "PATH"
74+
let allPaths =
75+
match environVarOrNone "DOTNET_ROOT" with
76+
| None -> pathEnvVarItems
77+
| Some dotnetRootPath -> dotnetRootPath::pathEnvVarItems
78+
allPaths
7479
|> Seq.map (fun value -> value.Trim())
7580
|> Seq.filter (fun value -> not (String.IsNullOrEmpty value) && isValidPath value)
7681

@@ -84,6 +89,12 @@ let tryFindFileOnPath (file : string) : string option =
8489
|> Seq.append [ "." ]
8590
|> fun path -> tryFindFile path file
8691

92+
let dotnetExe =
93+
let exeName = if isUnix then "dotnet" else "dotnet.exe"
94+
match tryFindFileOnPath exeName with
95+
| Some exe -> exe
96+
| None -> exeName
97+
8798
/// Modifies the ProcessStartInfo according to the platform semantics
8899
let platformInfoAction (psi : ProcessStartInfo) =
89100
if isMonoRuntime && psi.FileName.EndsWith ".exe" then
@@ -92,11 +103,6 @@ let platformInfoAction (psi : ProcessStartInfo) =
92103

93104
if psi.FileName.ToLowerInvariant().EndsWith(".dll") then
94105
// Run DotNetCore
95-
let exeName = if isUnix then "dotnet" else "dotnet.exe"
96-
let dotnetExe =
97-
match tryFindFileOnPath exeName with
98-
| Some exe -> exe
99-
| None -> exeName
100106
psi.Arguments <- "\"" + psi.FileName + "\" " + psi.Arguments
101107
psi.FileName <- dotnetExe
102108

src/Paket.Core/Common/Utils.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ let runDotnet workingDir arguments =
455455
let result =
456456
let p = new System.Diagnostics.Process()
457457
p.StartInfo.WorkingDirectory <- workingDir
458-
p.StartInfo.FileName <- "dotnet"
458+
p.StartInfo.FileName <- ProcessHelper.dotnetExe
459459
p.StartInfo.Arguments <- arguments
460460
p.Start() |> ignore
461461
p.WaitForExit()

0 commit comments

Comments
 (0)