Paket.VisualStudio icon indicating copy to clipboard operation
Paket.VisualStudio copied to clipboard

Update All Packages lost unsaved changes

Open JohanLarsson opened this issue 10 years ago • 7 comments

This is probably more a VS bug but here goes:

  1. Edit some files but do not save them
  2. Tools > Paket Dependencies Manager > Update All Packages

Think ^ is what I did, did not test if it is a repro. When the projects reloaded all unsaved changes were lost.

Suggested fix: Save or ask if user wants to save before running the command.

JohanLarsson avatar Nov 10 '15 08:11 JohanLarsson

actually I thought we close the projects before updating. this should have triggered the save functions.

forki avatar Nov 10 '15 08:11 forki

Yeah. I'm sure I raised a bug about this on the Paket VS repo a while ago, not sure if it was closed it bout, but I've seen this happening as well.

isaacabraham avatar Nov 10 '15 08:11 isaacabraham

    private void RunCommandAndReloadAllProjects(string helpTopic, Action<SolutionInfo> command)
    {
        PaketOutputPane.OutputPane.Activate();
        PaketErrorPane.Clear();
        StatusBarService.UpdateText("Paket command started.");

        var info = new SolutionInfo();
        info.Directory = SolutionExplorerExtensions.GetSolutionDirectory();
        info.FileName = SolutionExplorerExtensions.GetSolutionDirectory();
        var projectGuids = SolutionExplorerExtensions.GetAllProjectGuids();

        SolutionExplorerExtensions.SaveSolution();
        foreach (var projectGuid in projectGuids)
            SolutionExplorerExtensions.UnloadProject(projectGuid);

        System.Threading.Tasks.Task.Run(() =>
        {
            try
            {
                command(info);
                PaketOutputPane.OutputPane.OutputStringThreadSafe("Ready\r\n");
                StatusBarService.UpdateText("Ready");
            }
            catch (Exception ex)
            {
                PaketErrorPane.ShowError(ex.Message, info.FileName, helpTopic);
                PaketOutputPane.OutputPane.OutputStringThreadSafe(ex.Message + "\r\n");
            }
        }).ContinueWith(_ =>
        {
            foreach (var projectGuid in projectGuids)
                SolutionExplorerExtensions.ReloadProject(projectGuid);
        });
    }

that's weird...

forki avatar Nov 10 '15 08:11 forki

The bug is very annoying. Is there any chance for the fix?

marhoily avatar Feb 23 '17 07:02 marhoily

I'm happy to take PRs

forki avatar Feb 23 '17 07:02 forki

Heck, it's annoying enough to have all your open document tabs unceremoniously get closed, and then worst of all, they're not restored when Paket extension is done doing its thing. Pretty poor UX. Not a fan. NuGet can restore/update packages without closing the project--so what's the deal here?

fourpastmidnight avatar Jul 28 '17 02:07 fourpastmidnight

Nuget is using VS apis to add or remove references. That works to some degree but is also very flaky.

In the new csproj/fsproj project system with MSBuild 15 this is basically solved.

For this addin here I'm still waiting for someone to contribute a fix. I personally don't use the addin.

forki avatar Jul 28 '17 05:07 forki