Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paket.Core: honor DOTNET_ROOT env var [note: UNTESTED, DO NOT MERGE yet] #4142

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions src/Paket.Core/Common/ProcessHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,14 @@ let isValidPath (path:string) =
|> Array.filter (fun char -> path.Contains(char.ToString()))
|> Array.isEmpty

/// Gets the list of valid directories included in the PATH environment variable.
/// Gets the list of valid directories included in the DOTNET_ROOT and PATH environment variables.
let pathDirectories =
splitEnvironVar "PATH"
let pathEnvVarItems = splitEnvironVar "PATH"
let allPaths =
match environVarOrNone "DOTNET_ROOT" with
| None -> pathEnvVarItems
| Some dotnetRootPath -> dotnetRootPath::pathEnvVarItems
allPaths
|> Seq.map (fun value -> value.Trim())
|> Seq.filter (fun value -> not (String.IsNullOrEmpty value) && isValidPath value)

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

let dotnetExe =
let exeName = if isUnix then "dotnet" else "dotnet.exe"
match tryFindFileOnPath exeName with
| Some exe -> exe
| None -> exeName

/// Modifies the ProcessStartInfo according to the platform semantics
let platformInfoAction (psi : ProcessStartInfo) =
if isMonoRuntime && psi.FileName.EndsWith ".exe" then
Expand All @@ -92,11 +103,6 @@ let platformInfoAction (psi : ProcessStartInfo) =

if psi.FileName.ToLowerInvariant().EndsWith(".dll") then
// Run DotNetCore
let exeName = if isUnix then "dotnet" else "dotnet.exe"
let dotnetExe =
match tryFindFileOnPath exeName with
| Some exe -> exe
| None -> exeName
psi.Arguments <- "\"" + psi.FileName + "\" " + psi.Arguments
psi.FileName <- dotnetExe

Expand Down
2 changes: 1 addition & 1 deletion src/Paket.Core/Common/Utils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ let runDotnet workingDir arguments =
let result =
let p = new System.Diagnostics.Process()
p.StartInfo.WorkingDirectory <- workingDir
p.StartInfo.FileName <- "dotnet"
p.StartInfo.FileName <- ProcessHelper.dotnetExe
p.StartInfo.Arguments <- arguments
p.Start() |> ignore
p.WaitForExit()
Expand Down
2 changes: 1 addition & 1 deletion src/Paket.Core/Paket.Core.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
<Compile Include="Common\Domain.fs" />
<Compile Include="Common\Constants.fs" />
<Compile Include="Common\Profile.fs" />
<Compile Include="Common\ProcessHelper.fs" />
<Compile Include="Common\Utils.fs" />
<Compile Include="Common\Encryption.fs" />
<Compile Include="Common\Xml.fs" />
<Compile Include="Common\ProcessHelper.fs" />
<Compile Include="Common\SymlinkUtils.fs" />
<Compile Include="Common\NetUtils.fs" />
<Compile Include="Versioning\SemVer.fs" />
Expand Down