Skip to content

Commit

Permalink
Merge pull request #3663 from rfrerebe/master
Browse files Browse the repository at this point in the history
Try hardcoded path for NuGetFallbackFolder
  • Loading branch information
forki authored Sep 24, 2019
2 parents 4117f21 + dbeb73d commit 4a3357b
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/Paket.Core/Dependencies/NuGetCache.fs
Original file line number Diff line number Diff line change
Expand Up @@ -331,13 +331,28 @@ let GetTargetUserNupkg (packageName:PackageName) (version:SemVerInfo) =
let GetTargetUserToolsFolder (packageName:PackageName) (version:SemVerInfo) =
DirectoryInfo(Path.Combine(Constants.UserNuGetPackagesFolder,".tools",packageName.CompareString,version.Normalize())).FullName

let TryGetFallbackFolder () =
let TryGetFallbackFolderFromHardCodedPath () =
let fallbackDir =
match isUnix with
| true ->
[|"/usr/share/dotnet/sdk/NuGetFallbackFolder" |]
| false ->
[| @"C:\Program Files\dotnet\sdk\NuGetFallbackFolder";
@"C:\Program Files (x86)\dotnet\sdk\NuGetFallbackFolder"|]
fallbackDir
|> Array.tryFind Directory.Exists

let TryGetFallbackFolderFromBin () =
let dotnet = if isUnix then "dotnet" else "dotnet.exe"
ProcessHelper.tryFindFileOnPath dotnet |> Option.bind (fun fileName ->
let dotnetDir = Path.GetDirectoryName fileName
let fallbackDir = Path.Combine (dotnetDir, "sdk", "NuGetFallbackFolder")
if Directory.Exists fallbackDir then Some fallbackDir else None)

let TryGetFallbackFolder () =
TryGetFallbackFolderFromHardCodedPath ()
|> Option.orElseWith TryGetFallbackFolderFromBin

let TryGetFallbackNupkg (packageName:PackageName) (version:SemVerInfo) =
match TryGetFallbackFolder() with
| Some folder ->
Expand Down

0 comments on commit 4a3357b

Please sign in to comment.