private void BeforeQueryStatusForAddPackageForSolutionDialog(object sender, EventArgs args) { NuGetUIThreadHelper.JoinableTaskFactory.Run(async delegate { await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); var command = (OleMenuCommand)sender; // Enable the 'Manage NuGet Packages For Solution' dialog menu // - if the console is NOT busy executing a command, AND // - if the solution exists and not debugging and not building AND // - if there are NuGetProjects. This means there are loaded, supported projects. command.Enabled = IsSolutionExistsAndNotDebuggingAndNotBuilding() && !ConsoleStatus.Value.IsBusy && await SolutionManager.DoesNuGetSupportsAnyProjectAsync(); }); }