From dbeb73d6f466a8c778da2d0b046cf5301cf5b363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Fr=C3=A8rebeau?= Date: Mon, 23 Sep 2019 14:13:35 +0200 Subject: [PATCH] Try hardcoded path for NuGetFallbackFolder in addition to BinFolder (working only on windows) --- src/Paket.Core/Dependencies/NuGetCache.fs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Paket.Core/Dependencies/NuGetCache.fs b/src/Paket.Core/Dependencies/NuGetCache.fs index 6f66e2b4d2..10d09d66d1 100644 --- a/src/Paket.Core/Dependencies/NuGetCache.fs +++ b/src/Paket.Core/Dependencies/NuGetCache.fs @@ -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 ->