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

Fix project restore compatibility issue with older versions of Paket #154

Merged
Merged
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
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");
}
}
}