Skip to content

Commit

Permalink
Fix project restore compatibility issue with older versions of Paket
Browse files Browse the repository at this point in the history
  • Loading branch information
ruhullahshah committed Oct 19, 2017
1 parent e807949 commit 5541d3b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
19 changes: 17 additions & 2 deletions src/Paket.VisualStudio/Restore/PaketRestorer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,23 @@ public void Restore(IEnumerable<RestoringProject> project)
foreach (RestoringProject p in project)
PaketSubCommand += $" --references-file {p.ReferenceFile} ";

PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetPaketDirectory(), PaketSubCommand,
(send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
try
{
PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetPaketDirectory(), PaketSubCommand,
(send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
}
catch (System.Exception ex)
{
/* One of the known reasons for this block to get executed is that if the paket.exe is old then it is likely
* that --references-file is not supported and --references-files is supported instead. paket-4.8.4 for instance
*/
PaketOutputPane.OutputPane.OutputStringThreadSafe("Seems like you are using an older version of paket.exe. Trying restore with --references-files\n");
PaketSubCommand = "restore --references-files";
foreach (RestoringProject p in project)
PaketSubCommand += $" {p.ReferenceFile} ";
PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetPaketDirectory(), PaketSubCommand,
(send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
}
}
}
}
3 changes: 2 additions & 1 deletion src/Paket.VisualStudio/Utils/PaketLauncher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public static void LaunchPaket(string SolutionDirectory, string PaketSubCommand,
/* At this point, all is well .paket\paket.exe exists or .paket\paket.bootstrapper.exe downloaded it successfully.
* Now issue the original command to .paket\paket.exe
*/
LaunchProcess(SolutionDirectory, PAKET_EXE, PaketSubCommand, PaketDataReceivedHandler);
if (LaunchProcess(SolutionDirectory, PAKET_EXE, PaketSubCommand, PaketDataReceivedHandler) != 0)
throw new System.Exception($"{PAKET_EXE} {PaketSubCommand} failed");
}
}
}

0 comments on commit 5541d3b

Please sign in to comment.