Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add Update All button in the Updates tab.

  • Loading branch information...
commit 0e2705bdc84354f4a5c9b05ab9ed145dc125c72a 1 parent a17c35c
dotnetjunky authored dotnetjunky committed
Showing with 456 additions and 204 deletions.
  1. +1 −0  changelog.txt
  2. +0 −3  src/Dialog/Dialog.csproj
  3. +0 −3  src/Dialog10/Dialog10.csproj
  4. +12 −2 src/Dialog10/Nodes/PackagesTreeNodeBase.cs
  5. +9 −1 src/Dialog10/PackageItem.cs
  6. +61 −0 src/Dialog10/PackageManagerWindow.xaml.cs
  7. +2 −31 src/Dialog10/Providers/InstalledProvider.cs
  8. +8 −15 src/Dialog10/Providers/OnlineProvider.cs
  9. +6 −1 src/Dialog10/Providers/OnlineSearchProvider.cs
  10. +61 −37 src/Dialog10/Providers/PackagesProviderBase.cs
  11. +7 −22 src/Dialog10/Providers/SolutionInstalledProvider.cs
  12. +4 −31 src/Dialog10/Providers/SolutionOnlineProvider.cs
  13. +36 −29 src/Dialog10/Providers/SolutionUpdatesProvider.cs
  14. +93 −2 src/Dialog10/Providers/UpdatesProvider.cs
  15. +9 −0 src/DialogServices/DialogServices.csproj
  16. +11 −0 src/DialogServices/PackageManagerUI/IUpdateAllUIService.cs
  17. +4 −0 src/DialogServices/PackageManagerUI/ProviderServices.cs
  18. +28 −0 src/DialogServices/PackageManagerUI/UpdateAllUI.xaml
  19. +28 −0 src/DialogServices/PackageManagerUI/UpdateAllUI.xaml.cs
  20. +41 −0 src/DialogServices/PackageManagerUI/UpdateAllUIService.cs
  21. +18 −18 src/DialogServices/Resources.Designer.cs
  22. +6 −6 src/DialogServices/Resources.resx
  23. +1 −0  test/Dialog.Test/InstalledProviderTest.cs
  24. +1 −0  test/Dialog.Test/Mocks/MockPackagesProvider.cs
  25. +1 −0  test/Dialog.Test/OnlineProviderTest.cs
  26. +2 −2 test/Dialog.Test/OnlineSearchProviderTest.cs
  27. +2 −1  test/Dialog.Test/PackagesProviderBaseTest.cs
  28. +1 −0  test/Dialog.Test/SolutionInstalledProviderTest.cs
  29. +1 −0  test/Dialog.Test/SolutionOnlineProviderTest.cs
  30. +1 −0  test/Dialog.Test/SolutionUpdatesProviderTest.cs
  31. +1 −0  test/Dialog.Test/UpdatesProviderTest.cs
View
1  changelog.txt
@@ -13,6 +13,7 @@ Release notes
- Added support for multiple repositories for preinstalled packages in project templates.
- Add -AsPath option to nuget.exe Config command.
- Updates tab in Manage Packages dialog now honors the 'allowedVersions' constraints in packages.config.
+- Added Update All button in the dialog to allow updating all packages with one click.
*** v2.2 ***
View
3  src/Dialog/Dialog.csproj
@@ -123,9 +123,6 @@
<Compile Include="..\Dialog10\Providers\UpdatesProvider.cs">
<Link>Providers\UpdatesProvider.cs</Link>
</Compile>
- <Compile Include="..\VsConsole\PowerShellHostProvider\RegistryHelper.cs">
- <Link>RegistryHelper.cs</Link>
- </Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
View
3  src/Dialog10/Dialog10.csproj
@@ -66,9 +66,6 @@
<DesignTime>True</DesignTime>
<DependentUpon>CommonResources.resx</DependentUpon>
</Compile>
- <Compile Include="..\VsConsole\PowerShellHostProvider\RegistryHelper.cs">
- <Link>RegistryHelper.cs</Link>
- </Compile>
<Compile Include="Nodes\EmptyTreeNode.cs" />
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="Providers\InstalledProvider.cs" />
View
14 src/Dialog10/Nodes/PackagesTreeNodeBase.cs
@@ -16,7 +16,6 @@ namespace NuGet.Dialog.Providers
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable")]
internal abstract class PackagesTreeNodeBase : IVsExtensionsTreeNode, IVsPageDataSource, IVsSortDataSource, IVsProgressPaneConsumer, INotifyPropertyChanged, IVsMessagePaneConsumer
{
-
// The number of extensions to show per page.
private const int DefaultItemsPerPage = 10;
@@ -136,7 +135,7 @@ public bool IsExpanded
}
/// <summary>
- /// List of templates at this node
+ /// List of templates at this node for the current page only
/// </summary>
#if VS10
public IList<IVsExtension> Extensions
@@ -205,6 +204,14 @@ internal set
}
}
+ public int TotalNumberOfPackages
+ {
+ get
+ {
+ return _totalCount;
+ }
+ }
+
/// <summary>
/// Raised when the current node completes loading packages.
/// </summary>
@@ -492,6 +499,9 @@ private void QueryExecutionCompleted(Task<LoadPageResult> task)
}
}
+ Provider.OnPackageLoadCompleted(this);
+
+ // for unit tests
PackageLoadCompleted(this, EventArgs.Empty);
NuGetEventTrigger.Instance.TriggerEvent(NuGetEvent.PackageLoadEnd);
}
View
10 src/Dialog10/PackageItem.cs
@@ -17,6 +17,7 @@ internal class PackageItem : IVsExtension, INotifyPropertyChanged
private readonly IPackage _packageIdentity;
private readonly bool _isUpdateItem, _isPrerelease;
private bool _isSelected;
+ private bool? _isEnabled;
private readonly ObservableCollection<Project> _referenceProjectNames;
private readonly SemanticVersion _oldPackageVersion;
private IEnumerable<object> _displayDependencies;
@@ -217,12 +218,19 @@ public bool IsEnabled
{
get
{
- return _provider.CanExecute(this);
+ if (!_isEnabled.HasValue)
+ {
+ _isEnabled = _provider.CanExecute(this);
+ }
+
+ return _isEnabled.Value;
}
}
internal void UpdateEnabledStatus()
{
+ // set to null to force re-evaluation of the property value
+ _isEnabled = null;
OnNotifyPropertyChanged("IsEnabled");
}
View
61 src/Dialog10/PackageManagerWindow.xaml.cs
@@ -6,6 +6,7 @@
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
+using System.Windows.Media;
using EnvDTE;
using Microsoft.VisualStudio.ExtensionsExplorer.UI;
using Microsoft.VisualStudio.PlatformUI;
@@ -36,8 +37,10 @@ public partial class PackageManagerWindow : DialogWindow
private readonly IProviderSettings _providerSettings;
private readonly IProductUpdateService _productUpdateService;
private readonly IOptionsPageActivator _optionsPageActivator;
+ private readonly IUpdateAllUIService _updateAllUIService;
private readonly Project _activeProject;
private string _searchText;
+
public PackageManagerWindow(Project project, string dialogParameters = null) :
this(project,
@@ -95,6 +98,7 @@ public partial class PackageManagerWindow : DialogWindow
_smartOutputConsoleProvider = new SmartOutputConsoleProvider(providerServices.OutputConsoleProvider);
providerServices.OutputConsoleProvider = _smartOutputConsoleProvider;
_providerSettings = providerServices.ProviderSettings;
+ _updateAllUIService = providerServices.UpdateAllUIService;
AddUpdateBar(productUpdateService);
AddRestoreBar(packageRestoreManager);
@@ -102,6 +106,7 @@ public partial class PackageManagerWindow : DialogWindow
InsertDisclaimerElement();
AdjustSortComboBoxWidth();
PreparePrereleaseComboBox();
+ InsertUpdateAllButton(providerServices.UpdateAllUIService);
SetupProviders(
project,
@@ -485,6 +490,8 @@ private void OnDialogWindowClosed(object sender, EventArgs e)
// flush output messages to the Output console at once when the dialog is closed.
_smartOutputConsoleProvider.Flush();
+ _updateAllUIService.DisposeElement();
+
CurrentInstance = null;
}
@@ -522,6 +529,39 @@ private void InsertDisclaimerElement()
}
}
+ private void InsertUpdateAllButton(IUpdateAllUIService updateAllUIService)
+ {
+ Grid grid = LogicalTreeHelper.FindLogicalNode(explorer, "resGrid") as Grid;
+ if (grid != null && grid.Children.Count > 0)
+ {
+ ListView listView = grid.FindDescendant<ListView>();
+ if (listView != null)
+ {
+ Grid firstGrid = (Grid)listView.Parent;
+ firstGrid.Children.Remove(listView);
+
+ var newGrid = new Grid
+ {
+ Margin = listView.Margin
+ };
+
+ newGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) });
+ newGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
+
+ var updateAllContainer = updateAllUIService.CreateUIElement();
+ updateAllContainer.Margin = new Thickness(5, 2, 0, 5);
+ updateAllContainer.UpdateInvoked += OnUpdateButtonClick;
+ newGrid.Children.Add(updateAllContainer);
+
+ listView.Margin = new Thickness();
+ Grid.SetRow(listView, 1);
+ newGrid.Children.Add(listView);
+
+ firstGrid.Children.Insert(0, newGrid);
+ }
+ }
+ }
+
private void AdjustSortComboBoxWidth()
{
ComboBox sortCombo = FindComboBox("cmd_SortOrder");
@@ -624,6 +664,8 @@ private void OnProviderSelectionChanged(object sender, RoutedPropertyChangedEven
_hasOpenedOnlineProvider = true;
_productUpdateService.CheckForAvailableUpdateAsync();
}
+
+ _updateAllUIService.Hide();
}
else
{
@@ -631,6 +673,25 @@ private void OnProviderSelectionChanged(object sender, RoutedPropertyChangedEven
}
}
+ [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "We don't care about exception handling here.")]
+ private void OnUpdateButtonClick(object sender, RoutedEventArgs e)
+ {
+ var provider = explorer.SelectedProvider as PackagesProviderBase;
+ if (provider != null)
+ {
+ try
+ {
+ provider.Execute(item: null);
+ }
+ catch (Exception exception)
+ {
+ MessageHelper.ShowErrorMessage(exception, NuGet.Dialog.Resources.Dialog_MessageBoxTitle);
+
+ ExceptionHelper.WriteToActivityLog(exception);
+ }
+ }
+ }
+
private void OnSendingRequest(object sender, WebRequestEventArgs e)
{
HttpUtility.SetUserAgent(e.Request, _dialogUserAgent.Value);
View
33 src/Dialog10/Providers/InstalledProvider.cs
@@ -11,7 +11,6 @@
using Microsoft.VisualStudio.ExtensionsExplorer;
using NuGet.Dialog.PackageManagerUI;
using NuGet.VisualStudio;
-using NuGetConsole.Host.PowerShellProvider;
namespace NuGet.Dialog.Providers
{
@@ -143,7 +142,7 @@ protected override bool ExecuteCore(PackageItem item)
{
CheckDependentPackages(item.PackageIdentity, LocalRepository, _targetFramework);
- bool? removeDependencies = AskRemoveDependencyAndCheckUninstallPSScript(
+ bool? removeDependencies = AskRemoveDependency(
item.PackageIdentity,
new [] { LocalRepository },
new [] { _targetFramework });
@@ -183,7 +182,7 @@ protected override bool ExecuteCore(PackageItem item)
}
}
- protected bool? AskRemoveDependencyAndCheckUninstallPSScript(
+ protected bool? AskRemoveDependency(
IPackage package,
IList<IPackageRepository> localRepositories,
IList<FrameworkName> targetFrameworks)
@@ -230,34 +229,6 @@ protected override bool ExecuteCore(PackageItem item)
removeDependencies = _userNotifierServices.ShowRemoveDependenciesWindow(message);
}
- if (removeDependencies == null)
- {
- return removeDependencies;
- }
-
- bool hasScriptPackages;
- if (removeDependencies == true)
- {
- // if user wants to remove dependencies, we need to check all of them for PS scripts
- var scriptPackages = from o in allOperations
- where o.Package.HasPowerShellScript()
- select o.Package;
- hasScriptPackages = scriptPackages.Any();
- }
- else
- {
- // otherwise, just check the to-be-uninstalled package
- hasScriptPackages = package.HasPowerShellScript(new string[] { PowerShellScripts.Uninstall });
- }
-
- if (hasScriptPackages)
- {
- if (!RegistryHelper.CheckIfPowerShell2Installed())
- {
- throw new InvalidOperationException(Resources.Dialog_PackageHasPSScript);
- }
- }
-
return removeDependencies;
}
View
23 src/Dialog10/Providers/OnlineProvider.cs
@@ -150,8 +150,15 @@ protected override bool ExecuteCore(PackageItem item)
using (activePackageManager.SourceRepository.StartOperation(OperationName))
{
+ ShowProgressWindow();
+
IList<PackageOperation> operations;
- bool acceptLicense = CheckPSScriptAndShowLicenseAgreement(item, activePackageManager, out operations);
+ bool acceptLicense = ShowLicenseAgreement(
+ item.PackageIdentity,
+ activePackageManager,
+ _project.GetTargetFrameworkName(),
+ out operations);
+
if (!acceptLicense)
{
return false;
@@ -162,20 +169,6 @@ protected override bool ExecuteCore(PackageItem item)
}
}
- protected bool CheckPSScriptAndShowLicenseAgreement(PackageItem item, IVsPackageManager packageManager, out IList<PackageOperation> operations)
- {
- ShowProgressWindow();
-
- CheckInstallPSScripts(
- item.PackageIdentity,
- packageManager.SourceRepository,
- _project.GetTargetFrameworkName(),
- IncludePrerelease,
- out operations);
-
- return ShowLicenseAgreement(packageManager, operations);
- }
-
protected void ExecuteCommandOnProject(Project activeProject, PackageItem item, IVsPackageManager activePackageManager, IList<PackageOperation> operations)
{
IProjectManager projectManager = null;
View
7 src/Dialog10/Providers/OnlineSearchProvider.cs
@@ -55,9 +55,14 @@ protected override IList<IVsSortDescriptor> CreateSortDescriptors()
return sortDescriptors;
}
+ public override void OnPackageLoadCompleted(PackagesTreeNodeBase selectedNode)
+ {
+ _baseProvider.OnPackageLoadCompleted(selectedNode);
+ }
+
protected internal override void RemoveSearchNode()
{
_baseProvider.RemoveSearchNode();
}
}
-}
+}
View
98 src/Dialog10/Providers/PackagesProviderBase.cs
@@ -12,13 +12,13 @@
using Microsoft.VisualStudio.ExtensionsExplorer.UI;
using NuGet.VisualStudio;
using NuGetConsole;
-using NuGetConsole.Host.PowerShellProvider;
namespace NuGet.Dialog.Providers
{
/// <summary>
/// Base class for all tree node types.
/// </summary>
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling", Justification="This is due to the native of this class.")]
internal abstract class PackagesProviderBase : VsExtensionsProvider, ILogger, IDisposable
{
private PackagesSearchNode _searchNode;
@@ -143,6 +143,14 @@ public virtual IEnumerable<string> SupportedFrameworks
}
}
+ public virtual bool SupportsExecuteAllCommand
+ {
+ get
+ {
+ return false;
+ }
+ }
+
public override IVsExtensionsTreeNode ExtensionsTree
{
get
@@ -249,7 +257,6 @@ protected internal virtual void RemoveSearchNode()
{
if (_searchNode != null)
{
-
// When remove the search node, the dialog will automatically select the first node (All node)
// Since we are going to restore the previously selected node anyway, we don't want the first node
// to refresh. Hence suppress it here.
@@ -330,7 +337,7 @@ public virtual void Execute(PackageItem item)
OperationCoordinator.IsBusy = true;
_readmeFile = null;
- _originalPackageId = item.Id;
+ _originalPackageId = item != null ? item.Id : null;
_progressProvider.ProgressAvailable += OnProgressAvailable;
_uiCulture = System.Threading.Thread.CurrentThread.CurrentUICulture;
@@ -348,8 +355,11 @@ public virtual void Execute(PackageItem item)
worker.RunWorkerAsync(item);
// write an introductory sentence before every operation starts to make the console easier to read
- string progressMessage = GetProgressMessage(item.PackageIdentity);
- WriteLineToOutputWindow("------- " + progressMessage + " -------");
+ if (item != null)
+ {
+ string progressMessage = GetProgressMessage(item.PackageIdentity);
+ WriteLineToOutputWindow("------- " + progressMessage + " -------");
+ }
}
private void OnProgressAvailable(object sender, ProgressEventArgs e)
@@ -364,7 +374,7 @@ private void OnRunWorkerDoWork(object sender, DoWorkEventArgs e)
System.Threading.Thread.CurrentThread.CurrentCulture = _culture;
var item = (PackageItem)e.Argument;
- bool succeeded = ExecuteCore(item);
+ bool succeeded = item == null ? ExecuteAllCore() : ExecuteCore(item);
e.Cancel = !succeeded;
e.Result = item;
}
@@ -385,6 +395,13 @@ private void OnRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
OnExecuteCompleted((PackageItem)e.Result);
_providerServices.ProgressWindow.SetCompleted(successful: true);
+
+ // if this is an Execute All command, hide the Update All button after successful execution
+ if (SupportsExecuteAllCommand && e.Result == null)
+ {
+ _providerServices.UpdateAllUIService.Hide();
+ }
+
OpenReadMeFile();
CollapseNodes();
@@ -475,6 +492,11 @@ protected virtual bool ExecuteCore(PackageItem item)
return true;
}
+ protected virtual bool ExecuteAllCore()
+ {
+ return true;
+ }
+
protected virtual void OnExecuteCompleted(PackageItem item)
{
// After every operation, just update the status of all packages in the current node.
@@ -489,6 +511,10 @@ protected virtual void OnExecuteCompleted(PackageItem item)
}
}
+ public virtual void OnPackageLoadCompleted(PackagesTreeNodeBase selectedNode)
+ {
+ }
+
public virtual string NoItemsMessage
{
get
@@ -618,50 +644,47 @@ private Project FindProjectFromFileSystem(IFileSystem fileSystem)
return _solutionManager.GetProject(projectSystem.UniqueName);
}
- protected void CheckInstallPSScripts(
+ protected bool ShowLicenseAgreement(
IPackage package,
- IPackageRepository sourceRepository,
- FrameworkName targetFramework,
- bool includePrerelease,
+ IVsPackageManager packageManager,
+ IEnumerable<Project> projects,
out IList<PackageOperation> operations)
{
- CheckInstallPSScripts(
- package,
- LocalRepository,
- sourceRepository,
- targetFramework,
- includePrerelease,
- out operations);
+ var allOperations = new List<PackageOperation>();
+
+ foreach (Project project in projects)
+ {
+ var walker = new InstallWalker(
+ packageManager.GetProjectManager(project).LocalRepository,
+ packageManager.SourceRepository,
+ project.GetTargetFrameworkName(),
+ this,
+ ignoreDependencies: false,
+ allowPrereleaseVersions: IncludePrerelease);
+
+ allOperations.AddRange(walker.ResolveOperations(package));
+ }
+
+ operations = allOperations.Reduce();
+ return ShowLicenseAgreement(packageManager, operations);
}
- protected void CheckInstallPSScripts(
+ protected bool ShowLicenseAgreement(
IPackage package,
- IPackageRepository localRepository,
- IPackageRepository sourceRepository,
+ IVsPackageManager packageManager,
FrameworkName targetFramework,
- bool includePrerelease,
- out IList<PackageOperation> operations)
+ out IList<PackageOperation> operations)
{
- // Review: Is there any way the user could get into a position that we would need to allow pre release versions here?
var walker = new InstallWalker(
- localRepository,
- sourceRepository,
+ LocalRepository,
+ packageManager.SourceRepository,
targetFramework,
this,
ignoreDependencies: false,
- allowPrereleaseVersions: includePrerelease);
+ allowPrereleaseVersions: IncludePrerelease);
operations = walker.ResolveOperations(package).ToList();
- var scriptPackages = from o in operations
- where o.Package.HasPowerShellScript()
- select o.Package;
- if (scriptPackages.Any())
- {
- if (!RegistryHelper.CheckIfPowerShell2Installed())
- {
- throw new InvalidOperationException(Resources.Dialog_PackageHasPSScript);
- }
- }
+ return ShowLicenseAgreement(packageManager, operations);
}
protected bool ShowLicenseAgreement(IVsPackageManager packageManager, IEnumerable<PackageOperation> operations)
@@ -678,7 +701,8 @@ protected bool ShowLicenseAgreement(IVsPackageManager packageManager, IEnumerabl
// hide the progress window if we are going to show license window
HideProgressWindow();
- bool accepted = _providerServices.UserNotifierServices.ShowLicenseWindow(licensePackages);
+ bool accepted = _providerServices.UserNotifierServices.ShowLicenseWindow(
+ licensePackages.Distinct(PackageEqualityComparer.IdAndVersion));
if (!accepted)
{
return false;
View
29 src/Dialog10/Providers/SolutionInstalledProvider.cs
@@ -117,7 +117,7 @@ protected override bool ExecuteCore(PackageItem item)
}
}
- removeDepedencies = AskRemoveDependencyAndCheckUninstallPSScript(package, uninstallRepositories, uninstallFrameworks);
+ removeDepedencies = AskRemoveDependency(package, uninstallRepositories, uninstallFrameworks);
if (removeDepedencies == null)
{
// user cancels the operation.
@@ -132,7 +132,7 @@ protected override bool ExecuteCore(PackageItem item)
// to avoid the package file being deleted before an install.
if (hasInstallWork)
{
- bool successful = InstallPackageIntoProjects(allProjects, selectedProjectsSet, package);
+ bool successful = InstallPackageIntoProjects(package, allProjects, selectedProjectsSet);
if (!successful)
{
return false;
@@ -158,27 +158,12 @@ protected override bool ExecuteCore(PackageItem item)
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "We don't want one failed project to affect the other projects.")]
- private bool InstallPackageIntoProjects(IList<Project> allProjects, HashSet<string> selectedProjectsSet, IPackage package)
+ private bool InstallPackageIntoProjects(IPackage package, IList<Project> allProjects, HashSet<string> selectedProjectsSet)
{
- var allOperations = new List<PackageOperation>();
- foreach (Project project in allProjects)
- {
- if (selectedProjectsSet.Contains(project.UniqueName))
- {
- IList<PackageOperation> operations;
- CheckInstallPSScripts(
- package,
- PackageManager.GetProjectManager(project).LocalRepository,
- PackageManager.SourceRepository,
- targetFramework: project.GetTargetFrameworkName(),
- includePrerelease: true,
- operations: out operations);
-
- allOperations.AddRange(operations);
- }
- }
+ var selectedProjects = allProjects.Where(p => selectedProjectsSet.Contains(p.UniqueName));
- bool accepted = ShowLicenseAgreement(PackageManager, allOperations.Reduce());
+ IList<PackageOperation> operations;
+ bool accepted = ShowLicenseAgreement(package, PackageManager, selectedProjects, out operations);
if (!accepted)
{
return false;
@@ -209,7 +194,7 @@ private bool InstallPackageIntoProjects(IList<Project> allProjects, HashSet<stri
private bool UninstallSolutionPackage(IPackage package)
{
CheckDependentPackages(package, LocalRepository, targetFramework: null);
- bool? result = AskRemoveDependencyAndCheckUninstallPSScript(
+ bool? result = AskRemoveDependency(
package,
new[] { LocalRepository },
new FrameworkName[] { null });
View
35 src/Dialog10/Providers/SolutionOnlineProvider.cs
@@ -80,6 +80,8 @@ protected override bool ExecuteCore(PackageItem item)
// save the checked state of projects so that we can restore them the next time
SaveProjectCheckStates(selectedProjectsList);
+
+ ShowProgressWindow();
}
else
{
@@ -88,8 +90,8 @@ protected override bool ExecuteCore(PackageItem item)
}
IList<PackageOperation> operations;
- bool acceptLicense = isProjectLevel ? CheckPSScriptAndShowLicenseAgreement(item, selectedProjectsList, _activePackageManager, out operations)
- : CheckPSScriptAndShowLicenseAgreement(item, _activePackageManager, out operations);
+ bool acceptLicense = isProjectLevel ? ShowLicenseAgreement(item.PackageIdentity, _activePackageManager, selectedProjectsList, out operations)
+ : ShowLicenseAgreement(item.PackageIdentity, _activePackageManager, targetFramework: null, operations: out operations);
if (!acceptLicense)
{
return false;
@@ -117,35 +119,6 @@ protected override bool ExecuteCore(PackageItem item)
}
}
- protected bool CheckPSScriptAndShowLicenseAgreement(
- PackageItem item, IList<Project> projects, IVsPackageManager packageManager, out IList<PackageOperation> operations)
- {
- ShowProgressWindow();
-
- // combine the operations of all selected project
- var allOperations = new List<PackageOperation>();
- foreach (Project project in projects)
- {
- IProjectManager projectManager = packageManager.GetProjectManager(project);
-
- IList<PackageOperation> projectOperations;
- CheckInstallPSScripts(
- item.PackageIdentity,
- projectManager.LocalRepository,
- packageManager.SourceRepository,
- project.GetTargetFrameworkName(),
- IncludePrerelease,
- out projectOperations);
-
- allOperations.AddRange(projectOperations);
- }
-
- // reduce the operations before checking for license agreements
- operations = allOperations.Reduce();
-
- return ShowLicenseAgreement(packageManager, operations);
- }
-
private void SaveProjectCheckStates(IList<Project> selectedProjects)
{
var selectedProjectSet = new HashSet<Project>(selectedProjects);
View
65 src/Dialog10/Providers/SolutionUpdatesProvider.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Linq;
using System.Windows;
using EnvDTE;
@@ -76,6 +77,8 @@ protected override bool ExecuteCore(PackageItem item)
{
return false;
}
+
+ ShowProgressWindow();
}
else
{
@@ -84,8 +87,8 @@ protected override bool ExecuteCore(PackageItem item)
}
IList<PackageOperation> operations;
- bool acceptLicense = isProjectLevel ? CheckPSScriptAndShowLicenseAgreement(item, selectedProjectsList, _activePackageManager, out operations)
- : CheckPSScriptAndShowLicenseAgreement(item, _activePackageManager, out operations);
+ bool acceptLicense = isProjectLevel ? ShowLicenseAgreement(item.PackageIdentity, _activePackageManager, selectedProjectsList, out operations)
+ : ShowLicenseAgreement(item.PackageIdentity, _activePackageManager, targetFramework: null, operations: out operations);
if (!acceptLicense)
{
@@ -126,41 +129,45 @@ protected override bool ExecuteCore(PackageItem item)
}
}
- public override IVsExtension CreateExtension(IPackage package)
+ protected override bool ExecuteAllCore()
{
- return new PackageItem(this, package)
+ if (SelectedNode == null || SelectedNode.Extensions == null || SelectedNode.Extensions.Count == 0)
{
- CommandName = Resources.Dialog_UpdateButton
- };
- }
+ return false;
+ }
- protected bool CheckPSScriptAndShowLicenseAgreement(
- PackageItem item, IList<Project> projects, IVsPackageManager packageManager, out IList<PackageOperation> operations)
- {
ShowProgressWindow();
- // combine the operations of all selected project
- var allOperations = new List<PackageOperation>();
- foreach (Project project in projects)
+ _activePackageManager = GetActivePackageManager();
+ Debug.Assert(_activePackageManager != null);
+
+ IDisposable action = _activePackageManager.SourceRepository.StartOperation(OperationName);
+
+ try
{
- IProjectManager projectManager = packageManager.GetProjectManager(project);
-
- IList<PackageOperation> projectOperations;
- CheckInstallPSScripts(
- item.PackageIdentity,
- projectManager.LocalRepository,
- packageManager.SourceRepository,
- project.GetTargetFrameworkName(),
- IncludePrerelease,
- out projectOperations);
-
- allOperations.AddRange(projectOperations);
+ bool accepted = ShowLicenseAgreementForAllPackages(_activePackageManager);
+ if (!accepted)
+ {
+ return false;
+ }
+
+ RegisterPackageOperationEvents(_activePackageManager, null);
+ _activePackageManager.UpdatePackages(updateDependencies: true, allowPrereleaseVersions: IncludePrerelease, logger: this, eventListener: this);
+ return true;
}
+ finally
+ {
+ UnregisterPackageOperationEvents(_activePackageManager, null);
+ action.Dispose();
+ }
+ }
- // reduce the operations before checking for license agreements
- operations = allOperations.Reduce();
-
- return ShowLicenseAgreement(packageManager, operations);
+ public override IVsExtension CreateExtension(IPackage package)
+ {
+ return new PackageItem(this, package)
+ {
+ CommandName = Resources.Dialog_UpdateButton
+ };
}
public void OnBeforeAddPackageReference(Project project)
View
95 src/Dialog10/Providers/UpdatesProvider.cs
@@ -1,17 +1,19 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Linq;
using System.Windows;
using EnvDTE;
using Microsoft.VisualStudio.ExtensionsExplorer;
+using NuGet.Dialog.PackageManagerUI;
using NuGet.VisualStudio;
-using System.Diagnostics;
namespace NuGet.Dialog.Providers
{
internal class UpdatesProvider : OnlineProvider
{
private readonly Project _project;
+ private readonly IUpdateAllUIService _updateAllUIService;
public UpdatesProvider(
Project project,
@@ -35,6 +37,7 @@ internal class UpdatesProvider : OnlineProvider
solutionManager)
{
_project = project;
+ _updateAllUIService = providerServices.UpdateAllUIService;
}
public override string Name
@@ -61,6 +64,14 @@ public override bool RefreshOnNodeSelection
}
}
+ public override bool SupportsExecuteAllCommand
+ {
+ get
+ {
+ return true;
+ }
+ }
+
public override string OperationName
{
get
@@ -103,7 +114,87 @@ public override bool CanExecute(PackageItem item)
protected override void ExecuteCommand(IProjectManager projectManager, PackageItem item, IVsPackageManager activePackageManager, IList<PackageOperation> operations)
{
- activePackageManager.UpdatePackage(projectManager, item.PackageIdentity, operations, updateDependencies: true, allowPrereleaseVersions: IncludePrerelease, logger: this);
+ activePackageManager.UpdatePackage(
+ projectManager,
+ item.PackageIdentity,
+ operations,
+ updateDependencies: true,
+ allowPrereleaseVersions: IncludePrerelease,
+ logger: this);
+ }
+
+ protected override bool ExecuteAllCore()
+ {
+ if (SelectedNode == null || SelectedNode.Extensions == null || SelectedNode.Extensions.Count == 0)
+ {
+ return false;
+ }
+
+ ShowProgressWindow();
+
+ IVsPackageManager activePackageManager = GetActivePackageManager();
+ Debug.Assert(activePackageManager != null);
+
+ IDisposable action = activePackageManager.SourceRepository.StartOperation(OperationName);
+ IProjectManager projectManager = activePackageManager.GetProjectManager(_project);
+
+ try
+ {
+ bool accepted = ShowLicenseAgreementForAllPackages(activePackageManager);
+ if (!accepted)
+ {
+ return false;
+ }
+
+ RegisterPackageOperationEvents(activePackageManager, projectManager);
+ activePackageManager.UpdatePackages(projectManager, updateDependencies: true, allowPrereleaseVersions: IncludePrerelease, logger: this);
+ return true;
+ }
+ finally
+ {
+ UnregisterPackageOperationEvents(activePackageManager, projectManager);
+ action.Dispose();
+ }
+ }
+
+ protected bool ShowLicenseAgreementForAllPackages(IVsPackageManager activePackageManager)
+ {
+ var allOperations = new List<PackageOperation>();
+
+ var allPackages = SelectedNode.GetPackages(String.Empty, IncludePrerelease).ToList();
+ foreach (var package in allPackages)
+ {
+ var installWalker = new InstallWalker(
+ LocalRepository,
+ activePackageManager.SourceRepository,
+ _project.GetTargetFrameworkName(),
+ logger: this,
+ ignoreDependencies: false,
+ allowPrereleaseVersions: IncludePrerelease);
+
+ var operations = installWalker.ResolveOperations(package);
+ allOperations.AddRange(operations);
+ }
+
+ return ShowLicenseAgreement(activePackageManager, allOperations.Reduce());
+ }
+
+ public override void OnPackageLoadCompleted(PackagesTreeNodeBase selectedNode)
+ {
+ base.OnPackageLoadCompleted(selectedNode);
+ UpdateNumberOfPackages(selectedNode);
+ }
+
+ private void UpdateNumberOfPackages(PackagesTreeNodeBase selectedNode)
+ {
+ if (selectedNode != null && !selectedNode.IsSearchResultsNode && selectedNode.TotalNumberOfPackages > 1)
+ {
+ _updateAllUIService.Show();
+ }
+ else
+ {
+ _updateAllUIService.Hide();
+ }
}
public override IVsExtension CreateExtension(IPackage package)
View
9 src/DialogServices/DialogServices.csproj
@@ -49,6 +49,10 @@
</Compile>
<Compile Include="PackageManagerUI\Controls\TextBlockControl.cs" />
<Compile Include="PackageManagerUI\Converters\DescriptionLabelConverter.cs" />
+ <Compile Include="PackageManagerUI\IUpdateAllUIService.cs" />
+ <Compile Include="PackageManagerUI\UpdateAllUI.xaml.cs">
+ <DependentUpon>UpdateAllUI.xaml</DependentUpon>
+ </Compile>
<Compile Include="QueryExtensions.cs" />
<Compile Include="PackageManagerUI\IProviderSettings.cs" />
<Compile Include="NativeMethods.cs" />
@@ -97,6 +101,7 @@
<Compile Include="SolutionExplorer\SolutionExplorerViewModel.cs" />
<Compile Include="SolutionExplorer\SolutionWalker.cs" />
<Compile Include="UIResources.cs" />
+ <Compile Include="PackageManagerUI\UpdateAllUIService.cs" />
<Compile Include="Visualizer\Visualizer.cs" />
<Compile Include="WindowSizePersistenceHelper.cs" />
</ItemGroup>
@@ -120,6 +125,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
+ <Page Include="PackageManagerUI\UpdateAllUI.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
<Page Include="SolutionExplorer\SolutionExplorer.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
View
11 src/DialogServices/PackageManagerUI/IUpdateAllUIService.cs
@@ -0,0 +1,11 @@
+
+namespace NuGet.Dialog.PackageManagerUI
+{
+ public interface IUpdateAllUIService
+ {
+ void Show();
+ void Hide();
+ UpdateAllUI CreateUIElement();
+ void DisposeElement();
+ }
+}
View
4 src/DialogServices/PackageManagerUI/ProviderServices.cs
@@ -11,11 +11,13 @@ public sealed class ProviderServices
public IOutputConsoleProvider OutputConsoleProvider { get; set; }
public IProviderSettings ProviderSettings { get; private set; }
public IVsCommonOperations VsCommonOperations { get; private set; }
+ public IUpdateAllUIService UpdateAllUIService { get; private set; }
public ProviderServices() :
this(new UserNotifierServices(),
new ProgressWindowOpener(),
new ProviderSettingsManager(),
+ new UpdateAllUIService(),
ServiceLocator.GetInstance<IScriptExecutor>(),
ServiceLocator.GetInstance<IOutputConsoleProvider>(),
ServiceLocator.GetInstance<IVsCommonOperations>())
@@ -26,6 +28,7 @@ public sealed class ProviderServices
IUserNotifierServices userNotifierServices,
IProgressWindowOpener progressWindow,
IProviderSettings selectedProviderSettings,
+ IUpdateAllUIService updateAllUIService,
IScriptExecutor scriptExecutor,
IOutputConsoleProvider outputConsoleProvider,
IVsCommonOperations vsCommonOperations)
@@ -36,6 +39,7 @@ public sealed class ProviderServices
OutputConsoleProvider = outputConsoleProvider;
ProviderSettings = selectedProviderSettings;
VsCommonOperations = vsCommonOperations;
+ UpdateAllUIService = updateAllUIService;
}
}
}
View
28 src/DialogServices/PackageManagerUI/UpdateAllUI.xaml
@@ -0,0 +1,28 @@
+<UserControl x:Class="NuGet.Dialog.PackageManagerUI.UpdateAllUI"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ mc:Ignorable="d"
+ xmlns:self="clr-namespace:NuGet.Dialog.PackageManagerUI"
+ xmlns:local="clr-namespace:NuGet.Dialog"
+ xmlns:vsfx="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.10.0"
+ d:DesignHeight="30" d:DesignWidth="400">
+ <DockPanel LastChildFill="True">
+ <Button
+ x:Name="UpdateButton"
+ Content="{x:Static local:Resources.Dialog_UpdateAllButton}"
+ MinWidth="75"
+ MinHeight="23"
+ Margin="5,0,25,0"
+ Command="Cut"
+ DockPanel.Dock="Right">
+ </Button>
+
+ <self:TextBlockControl
+ Foreground="{DynamicResource {x:Static vsfx:VsBrushes.WindowTextKey}}"
+ Text="{x:Static local:Resources.Dialog_UpdateAllLabel}"
+ HorizontalAlignment="Left"
+ VerticalAlignment="Center" />
+ </DockPanel>
+</UserControl>
View
28 src/DialogServices/PackageManagerUI/UpdateAllUI.xaml.cs
@@ -0,0 +1,28 @@
+using System.Windows;
+using System.Windows.Controls;
+
+namespace NuGet.Dialog.PackageManagerUI
+{
+ /// <summary>
+ /// Interaction logic for UpdateAllUI.xaml
+ /// </summary>
+ public partial class UpdateAllUI : UserControl
+ {
+ public UpdateAllUI()
+ {
+ InitializeComponent();
+ }
+
+ public event RoutedEventHandler UpdateInvoked
+ {
+ add
+ {
+ UpdateButton.Click += value;
+ }
+ remove
+ {
+ UpdateButton.Click -= value;
+ }
+ }
+ }
+}
View
41 src/DialogServices/PackageManagerUI/UpdateAllUIService.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Windows;
+
+namespace NuGet.Dialog.PackageManagerUI
+{
+ public class UpdateAllUIService : IUpdateAllUIService
+ {
+ private UpdateAllUI _currentElement;
+
+ public void Show()
+ {
+ if (_currentElement == null)
+ {
+ throw new InvalidOperationException();
+ }
+
+ _currentElement.Visibility = Visibility.Visible;
+ }
+
+ public void Hide()
+ {
+ if (_currentElement != null)
+ {
+ _currentElement.Visibility = Visibility.Collapsed;
+ }
+ }
+
+ public UpdateAllUI CreateUIElement()
+ {
+ return _currentElement = new UpdateAllUI
+ {
+ Visibility = Visibility.Collapsed
+ };
+ }
+
+ public void DisposeElement()
+ {
+ _currentElement = null;
+ }
+ }
+}
View
36 src/DialogServices/Resources.Designer.cs
@@ -295,15 +295,6 @@ public class Resources {
}
/// <summary>
- /// Looks up a localized string similar to This package (or one of its dependencies) contains PowerShell scripts but the PowerShell 2.0 (or newer) runtime is not installed on this machine..
- /// </summary>
- public static string Dialog_PackageHasPSScript {
- get {
- return ResourceManager.GetString("Dialog_PackageHasPSScript", resourceCulture);
- }
- }
-
- /// <summary>
/// Looks up a localized string similar to This package is already installed..
/// </summary>
public static string Dialog_PackageInstalledTooltip {
@@ -538,6 +529,24 @@ public class Resources {
}
/// <summary>
+ /// Looks up a localized string similar to Update _All.
+ /// </summary>
+ public static string Dialog_UpdateAllButton {
+ get {
+ return ResourceManager.GetString("Dialog_UpdateAllButton", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to There are more than 1 update available..
+ /// </summary>
+ public static string Dialog_UpdateAllLabel {
+ get {
+ return ResourceManager.GetString("Dialog_UpdateAllLabel", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to _Update.
/// </summary>
public static string Dialog_UpdateButton {
@@ -592,15 +601,6 @@ public class Resources {
}
/// <summary>
- /// Looks up a localized string similar to ({0} Votes).
- /// </summary>
- public static string Dialog_VotesCount {
- get {
- return ResourceManager.GetString("Dialog_VotesCount", resourceCulture);
- }
- }
-
- /// <summary>
/// Looks up a localized string similar to Error: {0}.
/// </summary>
public static string ErrorStringFormat {
View
12 src/DialogServices/Resources.resx
@@ -159,9 +159,6 @@
<data name="Dialog_PackageDisclaimer" xml:space="preserve">
<value>Each item above may have sub-dependencies subject to additional license agreements.</value>
</data>
- <data name="Dialog_PackageHasPSScript" xml:space="preserve">
- <value>This package (or one of its dependencies) contains PowerShell scripts but the PowerShell 2.0 (or newer) runtime is not installed on this machine.</value>
- </data>
<data name="Dialog_PackageInstalledTooltip" xml:space="preserve">
<value>This package is already installed.</value>
</data>
@@ -216,9 +213,6 @@
<data name="Dialog_VersionLabel" xml:space="preserve">
<value>Version:</value>
</data>
- <data name="Dialog_VotesCount" xml:space="preserve">
- <value>({0} Votes)</value>
- </data>
<data name="License_Accept" xml:space="preserve">
<value>I _Accept</value>
</data>
@@ -345,4 +339,10 @@
<data name="Dialog_CurrentVersionLabel" xml:space="preserve">
<value>Installed version:</value>
</data>
+ <data name="Dialog_UpdateAllButton" xml:space="preserve">
+ <value>Update _All</value>
+ </data>
+ <data name="Dialog_UpdateAllLabel" xml:space="preserve">
+ <value>There are more than 1 update available.</value>
+ </data>
</root>
View
1  test/Dialog.Test/InstalledProviderTest.cs
@@ -306,6 +306,7 @@ public void InstalledProviderUnsubscribeToEventWhenDisposed()
null,
mockProgressWindowOpener.Object,
new Mock<IProviderSettings>().Object,
+ new Mock<IUpdateAllUIService>().Object,
scriptExecutor,
new MockOutputConsoleProvider(),
new Mock<IVsCommonOperations>().Object
View
1  test/Dialog.Test/Mocks/MockPackagesProvider.cs
@@ -35,6 +35,7 @@ public MockPackagesProvider(IPackageRepository localRepository, IVsPackageManage
new Mock<IUserNotifierServices>().Object,
new Mock<IProgressWindowOpener>().Object,
new Mock<IProviderSettings>().Object,
+ new Mock<IUpdateAllUIService>().Object,
new Mock<IScriptExecutor>().Object,
new MockOutputConsoleProvider(),
new Mock<IVsCommonOperations>().Object),
View
1  test/Dialog.Test/OnlineProviderTest.cs
@@ -575,6 +575,7 @@ public void ExecuteMethodInstallPackagesWithInitScript()
mockWindowServices.Object,
mockProgressWindowOpener.Object,
new Mock<IProviderSettings>().Object,
+ new Mock<IUpdateAllUIService>().Object,
scriptExecutor,
new MockOutputConsoleProvider(),
new Mock<IVsCommonOperations>().Object
View
4 test/Dialog.Test/OnlineSearchProviderTest.cs
@@ -19,7 +19,7 @@ public void IncludePreleaseVersionPropertyGetterReturnsTheValueOfBaseProvider(bo
var baseProvider = new Mock<PackagesProviderBase>(
new MockPackageRepository(),
new ResourceDictionary(),
- new ProviderServices(null, null, null, null, null, null),
+ new ProviderServices(null, null, null, null, null, null, null),
new Mock<IProgressProvider>().Object,
new Mock<ISolutionManager>().Object);
@@ -42,7 +42,7 @@ public void IncludePreleaseVersionPropertySetterSetsTheValueOfBaseProvider(bool
var baseProvider = new Mock<PackagesProviderBase>(
new MockPackageRepository(),
new ResourceDictionary(),
- new ProviderServices(null, null, null, null, null, null),
+ new ProviderServices(null, null, null, null, null, null, null),
new Mock<IProgressProvider>().Object,
new Mock<ISolutionManager>().Object);
baseProvider.SetupSet(p => p.IncludePrerelease = includePrerelease).Callback<bool>(a => assignedValue = a);
View
3  test/Dialog.Test/PackagesProviderBaseTest.cs
@@ -180,7 +180,8 @@ private class ConcretePackagesProvider : PackagesProviderBase
new ProviderServices(
new Mock<IUserNotifierServices>().Object,
new Mock<IProgressWindowOpener>().Object,
- new Mock<IProviderSettings>().Object,
+ new Mock<IProviderSettings>().Object,
+ new Mock<IUpdateAllUIService>().Object,
new Mock<IScriptExecutor>().Object,
new MockOutputConsoleProvider(),
new Mock<IVsCommonOperations>().Object), new Mock<IProgressProvider>().Object, new Mock<ISolutionManager>().Object)
View
1  test/Dialog.Test/SolutionInstalledProviderTest.cs
@@ -525,6 +525,7 @@ public void SolutionInstalledProviderUnsubscribeToEventWhenDisposed()
userNotifierServices,
mockProgressWindowOpener.Object,
new Mock<IProviderSettings>().Object,
+ new Mock<IUpdateAllUIService>().Object,
scriptExecutor,
new MockOutputConsoleProvider(),
new Mock<IVsCommonOperations>().Object
View
1  test/Dialog.Test/SolutionOnlineProviderTest.cs
@@ -572,6 +572,7 @@ public void ExecuteMethodDoNotCallInstallPackageIfUserDoesNotSelectAnyProject()
userNotifierServices,
mockProgressWindowOpener.Object,
new Mock<IProviderSettings>().Object,
+ new Mock<IUpdateAllUIService>().Object,
scriptExecutor,
new MockOutputConsoleProvider(),
new Mock<IVsCommonOperations>().Object
View
1  test/Dialog.Test/SolutionUpdatesProviderTest.cs
@@ -348,6 +348,7 @@ public void ExecuteUninstallsSolutionLevelPackageWhenUpdating()
userNotifierServices,
mockProgressWindowOpener.Object,
new Mock<IProviderSettings>().Object,
+ new Mock<IUpdateAllUIService>().Object,
scriptExecutor,
new MockOutputConsoleProvider(),
new Mock<IVsCommonOperations>().Object
View
1  test/Dialog.Test/UpdatesProviderTest.cs
@@ -392,6 +392,7 @@ public void ExecuteMethodInvokeInstallScriptAndUninstallScript()
userNotifierServices,
mockProgressWindowOpener.Object,
new Mock<IProviderSettings>().Object,
+ new Mock<IUpdateAllUIService>().Object,
scriptExecutor,
new MockOutputConsoleProvider(),
new Mock<IVsCommonOperations>().Object
Please sign in to comment.
Something went wrong with that request. Please try again.