Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Supporting installing a NuGet package into selected projects in one s…

…tep.
  • Loading branch information...
commit 051bda8c6a7e6ddae9ca456a501d24f01919bfd2 1 parent a70cd67
@mrward mrward authored
Showing with 3,134 additions and 287 deletions.
  1. +15 −3 src/AddIns/Misc/PackageManagement/Project/PackageManagement.addin
  2. +21 −1 src/AddIns/Misc/PackageManagement/Project/PackageManagement.csproj
  3. +42 −0 src/AddIns/Misc/PackageManagement/Project/Src/Design/DesignTimeSelectProjectsViewModel.cs
  4. +5 −0 src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeInstallPackageAction.cs
  5. +22 −11 src/AddIns/Misc/PackageManagement/Project/Src/Design/FakePackageManagementProject.cs
  6. +62 −2 src/AddIns/Misc/PackageManagement/Project/Src/Design/FakePackageManagementSolution.cs
  7. +24 −0 src/AddIns/Misc/PackageManagement/Project/Src/Design/FakePackageOperation.cs
  8. +57 −0 src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeSelectedProject.cs
  9. +2 −0  src/AddIns/Misc/PackageManagement/Project/Src/IPackageManagementEvents.cs
  10. +1 −1  src/AddIns/Misc/PackageManagement/Project/Src/IPackageManagementProject.cs
  11. +17 −0 src/AddIns/Misc/PackageManagement/Project/Src/IPackageManagementSelectedProject.cs
  12. +10 −0 src/AddIns/Misc/PackageManagement/Project/Src/IPackageManagementSolution.cs
  13. +1 −1  src/AddIns/Misc/PackageManagement/Project/Src/IPackageManagerFactory.cs
  14. +13 −0 src/AddIns/Misc/PackageManagement/Project/Src/ISelectProjectsService.cs
  15. +9 −1 src/AddIns/Misc/PackageManagement/Project/Src/{Scripting → }/ISolutionPackageRepository.cs
  16. +13 −0 src/AddIns/Misc/PackageManagement/Project/Src/ISolutionPackageRepositoryFactory.cs
  17. +6 −3 src/AddIns/Misc/PackageManagement/Project/Src/InstalledPackagesViewModel.cs
  18. +61 −0 src/AddIns/Misc/PackageManagement/Project/Src/ManagePackagesUserPrompts.cs
  19. +27 −41 src/AddIns/Misc/PackageManagement/Project/Src/ManagePackagesViewModel.cs
  20. +24 −0 src/AddIns/Misc/PackageManagement/Project/Src/ManagePackagesViewTitle.cs
  21. +12 −0 src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementEvents.cs
  22. +1 −1  src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementProject.cs
  23. +29 −0 src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementSelectedProject.cs
  24. +136 −0 src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementSelectedProjects.cs
  25. +8 −3 src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementServices.cs
  26. +64 −12 src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementSolution.cs
  27. +30 −14 src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementViewModels.cs
  28. +130 −17 src/AddIns/Misc/PackageManagement/Project/Src/PackageViewModel.cs
  29. +8 −0 src/AddIns/Misc/PackageManagement/Project/Src/PackageViewModelOperationLogger.cs
  30. +28 −0 src/AddIns/Misc/PackageManagement/Project/Src/PackagesView.xaml
  31. +46 −0 src/AddIns/Misc/PackageManagement/Project/Src/PackagesViewModels.cs
  32. +20 −0 src/AddIns/Misc/PackageManagement/Project/Src/SelectProjectsEventArgs.cs
  33. +45 −0 src/AddIns/Misc/PackageManagement/Project/Src/SelectProjectsService.cs
  34. +69 −0 src/AddIns/Misc/PackageManagement/Project/Src/SelectProjectsView.xaml
  35. +21 −0 src/AddIns/Misc/PackageManagement/Project/Src/SelectProjectsView.xaml.cs
  36. +36 −0 src/AddIns/Misc/PackageManagement/Project/Src/SelectProjectsViewModel.cs
  37. +5 −6 src/AddIns/Misc/PackageManagement/Project/Src/SharpDevelopPackageManager.cs
  38. +10 −21 src/AddIns/Misc/PackageManagement/Project/Src/SharpDevelopPackageManagerFactory.cs
  39. +24 −1 src/AddIns/Misc/PackageManagement/Project/Src/SolutionPackageRepository.cs
  40. +34 −0 src/AddIns/Misc/PackageManagement/Project/Src/SolutionPackageRepositoryFactory.cs
  41. +10 −0 src/AddIns/Misc/PackageManagement/Project/Src/ThreadSafePackageManagementEvents.cs
  42. +18 −4 src/AddIns/Misc/PackageManagement/Project/Src/UpdatedPackages.cs
  43. +8 −2 src/AddIns/Misc/PackageManagement/Project/Src/UpdatedPackagesViewModel.cs
  44. +6 −0 src/AddIns/Misc/PackageManagement/Test/PackageManagement.Tests.csproj
  45. +13 −2 src/AddIns/Misc/PackageManagement/Test/Src/Helpers/ExceptionThrowingPackageManagementProject.cs
  46. +1 −1  src/AddIns/Misc/PackageManagement/Test/Src/Helpers/FakeLicenseAcceptanceService.cs
  47. +6 −0 src/AddIns/Misc/PackageManagement/Test/Src/Helpers/FakeLogger.cs
  48. +8 −0 src/AddIns/Misc/PackageManagement/Test/Src/Helpers/FakePackageActionRunner.cs
  49. +37 −4 src/AddIns/Misc/PackageManagement/Test/Src/Helpers/FakePackageManagementEvents.cs
  50. +2 −2 src/AddIns/Misc/PackageManagement/Test/Src/Helpers/FakePackageManagerFactory.cs
  51. +23 −0 src/AddIns/Misc/PackageManagement/Test/Src/Helpers/FakeSelectProjectsService.cs
  52. +29 −3 src/AddIns/Misc/PackageManagement/Test/Src/Helpers/FakeSolutionPackageRepository.cs
  53. +21 −0 src/AddIns/Misc/PackageManagement/Test/Src/Helpers/FakeSolutionPackageRepositoryFactory.cs
  54. +32 −0 src/AddIns/Misc/PackageManagement/Test/Src/Helpers/SelectedProjectCollectionAssert.cs
  55. +4 −3 src/AddIns/Misc/PackageManagement/Test/Src/Helpers/TestablePackageViewModel.cs
  56. +2 −2 src/AddIns/Misc/PackageManagement/Test/Src/InstallPackageActionTests.cs
  57. +29 −0 src/AddIns/Misc/PackageManagement/Test/Src/InstalledPackagesViewModelTests.cs
  58. +105 −18 src/AddIns/Misc/PackageManagement/Test/Src/ManagePackagesViewModelTests.cs
  59. +72 −0 src/AddIns/Misc/PackageManagement/Test/Src/PackageManagementEventsTests.cs
  60. +3 −3 src/AddIns/Misc/PackageManagement/Test/Src/PackageManagementProjectTests.cs
  61. +39 −0 src/AddIns/Misc/PackageManagement/Test/Src/PackageManagementSelectedProjectTests.cs
  62. +445 −0 src/AddIns/Misc/PackageManagement/Test/Src/PackageManagementSelectedProjectsTests.cs
  63. +202 −25 src/AddIns/Misc/PackageManagement/Test/Src/PackageManagementSolutionTests.cs
  64. +641 −67 src/AddIns/Misc/PackageManagement/Test/Src/PackageViewModelTests.cs
  65. +2 −2 src/AddIns/Misc/PackageManagement/Test/Src/Scripting/PackageManagementConsoleHostTests.cs
  66. +54 −0 src/AddIns/Misc/PackageManagement/Test/Src/SelectProjectsViewModelTests.cs
  67. +6 −3 src/AddIns/Misc/PackageManagement/Test/Src/SharpDevelopPackageManagerTests.cs
  68. +40 −0 src/AddIns/Misc/PackageManagement/Test/Src/SolutionPackageRepositoryTests.cs
  69. +51 −2 src/AddIns/Misc/PackageManagement/Test/Src/ThreadSafePackageManagementEventsTests.cs
  70. +37 −5 src/AddIns/Misc/PackageManagement/Test/Src/UpdatedPackagesViewModelTests.cs
View
18 src/AddIns/Misc/PackageManagement/Project/PackageManagement.addin
@@ -20,7 +20,7 @@
<Condition name="WriteableProject" action="Disable">
<MenuItem
id="ManagePackages"
- label="Manage Packages"
+ label="Manage Packages..."
insertafter="AddWebReference"
insertbefore="AddSeparator"
class="ICSharpCode.PackageManagement.ManagePackagesCommand"/>
@@ -32,7 +32,7 @@
<Condition name="WriteableProject" action="Disable">
<MenuItem
id="ManagePackages"
- label="Manage Packages"
+ label="Manage Packages..."
insertafter="AddWebReference"
insertbefore="AddSeparator"
class="ICSharpCode.PackageManagement.ManagePackagesCommand"/>
@@ -44,12 +44,24 @@
<Condition name="WriteableProject" action="Disable">
<MenuItem
id="ManagePackages"
- label="Manage Packages"
+ label="Manage Packages..."
insertafter="AddWebReference"
insertbefore="AddSeparator"
class="ICSharpCode.PackageManagement.ManagePackagesCommand"/>
</Condition>
</Path>
+
+ <!-- Projects window context menu - solution selected -->
+ <Path path="/SharpDevelop/Pads/ProjectBrowser/ContextMenu/SolutionNode">
+ <Condition name="WriteableSolution" action="Disable">
+ <MenuItem
+ id="ManagePackagesForSolution"
+ label="Manage Packages..."
+ insertafter="CombineAddMenu"
+ insertbefore="AddSeparator"
+ class="ICSharpCode.PackageManagement.ManagePackagesCommand"/>
+ </Condition>
+ </Path>
<!-- Tools options -->
<Path name="/SharpDevelop/Dialogs/OptionsDialog">
View
22 src/AddIns/Misc/PackageManagement/Project/PackageManagement.csproj
@@ -70,6 +70,13 @@
</Compile>
<Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="Src\AcceptLicensesEventArgs.cs" />
+ <Compile Include="Src\Design\DesignTimeSelectProjectsViewModel.cs" />
+ <Compile Include="Src\Design\FakePackageOperation.cs" />
+ <Compile Include="Src\Design\FakeSelectedProject.cs" />
+ <Compile Include="Src\IPackageManagementSelectedProject.cs" />
+ <Compile Include="Src\ISelectProjectsService.cs" />
+ <Compile Include="Src\ISolutionPackageRepository.cs" />
+ <Compile Include="Src\ISolutionPackageRepositoryFactory.cs" />
<Compile Include="Src\ManagePackagesCommand.cs" />
<Compile Include="Src\AggregateExceptionErrorMessage.cs" />
<Compile Include="Src\ConsolePackageActionRunner.cs" />
@@ -122,6 +129,8 @@
<Compile Include="Src\IPropertyService.cs" />
<Compile Include="Src\ISettingsFactory.cs" />
<Compile Include="Src\IThreadSafePackageManagementEvents.cs" />
+ <Compile Include="Src\ManagePackagesUserPrompts.cs" />
+ <Compile Include="Src\ManagePackagesViewTitle.cs" />
<Compile Include="Src\NewProjectsCreated.cs" />
<Compile Include="Src\OpenMSBuildProjects.cs" />
<Compile Include="Src\PackageActionRunner.cs" />
@@ -134,6 +143,8 @@
<Compile Include="Src\PackageManagementProject.cs" />
<Compile Include="Src\PackageManagementProjectFactory.cs" />
<Compile Include="Src\PackageManagementPropertyService.cs" />
+ <Compile Include="Src\PackageManagementSelectedProject.cs" />
+ <Compile Include="Src\PackageManagementSelectedProjects.cs" />
<Compile Include="Src\PackageManagementWorkbench.cs" />
<Compile Include="Src\PackageOperationExceptionEventArgs.cs" />
<Compile Include="Src\PackageOperationMessage.cs" />
@@ -144,6 +155,7 @@
<Compile Include="Src\PackageReferenceInstaller.cs" />
<Compile Include="Src\PackageReferencesForProject.cs" />
<Compile Include="Src\PackageSourceExtensions.cs" />
+ <Compile Include="Src\PackagesViewModels.cs" />
<Compile Include="Src\PackageViewModelOperationLogger.cs" />
<Compile Include="Src\ParentPackageOperationEventArgs.cs" />
<Compile Include="Src\ProcessPackageOperationsAction.cs" />
@@ -249,7 +261,6 @@
<Compile Include="Src\Scripting\IPackageManagementConsoleHost.cs" />
<Compile Include="Src\Scripting\IPackageScriptRunner.cs" />
<Compile Include="Src\Scripting\IPowerShellDetection.cs" />
- <Compile Include="Src\Scripting\ISolutionPackageRepository.cs" />
<Compile Include="Src\Scripting\PackageInitializationScripts.cs" />
<Compile Include="Src\Scripting\PackageInitializationScriptsConsole.cs" />
<Compile Include="Src\Scripting\PackageInitializationScriptsFactory.cs" />
@@ -258,7 +269,15 @@
<Compile Include="Src\Scripting\PowerShellMissingConsoleHost.cs" />
<Compile Include="Src\Scripting\PowerShellWorkingDirectory.cs" />
<Compile Include="Src\Scripting\ResetPowerShellWorkingDirectoryOnSolutionClosed.cs" />
+ <Compile Include="Src\SelectProjectsEventArgs.cs" />
+ <Compile Include="Src\SelectProjectsService.cs" />
+ <Compile Include="Src\SelectProjectsView.xaml.cs">
+ <DependentUpon>SelectProjectsView.xaml</DependentUpon>
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Src\SelectProjectsViewModel.cs" />
<Compile Include="Src\SettingsFactory.cs" />
+ <Compile Include="Src\SolutionPackageRepositoryFactory.cs" />
<Compile Include="Src\SolutionPackageRepositoryPath.cs" />
<Compile Include="Src\PackageSourceConverter.cs" />
<Compile Include="Src\PackageSourceViewModel.cs" />
@@ -348,6 +367,7 @@
<Page Include="Src\PagedResultsView.xaml" />
<Page Include="Src\RegisteredProjectTemplatePackageSourcesView.xaml" />
<Page Include="Src\Scripting\PackageManagementConsoleView.xaml" />
+ <Page Include="Src\SelectProjectsView.xaml" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj">
View
42 src/AddIns/Misc/PackageManagement/Project/Src/Design/DesignTimeSelectProjectsViewModel.cs
@@ -0,0 +1,42 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Collections.ObjectModel;
+
+namespace ICSharpCode.PackageManagement.Design
+{
+ public class DesignTimeSelectProjectsViewModel
+ {
+ public DesignTimeSelectProjectsViewModel()
+ {
+ Projects = new ObservableCollection<IPackageManagementSelectedProject>();
+ AddSelectedProject("AvalonEdit");
+ AddSelectedProject("ICSharpCode.SharpDevelop");
+ AddUnselectedProject("ICSharpCode.SharpDevelop.Dom");
+ AddUnselectedProject("ICSharpCode.SharpDevelop.Widgets");
+ AddSelectedProject("NRefactory");
+ }
+
+ void AddSelectedProject(string name)
+ {
+ AddProject(name, selected: true);
+ }
+
+ void AddUnselectedProject(string name)
+ {
+ AddProject(name, selected: false);
+ }
+
+ void AddProject(string name, bool selected)
+ {
+ var project = new FakeSelectedProject() {
+ Name = name,
+ IsSelected = selected
+ };
+ Projects.Add(project);
+ }
+
+ public ObservableCollection<IPackageManagementSelectedProject> Projects { get; private set; }
+ }
+}
View
5 src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeInstallPackageAction.cs
@@ -7,6 +7,11 @@ namespace ICSharpCode.PackageManagement.Design
{
public class FakeInstallPackageAction : InstallPackageAction
{
+ public FakeInstallPackageAction()
+ : this(null)
+ {
+ }
+
public FakeInstallPackageAction(IPackageManagementProject project)
: base(project, null)
{
View
33 src/AddIns/Misc/PackageManagement/Project/Src/Design/FakePackageManagementProject.cs
@@ -14,12 +14,17 @@ namespace ICSharpCode.PackageManagement.Design
public class FakePackageManagementProject : IPackageManagementProject
{
public FakePackageManagementProject()
+ : this("Test")
+ {
+ }
+
+ public FakePackageManagementProject(string name)
{
FakeInstallPackageAction = new FakeInstallPackageAction(this);
FakeUninstallPackageAction = new FakeUninstallPackageAction(this);
FakeUpdatePackageAction = new FakeUpdatePackageAction(this);
- Name = "Test";
+ this.Name = name;
}
public FakeInstallPackageAction FakeInstallPackageAction;
@@ -28,13 +33,9 @@ public FakePackageManagementProject()
public string Name { get; set; }
- public bool IsInstalledReturnValue;
- public IPackage PackagePassedToIsInstalled;
-
- public bool IsInstalled(IPackage package)
+ public bool IsPackageInstalled(IPackage package)
{
- PackagePassedToIsInstalled = package;
- return IsInstalledReturnValue;
+ return FakePackages.Contains(package);
}
public List<FakePackage> FakePackages = new List<FakePackage>();
@@ -44,11 +45,11 @@ public IQueryable<IPackage> GetPackages()
return FakePackages.AsQueryable();
}
- public List<PackageOperation> FakeInstallOperations = new List<PackageOperation>();
+ public List<FakePackageOperation> FakeInstallOperations = new List<FakePackageOperation>();
public IPackage PackagePassedToGetInstallPackageOperations;
public bool IgnoreDependenciesPassedToGetInstallPackageOperations;
- public IEnumerable<PackageOperation> GetInstallPackageOperations(IPackage package, bool ignoreDependencies)
+ public virtual IEnumerable<PackageOperation> GetInstallPackageOperations(IPackage package, bool ignoreDependencies)
{
PackagePassedToGetInstallPackageOperations = package;
IgnoreDependenciesPassedToGetInstallPackageOperations = ignoreDependencies;
@@ -69,10 +70,20 @@ public void InstallPackage(IPackage package, IEnumerable<PackageOperation> opera
IgnoreDependenciesPassedToInstallPackage = ignoreDependencies;
}
- public void AddFakeInstallOperation()
+ public FakePackageOperation AddFakeInstallOperation()
+ {
+ var package = new FakePackage("MyPackage");
+ var operation = new FakePackageOperation(package, PackageAction.Install);
+ FakeInstallOperations.Add(operation);
+ return operation;
+ }
+
+ public FakePackageOperation AddFakeUninstallOperation()
{
- var operation = new PackageOperation(new FakePackage(), PackageAction.Install);
+ var package = new FakePackage("MyPackage");
+ var operation = new FakePackageOperation(package, PackageAction.Uninstall);
FakeInstallOperations.Add(operation);
+ return operation;
}
public FakePackageRepository FakeSourceRepository = new FakePackageRepository();
View
64 src/AddIns/Misc/PackageManagement/Project/Src/Design/FakePackageManagementSolution.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using ICSharpCode.Core;
using ICSharpCode.PackageManagement;
using ICSharpCode.PackageManagement.Scripting;
@@ -43,6 +44,9 @@ public virtual IPackageManagementProject GetActiveProject(IPackageRepository sou
return FakeActiveProject;
}
+ public FakePackageManagementProject FakeProjectToReturnFromGetProject =
+ new FakePackageManagementProject();
+
public PackageSource PackageSourcePassedToGetProject;
public string ProjectNamePassedToGetProject;
@@ -50,7 +54,7 @@ public IPackageManagementProject GetProject(PackageSource source, string project
{
PackageSourcePassedToGetProject = source;
ProjectNamePassedToGetProject = projectName;
- return FakeActiveProject;
+ return FakeProjectToReturnFromGetProject;
}
public IPackageRepository RepositoryPassedToGetProject;
@@ -59,7 +63,31 @@ public IPackageManagementProject GetProject(IPackageRepository sourceRepository,
{
RepositoryPassedToGetProject = sourceRepository;
ProjectNamePassedToGetProject = projectName;
- return FakeActiveProject;
+ return FakeProjectToReturnFromGetProject;
+ }
+
+ public IProject ProjectPassedToGetProject;
+ public List<IProject> ProjectsPassedToGetProject = new List<IProject>();
+ public Dictionary<string, FakePackageManagementProject> FakeProjectsToReturnFromGetProject
+ = new Dictionary<string, FakePackageManagementProject>();
+
+ public IPackageManagementProject GetProject(IPackageRepository sourceRepository, IProject project)
+ {
+ RepositoryPassedToGetProject = sourceRepository;
+ ProjectPassedToGetProject = project;
+ ProjectsPassedToGetProject.Add(project);
+ FakePackageManagementProject fakeProject = null;
+ if (FakeProjectsToReturnFromGetProject.TryGetValue(project.Name, out fakeProject)) {
+ return fakeProject;
+ }
+ return FakeProjectToReturnFromGetProject;
+ }
+
+ public IProject FakeActiveMSBuildProject;
+
+ public IProject GetActiveMSBuildProject()
+ {
+ return FakeActiveMSBuildProject;
}
public List<IProject> FakeMSBuildProjects = new List<IProject>();
@@ -70,5 +98,37 @@ public IEnumerable<IProject> GetMSBuildProjects()
}
public bool IsOpen { get; set; }
+
+ public bool HasMultipleProjects()
+ {
+ return FakeMSBuildProjects.Count > 1;
+ }
+
+ public string FileName { get; set; }
+
+ public List<IPackage> FakeInstalledPackages = new List<IPackage>();
+
+ public bool IsPackageInstalled(IPackage package)
+ {
+ return FakeInstalledPackages.Contains(package);
+ }
+
+ public IQueryable<IPackage> GetPackages()
+ {
+ return FakeInstalledPackages.AsQueryable();
+ }
+
+ public void NoProjectsSelected()
+ {
+ FakeActiveProject = null;
+ FakeActiveMSBuildProject = null;
+ }
+
+ public FakePackageManagementProject AddFakeProjectToReturnFromGetProject(string name)
+ {
+ var project = new FakePackageManagementProject(name);
+ FakeProjectsToReturnFromGetProject.Add(name, project);
+ return project;
+ }
}
}
View
24 src/AddIns/Misc/PackageManagement/Project/Src/Design/FakePackageOperation.cs
@@ -0,0 +1,24 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using NuGet;
+
+namespace ICSharpCode.PackageManagement.Design
+{
+ public class FakePackageOperation : PackageOperation
+ {
+ public FakePackageOperation()
+ : this(new FakePackage("MyPackage"), PackageAction.Install)
+ {
+ }
+
+ public FakePackageOperation(FakePackage package, PackageAction action)
+ : base(package, action)
+ {
+ this.FakePackage = package;
+ }
+
+ public FakePackage FakePackage { get; set; }
+ }
+}
View
57 src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeSelectedProject.cs
@@ -0,0 +1,57 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Collections.Generic;
+using ICSharpCode.PackageManagement;
+using NuGet;
+
+namespace ICSharpCode.PackageManagement.Design
+{
+ public class FakeSelectedProject : IPackageManagementSelectedProject
+ {
+ public FakePackageManagementProject FakeProject = new FakePackageManagementProject();
+
+ public FakeSelectedProject()
+ {
+ }
+
+ public FakeSelectedProject(string name)
+ : this(name, false)
+ {
+ }
+
+ public FakeSelectedProject(string name, bool selected)
+ {
+ this.Name = name;
+ this.IsSelected = selected;
+ }
+
+ public string Name { get; set; }
+ public bool IsSelected { get; set; }
+
+ public override string ToString()
+ {
+ return String.Format("Name: {0}, IsSelected: {1}", Name, IsSelected);
+ }
+
+ public FakeInstallPackageAction FakeInstallPackageAction {
+ get { return FakeProject.FakeInstallPackageAction; }
+ set { FakeProject.FakeInstallPackageAction = value; }
+ }
+
+ public IPackageManagementProject Project {
+ get { return FakeProject; }
+ }
+
+ public FakePackageOperation AddFakeInstallPackageOperation()
+ {
+ return FakeProject.AddFakeInstallOperation();
+ }
+
+ public FakePackageOperation AddFakeUninstallPackageOperation()
+ {
+ return FakeProject.AddFakeUninstallOperation();
+ }
+ }
+}
View
2  src/AddIns/Misc/PackageManagement/Project/Src/IPackageManagementEvents.cs
@@ -11,6 +11,7 @@ public interface IPackageManagementEvents
{
event EventHandler PackageOperationsStarting;
event EventHandler<AcceptLicensesEventArgs> AcceptLicenses;
+ event EventHandler<SelectProjectsEventArgs> SelectProjects;
event EventHandler<PackageOperationExceptionEventArgs> PackageOperationError;
event EventHandler<ParentPackageOperationEventArgs> ParentPackageInstalled;
event EventHandler<ParentPackageOperationEventArgs> ParentPackageUninstalled;
@@ -22,5 +23,6 @@ public interface IPackageManagementEvents
void OnParentPackageInstalled(IPackage package);
void OnParentPackageUninstalled(IPackage package);
void OnPackageOperationMessageLogged(MessageLevel level, string message, params object[] args);
+ bool OnSelectProjects(IEnumerable<IPackageManagementSelectedProject> selectedProjects);
}
}
View
2  src/AddIns/Misc/PackageManagement/Project/Src/IPackageManagementProject.cs
@@ -23,7 +23,7 @@ public interface IPackageManagementProject
Project ConvertToDTEProject();
- bool IsInstalled(IPackage package);
+ bool IsPackageInstalled(IPackage package);
IQueryable<IPackage> GetPackages();
View
17 src/AddIns/Misc/PackageManagement/Project/Src/IPackageManagementSelectedProject.cs
@@ -0,0 +1,17 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Collections.Generic;
+using NuGet;
+
+namespace ICSharpCode.PackageManagement
+{
+ public interface IPackageManagementSelectedProject
+ {
+ string Name { get; }
+ bool IsSelected { get; set; }
+
+ IPackageManagementProject Project { get; }
+ }
+}
View
10 src/AddIns/Misc/PackageManagement/Project/Src/IPackageManagementSolution.cs
@@ -3,6 +3,8 @@
using System;
using System.Collections.Generic;
+using System.Linq;
+
using ICSharpCode.SharpDevelop.Project;
using NuGet;
@@ -14,8 +16,16 @@ public interface IPackageManagementSolution
IPackageManagementProject GetActiveProject(IPackageRepository sourceRepository);
IPackageManagementProject GetProject(PackageSource source, string projectName);
IPackageManagementProject GetProject(IPackageRepository sourceRepository, string projectName);
+ IPackageManagementProject GetProject(IPackageRepository sourceRepository, IProject project);
+
+ IProject GetActiveMSBuildProject();
IEnumerable<IProject> GetMSBuildProjects();
+ bool HasMultipleProjects();
+
+ bool IsPackageInstalled(IPackage package);
+ IQueryable<IPackage> GetPackages();
bool IsOpen { get; }
+ string FileName { get; }
}
}
View
2  src/AddIns/Misc/PackageManagement/Project/Src/IPackageManagerFactory.cs
@@ -10,7 +10,7 @@ namespace ICSharpCode.PackageManagement
public interface IPackageManagerFactory
{
ISharpDevelopPackageManager CreatePackageManager(
- IPackageRepository packageRepository,
+ IPackageRepository sourceRepository,
MSBuildBasedProject project);
}
}
View
13 src/AddIns/Misc/PackageManagement/Project/Src/ISelectProjectsService.cs
@@ -0,0 +1,13 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Collections.Generic;
+
+namespace ICSharpCode.PackageManagement
+{
+ public interface ISelectProjectsService
+ {
+ bool SelectProjects(IEnumerable<IPackageManagementSelectedProject> projects);
+ }
+}
View
10 ...oject/Src/Scripting/ISolutionPackageRepository.cs → ...agement/Project/Src/ISolutionPackageRepository.cs
@@ -3,13 +3,21 @@
using System;
using System.Collections.Generic;
+using System.Linq;
+
using NuGet;
-namespace ICSharpCode.PackageManagement.Scripting
+namespace ICSharpCode.PackageManagement
{
public interface ISolutionPackageRepository
{
string GetInstallPath(IPackage package);
IEnumerable<IPackage> GetPackagesByDependencyOrder();
+ IQueryable<IPackage> GetPackages();
+ bool IsInstalled(IPackage package);
+
+ ISharedPackageRepository Repository { get; }
+ IFileSystem FileSystem { get; }
+ IPackagePathResolver PackagePathResolver { get; }
}
}
View
13 src/AddIns/Misc/PackageManagement/Project/Src/ISolutionPackageRepositoryFactory.cs
@@ -0,0 +1,13 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using ICSharpCode.SharpDevelop.Project;
+
+namespace ICSharpCode.PackageManagement
+{
+ public interface ISolutionPackageRepositoryFactory
+ {
+ ISolutionPackageRepository CreateSolutionPackageRepository(Solution solution);
+ }
+}
View
9 src/AddIns/Misc/PackageManagement/Project/Src/InstalledPackagesViewModel.cs
@@ -13,7 +13,7 @@ public class InstalledPackagesViewModel : PackagesViewModel
IPackageManagementSolution solution;
IPackageManagementEvents packageManagementEvents;
IPackageManagementProject project;
- string errorMessage = String.Empty;
+ string errorMessage;
public InstalledPackagesViewModel(
IPackageManagementSolution solution,
@@ -53,10 +53,13 @@ protected override void OnDispose()
protected override IQueryable<IPackage> GetAllPackages()
{
- if (project == null) {
+ if (errorMessage != null) {
ThrowOriginalExceptionWhenTryingToGetProjectManager();
}
- return project.GetPackages();
+ if (project != null) {
+ return project.GetPackages();
+ }
+ return solution.GetPackages();
}
void ThrowOriginalExceptionWhenTryingToGetProjectManager()
View
61 src/AddIns/Misc/PackageManagement/Project/Src/ManagePackagesUserPrompts.cs
@@ -0,0 +1,61 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+
+namespace ICSharpCode.PackageManagement
+{
+ public class ManagePackagesUserPrompts
+ {
+ ILicenseAcceptanceService licenseAcceptanceService;
+ ISelectProjectsService selectProjectsService;
+ IPackageManagementEvents packageManagementEvents;
+
+ public ManagePackagesUserPrompts(IPackageManagementEvents packageManagementEvents)
+ : this(
+ packageManagementEvents,
+ new LicenseAcceptanceService(),
+ new SelectProjectsService())
+ {
+ }
+
+ public ManagePackagesUserPrompts(
+ IPackageManagementEvents packageManagementEvents,
+ ILicenseAcceptanceService licenseAcceptanceService,
+ ISelectProjectsService selectProjectsService)
+ {
+ this.packageManagementEvents = packageManagementEvents;
+ this.licenseAcceptanceService = licenseAcceptanceService;
+ this.selectProjectsService = selectProjectsService;
+
+ SubscribeToEvents();
+ }
+
+ void SubscribeToEvents()
+ {
+ packageManagementEvents.AcceptLicenses += AcceptLicenses;
+ packageManagementEvents.SelectProjects += SelectProjects;
+ }
+
+ void AcceptLicenses(object sender, AcceptLicensesEventArgs e)
+ {
+ e.IsAccepted = licenseAcceptanceService.AcceptLicenses(e.Packages);
+ }
+
+ void SelectProjects(object sender, SelectProjectsEventArgs e)
+ {
+ e.IsAccepted = selectProjectsService.SelectProjects(e.SelectedProjects);
+ }
+
+ public void Dispose()
+ {
+ UnsubscribeFromEvents();
+ }
+
+ public void UnsubscribeFromEvents()
+ {
+ packageManagementEvents.SelectProjects -= SelectProjects;
+ packageManagementEvents.AcceptLicenses -= AcceptLicenses;
+ }
+ }
+}
View
68 src/AddIns/Misc/PackageManagement/Project/Src/ManagePackagesViewModel.cs
@@ -12,64 +12,55 @@ namespace ICSharpCode.PackageManagement
{
public class ManagePackagesViewModel : ViewModelBase<ManagePackagesViewModel>, IDisposable
{
- IPackageManagementSolution solution;
IThreadSafePackageManagementEvents packageManagementEvents;
- ILicenseAcceptanceService licenseAcceptanceService;
+ ManagePackagesUserPrompts userPrompts;
+ PackagesViewModels packagesViewModels;
+ ManagePackagesViewTitle viewTitle;
string message;
bool hasError;
public ManagePackagesViewModel(
- IPackageManagementSolution solution,
- IRegisteredPackageRepositories registeredPackageRepositories,
+ PackagesViewModels packagesViewModels,
+ ManagePackagesViewTitle viewTitle,
IThreadSafePackageManagementEvents packageManagementEvents,
- IPackageActionRunner actionRunner,
- ILicenseAcceptanceService licenseAcceptanceService,
- ITaskFactory taskFactory)
+ ManagePackagesUserPrompts userPrompts)
{
- this.solution = solution;
+ this.packagesViewModels = packagesViewModels;
+ this.viewTitle = viewTitle;
this.packageManagementEvents = packageManagementEvents;
- this.licenseAcceptanceService = licenseAcceptanceService;
+ this.userPrompts = userPrompts;
packageManagementEvents.PackageOperationError += PackageOperationError;
packageManagementEvents.PackageOperationsStarting += PackageOperationsStarting;
- packageManagementEvents.AcceptLicenses += AcceptLicenses;
- var packageViewModelFactory = new PackageViewModelFactory(solution, packageManagementEvents, actionRunner);
-
- AvailablePackagesViewModel = new AvailablePackagesViewModel(registeredPackageRepositories, packageViewModelFactory, taskFactory);
- InstalledPackagesViewModel = new InstalledPackagesViewModel(solution, packageManagementEvents, registeredPackageRepositories, packageViewModelFactory, taskFactory);
- UpdatedPackagesViewModel = new UpdatedPackagesViewModel(solution, registeredPackageRepositories, packageViewModelFactory, taskFactory);
- RecentPackagesViewModel = new RecentPackagesViewModel(packageManagementEvents, registeredPackageRepositories, packageViewModelFactory, taskFactory);
-
- AvailablePackagesViewModel.ReadPackages();
- InstalledPackagesViewModel.ReadPackages();
- UpdatedPackagesViewModel.ReadPackages();
- RecentPackagesViewModel.ReadPackages();
+ packagesViewModels.ReadPackages();
}
- public AvailablePackagesViewModel AvailablePackagesViewModel { get; private set; }
- public InstalledPackagesViewModel InstalledPackagesViewModel { get; private set; }
- public RecentPackagesViewModel RecentPackagesViewModel { get; private set; }
- public UpdatedPackagesViewModel UpdatedPackagesViewModel { get; private set; }
+ public AvailablePackagesViewModel AvailablePackagesViewModel {
+ get { return packagesViewModels.AvailablePackagesViewModel; }
+ }
- public string Title {
- get { return GetTitle(); }
+ public InstalledPackagesViewModel InstalledPackagesViewModel {
+ get { return packagesViewModels.InstalledPackagesViewModel; }
}
- string GetTitle()
- {
- IPackageManagementProject project = solution.GetActiveProject();
- return String.Format("{0} - Manage Packages", project.Name);
+ public RecentPackagesViewModel RecentPackagesViewModel {
+ get { return packagesViewModels.RecentPackagesViewModel; }
+ }
+
+ public UpdatedPackagesViewModel UpdatedPackagesViewModel {
+ get { return packagesViewModels.UpdatedPackagesViewModel; }
+ }
+
+ public string Title {
+ get { return viewTitle.Title; }
}
public void Dispose()
{
- AvailablePackagesViewModel.Dispose();
- InstalledPackagesViewModel.Dispose();
- RecentPackagesViewModel.Dispose();
- UpdatedPackagesViewModel.Dispose();
+ packagesViewModels.Dispose();
+ userPrompts.Dispose();
- packageManagementEvents.AcceptLicenses -= AcceptLicenses;
packageManagementEvents.PackageOperationError -= PackageOperationError;
packageManagementEvents.PackageOperationsStarting -= PackageOperationsStarting;
packageManagementEvents.Dispose();
@@ -112,10 +103,5 @@ void ClearMessage()
this.Message = null;
this.HasError = false;
}
-
- void AcceptLicenses(object sender, AcceptLicensesEventArgs e)
- {
- e.IsAccepted = licenseAcceptanceService.AcceptLicenses(e.Packages);
- }
}
}
View
24 src/AddIns/Misc/PackageManagement/Project/Src/ManagePackagesViewTitle.cs
@@ -0,0 +1,24 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+
+namespace ICSharpCode.PackageManagement
+{
+ public class ManagePackagesViewTitle
+ {
+ public ManagePackagesViewTitle(IPackageManagementSolution solution)
+ {
+ GetTitle(solution);
+ }
+
+ void GetTitle(IPackageManagementSolution solution)
+ {
+ var selectedProjects = new PackageManagementSelectedProjects(solution);
+ string selectionName = selectedProjects.SelectionName;
+ Title = String.Format("{0} - Manage Packages", selectionName);
+ }
+
+ public string Title { get; private set; }
+ }
+}
View
12 src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementEvents.cs
@@ -66,5 +66,17 @@ public void OnPackageOperationMessageLogged(MessageLevel level, string message,
PackageOperationMessageLogged(this, eventArgs);
}
}
+
+ public event EventHandler<SelectProjectsEventArgs> SelectProjects;
+
+ public bool OnSelectProjects(IEnumerable<IPackageManagementSelectedProject> projects)
+ {
+ if (SelectProjects != null) {
+ var eventArgs = new SelectProjectsEventArgs(projects);
+ SelectProjects(this, eventArgs);
+ return eventArgs.IsAccepted;
+ }
+ return true;
+ }
}
}
View
2  src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementProject.cs
@@ -69,7 +69,7 @@ public class PackageManagementProject : IPackageManagementProject
remove { projectManager.PackageReferenceRemoved -= value; }
}
- public bool IsInstalled(IPackage package)
+ public bool IsPackageInstalled(IPackage package)
{
return projectManager.IsInstalled(package);
}
View
29 src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementSelectedProject.cs
@@ -0,0 +1,29 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+
+namespace ICSharpCode.PackageManagement
+{
+ public class PackageManagementSelectedProject : IPackageManagementSelectedProject
+ {
+ public PackageManagementSelectedProject(IPackageManagementProject project)
+ : this(project, false)
+ {
+ }
+
+ public PackageManagementSelectedProject(
+ IPackageManagementProject project,
+ bool selected)
+ {
+ this.Project = project;
+ this.Name = Project.Name;
+ this.IsSelected = selected;
+ }
+
+ public IPackageManagementProject Project { get; private set; }
+ public string Name { get; private set; }
+
+ public bool IsSelected { get; set; }
+ }
+}
View
136 src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementSelectedProjects.cs
@@ -0,0 +1,136 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+
+using ICSharpCode.SharpDevelop.Project;
+using NuGet;
+
+namespace ICSharpCode.PackageManagement
+{
+ public class PackageManagementSelectedProjects
+ {
+ IPackageManagementSolution solution;
+
+ public PackageManagementSelectedProjects(IPackageManagementSolution solution)
+ {
+ this.solution = solution;
+ }
+
+ public IEnumerable<IPackageManagementSelectedProject> GetProjects(IPackageFromRepository package)
+ {
+ if (HasSingleProjectSelected()) {
+ yield return GetSingleProjectSelected(package);
+ } else {
+ foreach (IProject project in GetOpenProjects()) {
+ yield return CreateSelectedProject(project, package);
+ }
+ }
+ }
+
+ public bool HasSingleProjectSelected()
+ {
+ return GetSingleMSBuildProjectSelected() != null;
+ }
+
+ IProject GetSingleMSBuildProjectSelected()
+ {
+ return solution.GetActiveMSBuildProject();
+ }
+
+ IEnumerable<IProject> GetOpenProjects()
+ {
+ return solution.GetMSBuildProjects();
+ }
+
+ IPackageManagementSelectedProject GetSingleProjectSelected(IPackageFromRepository package)
+ {
+ IProject project = GetSingleMSBuildProjectSelected();
+ return CreateSelectedProject(project, package);
+ }
+
+ IPackageManagementSelectedProject CreateSelectedProject(IProject msbuildProject, IPackageFromRepository package)
+ {
+ IPackageManagementProject project = solution.GetProject(package.Repository, msbuildProject);
+ return CreateSelectedProject(project, package);
+ }
+
+ IPackageManagementSelectedProject CreateSelectedProject(
+ IPackageManagementProject project,
+ IPackageFromRepository package)
+ {
+ bool selected = project.IsPackageInstalled(package);
+ return new PackageManagementSelectedProject(project, selected);
+ }
+
+ public bool HasMultipleProjects()
+ {
+ if (HasSingleProjectSelected()) {
+ return false;
+ }
+ return solution.HasMultipleProjects();
+ }
+
+ public string SelectionName {
+ get { return GetSelectionName(); }
+ }
+
+ string GetSelectionName()
+ {
+ if (HasSingleProjectSelected()) {
+ return GetSingleProjectSelectedName();
+ }
+ return GetSolutionFileNameWithoutFullPath();
+ }
+
+ string GetSingleProjectSelectedName()
+ {
+ IProject project = GetSingleMSBuildProjectSelected();
+ return project.Name;
+ }
+
+ string GetSolutionFileNameWithoutFullPath()
+ {
+ return Path.GetFileName(solution.FileName);
+ }
+
+ /// <summary>
+ /// Returns true if the package is installed in the selected projects.
+ /// </summary>
+ public bool IsPackageInstalled(IPackageFromRepository package)
+ {
+ IPackageManagementProject project = solution.GetActiveProject(package.Repository);
+ if (project != null) {
+ return project.IsPackageInstalled(package);
+ }
+ return IsPackageInstalledInSolution(package);
+ }
+
+ public bool IsPackageInstalledInSolution(IPackage package)
+ {
+ return solution.IsPackageInstalled(package);
+ }
+
+ public IQueryable<IPackage> GetPackagesInstalledInSolution()
+ {
+ return solution.GetPackages();
+ }
+
+ public IQueryable<IPackage> GetInstalledPackages(IPackageRepository sourceRepository)
+ {
+ if (HasSingleProjectSelected()) {
+ IPackageManagementProject project = GetActiveProject(sourceRepository);
+ return project.GetPackages();
+ }
+ return GetPackagesInstalledInSolution();
+ }
+
+ public IPackageManagementProject GetActiveProject(IPackageRepository repository)
+ {
+ return solution.GetActiveProject(repository);
+ }
+ }
+}
View
11 src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementServices.cs
@@ -22,14 +22,15 @@ public static class PackageManagementServices
static readonly PackageActionRunner packageActionRunner;
static readonly IPackageRepositoryCache projectTemplatePackageRepositoryCache;
static readonly RegisteredProjectTemplatePackageSources projectTemplatePackageSources;
+ static readonly PackageRepositoryCache packageRepositoryCache;
static PackageManagementServices()
{
options = new PackageManagementOptions();
- var cache = new PackageRepositoryCache(options.PackageSources, options.RecentPackages);
- registeredPackageRepositories = new RegisteredPackageRepositories(cache, options);
+ packageRepositoryCache = new PackageRepositoryCache(options.PackageSources, options.RecentPackages);
+ registeredPackageRepositories = new RegisteredPackageRepositories(packageRepositoryCache, options);
projectTemplatePackageSources = new RegisteredProjectTemplatePackageSources();
- projectTemplatePackageRepositoryCache = new ProjectTemplatePackageRepositoryCache(cache, projectTemplatePackageSources);
+ projectTemplatePackageRepositoryCache = new ProjectTemplatePackageRepositoryCache(packageRepositoryCache, projectTemplatePackageSources);
outputMessagesView = new PackageManagementOutputMessagesView(packageManagementEvents);
projectBrowserRefresher = new ProjectBrowserRefresher(projectService, packageManagementEvents);
@@ -58,6 +59,10 @@ static PackageManagementServices()
get { return registeredPackageRepositories; }
}
+ public static IPackageRepositoryCache PackageRepositoryCache {
+ get { return packageRepositoryCache; }
+ }
+
public static IPackageManagementEvents PackageManagementEvents {
get { return packageManagementEvents; }
}
View
76 src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementSolution.cs
@@ -14,35 +14,56 @@ public class PackageManagementSolution : IPackageManagementSolution
{
IRegisteredPackageRepositories registeredPackageRepositories;
IPackageManagementProjectService projectService;
- IPackageManagementEvents packageManagementEvents;
IPackageManagementProjectFactory projectFactory;
+ ISolutionPackageRepositoryFactory solutionPackageRepositoryFactory;
public PackageManagementSolution(
IRegisteredPackageRepositories registeredPackageRepositories,
IPackageManagementEvents packageManagementEvents)
: this(
registeredPackageRepositories,
- packageManagementEvents,
new PackageManagementProjectService(),
- new PackageManagementProjectFactory(packageManagementEvents))
+ new PackageManagementProjectFactory(packageManagementEvents),
+ new SolutionPackageRepositoryFactory())
{
}
public PackageManagementSolution(
IRegisteredPackageRepositories registeredPackageRepositories,
- IPackageManagementEvents packageManagementEvents,
IPackageManagementProjectService projectService,
- IPackageManagementProjectFactory projectFactory)
+ IPackageManagementProjectFactory projectFactory,
+ ISolutionPackageRepositoryFactory solutionPackageRepositoryFactory)
{
this.registeredPackageRepositories = registeredPackageRepositories;
- this.packageManagementEvents = packageManagementEvents;
this.projectFactory = projectFactory;
this.projectService = projectService;
+ this.solutionPackageRepositoryFactory = solutionPackageRepositoryFactory;
+ }
+
+ public string FileName {
+ get { return OpenSolution.FileName; }
+ }
+
+ Solution OpenSolution {
+ get { return projectService.OpenSolution; }
}
public IPackageManagementProject GetActiveProject()
{
- return GetActiveProject(ActivePackageRepository);
+ if (HasActiveProject()) {
+ return GetActiveProject(ActivePackageRepository);
+ }
+ return null;
+ }
+
+ bool HasActiveProject()
+ {
+ return GetActiveMSBuildBasedProject() != null;
+ }
+
+ public IProject GetActiveMSBuildProject()
+ {
+ return projectService.CurrentProject;
}
IPackageRepository ActivePackageRepository {
@@ -51,13 +72,16 @@ public IPackageManagementProject GetActiveProject()
public IPackageManagementProject GetActiveProject(IPackageRepository sourceRepository)
{
- MSBuildBasedProject activeProject = GetActiveMSBuildProject();
- return CreateProject(sourceRepository, activeProject);
+ MSBuildBasedProject activeProject = GetActiveMSBuildBasedProject();
+ if (activeProject != null) {
+ return CreateProject(sourceRepository, activeProject);
+ }
+ return null;
}
- MSBuildBasedProject GetActiveMSBuildProject()
+ MSBuildBasedProject GetActiveMSBuildBasedProject()
{
- return projectService.CurrentProject as MSBuildBasedProject;
+ return GetActiveMSBuildProject() as MSBuildBasedProject;
}
IPackageManagementProject CreateProject(IPackageRepository sourceRepository, MSBuildBasedProject project)
@@ -94,13 +118,41 @@ public IPackageManagementProject GetProject(IPackageRepository sourceRepository,
return CreateProject(sourceRepository, msbuildProject);
}
+ public IPackageManagementProject GetProject(IPackageRepository sourceRepository, IProject project)
+ {
+ var msbuildProject = project as MSBuildBasedProject;
+ return CreateProject(sourceRepository, msbuildProject);
+ }
+
public IEnumerable<IProject> GetMSBuildProjects()
{
return projectService.GetOpenProjects();
}
public bool IsOpen {
- get { return projectService.OpenSolution != null; }
+ get { return OpenSolution != null; }
+ }
+
+ public bool HasMultipleProjects()
+ {
+ return projectService.GetOpenProjects().Count() > 1;
+ }
+
+ public bool IsPackageInstalled(IPackage package)
+ {
+ ISolutionPackageRepository repository = CreateSolutionPackageRepository();
+ return repository.IsInstalled(package);
+ }
+
+ ISolutionPackageRepository CreateSolutionPackageRepository()
+ {
+ return solutionPackageRepositoryFactory.CreateSolutionPackageRepository(OpenSolution);
+ }
+
+ public IQueryable<IPackage> GetPackages()
+ {
+ ISolutionPackageRepository repository = CreateSolutionPackageRepository();
+ return repository.GetPackages();
}
}
}
View
44 src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementViewModels.cs
@@ -29,39 +29,55 @@ void CreateManagePackagesViewModel()
{
CreateRegisteredPackageRepositories();
CreateSolution();
- var packageManagementEvents = new ThreadSafePackageManagementEvents(PackageManagementServices.PackageManagementEvents);
+ ThreadSafePackageManagementEvents packageManagementEvents = CreateThreadSafePackageManagementEvents();
+ PackagesViewModels packagesViewModels = CreatePackagesViewModels(packageManagementEvents);
+
managePackagesViewModel =
new ManagePackagesViewModel(
- solution,
- registeredPackageRepositories,
+ packagesViewModels,
+ new ManagePackagesViewTitle(solution),
packageManagementEvents,
- PackageManagementServices.PackageActionRunner,
- new LicenseAcceptanceService(),
- new PackageManagementTaskFactory());
+ new ManagePackagesUserPrompts(packageManagementEvents));
}
- void CreateSolution()
+ void CreateRegisteredPackageRepositories()
{
- if (solution == null) {
+ if (registeredPackageRepositories == null) {
if (IsInDesignMode()) {
- solution = new FakePackageManagementSolution();
+ registeredPackageRepositories = new DesignTimeRegisteredPackageRepositories();
} else {
- solution = PackageManagementServices.Solution;
+ registeredPackageRepositories = PackageManagementServices.RegisteredPackageRepositories;
}
}
}
- void CreateRegisteredPackageRepositories()
+ void CreateSolution()
{
- if (registeredPackageRepositories == null) {
+ if (solution == null) {
if (IsInDesignMode()) {
- registeredPackageRepositories = new DesignTimeRegisteredPackageRepositories();
+ solution = new FakePackageManagementSolution();
} else {
- registeredPackageRepositories = PackageManagementServices.RegisteredPackageRepositories;
+ solution = PackageManagementServices.Solution;
}
}
}
+ ThreadSafePackageManagementEvents CreateThreadSafePackageManagementEvents()
+ {
+ return new ThreadSafePackageManagementEvents(
+ PackageManagementServices.PackageManagementEvents);
+ }
+
+ PackagesViewModels CreatePackagesViewModels(IThreadSafePackageManagementEvents packageManagementEvents)
+ {
+ return new PackagesViewModels(
+ solution,
+ registeredPackageRepositories,
+ packageManagementEvents,
+ PackageManagementServices.PackageActionRunner,
+ new PackageManagementTaskFactory());
+ }
+
bool IsInDesignMode()
{
return WpfDesigner.IsInDesignMode();
View
147 src/AddIns/Misc/PackageManagement/Project/Src/PackageViewModel.cs
@@ -14,9 +14,10 @@ public class PackageViewModel : ViewModelBase<PackageViewModel>
{
DelegateCommand addPackageCommand;
DelegateCommand removePackageCommand;
+ DelegateCommand managePackageCommand;
IPackageManagementSolution solution;
- IPackageManagementProject activeProject;
+ PackageManagementSelectedProjects selectedProjects;
IPackageManagementEvents packageManagementEvents;
IPackageFromRepository package;
IEnumerable<PackageOperation> packageOperations = new PackageOperation[0];
@@ -36,6 +37,8 @@ public class PackageViewModel : ViewModelBase<PackageViewModel>
this.actionRunner = actionRunner;
this.logger = CreateLogger(logger);
+ selectedProjects = new PackageManagementSelectedProjects(solution);
+
CreateCommands();
}
@@ -48,6 +51,7 @@ void CreateCommands()
{
addPackageCommand = new DelegateCommand(param => AddPackage());
removePackageCommand = new DelegateCommand(param => RemovePackage());
+ managePackageCommand = new DelegateCommand(param => ManagePackage());
}
public ICommand AddPackageCommand {
@@ -58,6 +62,10 @@ void CreateCommands()
get { return removePackageCommand; }
}
+ public ICommand ManagePackageCommand {
+ get { return managePackageCommand; }
+ }
+
public IPackage GetPackage()
{
return package;
@@ -93,21 +101,7 @@ public IPackage GetPackage()
bool IsPackageInstalled()
{
- return IsPackageInstalled(package);
- }
-
- bool IsPackageInstalled(IPackage package)
- {
- return ActiveProject.IsInstalled(package);
- }
-
- IPackageManagementProject ActiveProject {
- get {
- if (activeProject == null) {
- activeProject = solution.GetActiveProject();
- }
- return activeProject;
- }
+ return selectedProjects.IsPackageInstalled(package);
}
public IEnumerable<PackageDependency> Dependencies {
@@ -219,7 +213,12 @@ IList<IPackage> GetPackagesToBeInstalled()
bool PackageRequiresLicenseAcceptance(IPackage package)
{
- return package.RequireLicenseAcceptance && !IsPackageInstalled(package);
+ return package.RequireLicenseAcceptance && !IsPackageInstalledInSolution(package);
+ }
+
+ bool IsPackageInstalledInSolution(IPackage package)
+ {
+ return selectedProjects.IsPackageInstalledInSolution(package);
}
void TryInstallingPackage()
@@ -290,5 +289,119 @@ void TryUninstallingPackage()
logger.LogError(ex);
}
}
+
+ public bool IsManaged {
+ get { return selectedProjects.HasMultipleProjects(); }
+ }
+
+ public void ManagePackage()
+ {
+ List<IPackageManagementSelectedProject> projects = GetSelectedProjectsForPackage();
+ if (packageManagementEvents.OnSelectProjects(projects)) {
+ ManagePackagesForSelectedProjects(projects);
+ }
+ }
+
+ List<IPackageManagementSelectedProject> GetSelectedProjectsForPackage()
+ {
+ return selectedProjects.GetProjects(package).ToList();
+ }
+
+ public void ManagePackagesForSelectedProjects(IEnumerable<IPackageManagementSelectedProject> projects)
+ {
+ ManagePackagesForSelectedProjects(projects.ToList());
+ }
+
+ void ManagePackagesForSelectedProjects(IList<IPackageManagementSelectedProject> projects)
+ {
+ ClearReportedMessages();
+ logger.LogManagingPackage();
+ TryInstallingPackagesForSelectedProjects(projects);
+ logger.LogAfterPackageOperationCompletes();
+ OnPropertyChanged(model => model.IsAdded);
+ }
+
+ void TryInstallingPackagesForSelectedProjects(IList<IPackageManagementSelectedProject> projects)
+ {
+ try {
+ if (AnyProjectsSelected(projects)) {
+ InstallPackagesForSelectedProjects(projects);
+ }
+ } catch (Exception ex) {
+ ReportError(ex);
+ logger.LogError(ex);
+ }
+ }
+
+ bool AnyProjectsSelected(IList<IPackageManagementSelectedProject> projects)
+ {
+ return projects.Any(project => project.IsSelected);
+ }
+
+ void InstallPackagesForSelectedProjects(IList<IPackageManagementSelectedProject> projects)
+ {
+ if (CanInstallPackage(projects)) {
+ var actions = new List<ProcessPackageAction>();
+ foreach (IPackageManagementSelectedProject selectedProject in projects) {
+ if (selectedProject.IsSelected) {
+ selectedProject.Project.Logger = logger;
+ InstallPackageAction action = selectedProject.Project.CreateInstallPackageAction();
+ action.Package = package;
+ actions.Add(action);
+ }
+ }
+ RunActionsIfAnyExist(actions);
+ }
+ }
+
+ bool CanInstallPackage(IList<IPackageManagementSelectedProject> projects)
+ {
+ IPackageManagementSelectedProject project = projects.FirstOrDefault();
+ if (project != null) {
+ return CanInstallPackage(project);
+ }
+ return false;
+ }
+
+ bool CanInstallPackage(IPackageManagementSelectedProject selectedProject)
+ {
+ IEnumerable<IPackage> licensedPackages = GetPackagesRequiringLicenseAcceptance(selectedProject);
+ if (licensedPackages.Any()) {
+ return packageManagementEvents.OnAcceptLicenses(licensedPackages);
+ }
+ return true;
+ }
+
+ void RunActionsIfAnyExist(List<ProcessPackageAction> actions)
+ {
+ if (actions.Any()) {
+ actionRunner.Run(actions);
+ }
+ }
+
+ IEnumerable<IPackage> GetPackagesRequiringLicenseAcceptance(IPackageManagementSelectedProject selectedProject)
+ {
+ IPackageManagementProject project = selectedProject.Project;
+ project.Logger = logger;
+ IEnumerable<PackageOperation> operations = project.GetInstallPackageOperations(package, false);
+ return GetPackagesRequiringLicenseAcceptance(operations);
+ }
+
+ IEnumerable<IPackage> GetPackagesRequiringLicenseAcceptance(IEnumerable<PackageOperation> operations)
+ {
+ foreach (PackageOperation operation in operations) {
+ if (PackageOperationRequiresLicenseAcceptance(operation)) {
+ yield return operation.Package;
+ }
+ }
+ }
+
+ bool PackageOperationRequiresLicenseAcceptance(PackageOperation operation)
+ {
+ return
+ (operation.Action == PackageAction.Install) &&
+ operation.Package.RequireLicenseAcceptance &&
+ !IsPackageInstalledInSolution(operation.Package);
+ }
}
}
View
8 src/AddIns/Misc/PackageManagement/Project/Src/PackageViewModelOperationLogger.cs
@@ -23,10 +23,12 @@ void GetMessageFormats()
{
AddingPackageMessageFormat = "Installing...{0}";
RemovingPackageMessageFormat = "Uninstalling...{0}";
+ ManagingPackageMessageFormat = "Managing...{0}";
}
public string AddingPackageMessageFormat { get; set; }
public string RemovingPackageMessageFormat { get; set; }
+ public string ManagingPackageMessageFormat { get; set; }
public void Log(MessageLevel level, string message, params object[] args)
{
@@ -82,5 +84,11 @@ public void LogError(Exception ex)
{
LogInformation(ex.ToString());
}
+
+ public void LogManagingPackage()
+ {
+ string message = GetFormattedStartPackageOperationMessage(ManagingPackageMessageFormat);
+ LogInformation(message);
+ }
}
}
View
28 src/AddIns/Misc/PackageManagement/Project/Src/PackagesView.xaml
@@ -78,6 +78,14 @@
Visibility="Collapsed"
Command="{Binding Path=RemovePackageCommand}"
VerticalAlignment="Bottom"/>
+ <Button
+ x:Name="managePackageButton"
+ Grid.Column="2"
+ Content="Manage"
+ IsDefault="True"
+ Visibility="Collapsed"
+ Command="{Binding Path=ManagePackageCommand}"
+ VerticalAlignment="Bottom"/>
</Grid>
<DataTemplate.Triggers>
@@ -89,6 +97,9 @@
<Condition
Binding="{Binding Path=IsAdded}"
Value="False"/>
+ <Condition
+ Binding="{Binding Path=IsManaged}"
+ Value="False"/>
</MultiDataTrigger.Conditions>
<Setter
TargetName="addPackageButton"
@@ -103,12 +114,29 @@
<Condition
Binding="{Binding Path=IsAdded}"
Value="True"/>
+ <Condition
+ Binding="{Binding Path=IsManaged}"
+ Value="False"/>
</MultiDataTrigger.Conditions>
<Setter
TargetName="removePackageButton"
Property="Visibility"
Value="Visible"/>
</MultiDataTrigger>
+ <MultiDataTrigger>
+ <MultiDataTrigger.Conditions>
+ <Condition
+ Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}}"
+ Value="True"/>
+ <Condition
+ Binding="{Binding Path=IsManaged}"
+ Value="True"/>
+ </MultiDataTrigger.Conditions>
+ <Setter
+ TargetName="managePackageButton"
+ Property="Visibility"
+ Value="Visible"/>
+ </MultiDataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
View
46 src/AddIns/Misc/PackageManagement/Project/Src/PackagesViewModels.cs
@@ -0,0 +1,46 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+
+namespace ICSharpCode.PackageManagement
+{
+ public class PackagesViewModels : IDisposable
+ {
+ public PackagesViewModels(
+ IPackageManagementSolution solution,
+ IRegisteredPackageRepositories registeredPackageRepositories,
+ IThreadSafePackageManagementEvents packageManagementEvents,
+ IPackageActionRunner actionRunner,
+ ITaskFactory taskFactory)
+ {
+ var packageViewModelFactory = new PackageViewModelFactory(solution, packageManagementEvents, actionRunner);
+
+ AvailablePackagesViewModel = new AvailablePackagesViewModel(registeredPackageRepositories, packageViewModelFactory, taskFactory);
+ InstalledPackagesViewModel = new InstalledPackagesViewModel(solution, packageManagementEvents, registeredPackageRepositories, packageViewModelFactory, taskFactory);
+ UpdatedPackagesViewModel = new UpdatedPackagesViewModel(solution, registeredPackageRepositories, packageViewModelFactory, taskFactory);
+ RecentPackagesViewModel = new RecentPackagesViewModel(packageManagementEvents, registeredPackageRepositories, packageViewModelFactory, taskFactory);
+ }
+
+ public AvailablePackagesViewModel AvailablePackagesViewModel { get; private set; }
+ public InstalledPackagesViewModel InstalledPackagesViewModel { get; private set; }
+ public RecentPackagesViewModel RecentPackagesViewModel { get; private set; }
+ public UpdatedPackagesViewModel UpdatedPackagesViewModel { get; private set; }
+
+ public void ReadPackages()
+ {
+ AvailablePackagesViewModel.ReadPackages();
+ InstalledPackagesViewModel.ReadPackages();
+ UpdatedPackagesViewModel.ReadPackages();
+ RecentPackagesViewModel.ReadPackages();
+ }
+
+ public void Dispose()
+ {
+ AvailablePackagesViewModel.Dispose();
+ InstalledPackagesViewModel.Dispose();
+ RecentPackagesViewModel.Dispose();
+ UpdatedPackagesViewModel.Dispose();
+ }
+ }
+}
View
20 src/AddIns/Misc/PackageManagement/Project/Src/SelectProjectsEventArgs.cs
@@ -0,0 +1,20 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Collections.Generic;
+
+namespace ICSharpCode.PackageManagement
+{
+ public class SelectProjectsEventArgs : EventArgs
+ {
+ public SelectProjectsEventArgs(IEnumerable<IPackageManagementSelectedProject> selectedProjects)
+ {
+ this.SelectedProjects = selectedProjects;
+ }
+
+ public IEnumerable<IPackageManagementSelectedProject> SelectedProjects { get; private set; }
+
+ public bool IsAccepted { get; set; }
+ }
+}
View
45 src/AddIns/Misc/PackageManagement/Project/Src/SelectProjectsService.cs
@@ -0,0 +1,45 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Collections.Generic;
+using System.Windows;
+using ICSharpCode.SharpDevelop.Gui;
+
+namespace ICSharpCode.PackageManagement
+{
+ public class SelectProjectsService : ISelectProjectsService
+ {
+ Window owner;
+
+ public Window Owner {
+ get {
+ if (owner == null) {
+ owner = WorkbenchSingleton.MainWindow;
+ }
+ return owner;
+ }
+ set { owner = value; }
+ }
+
+ public bool SelectProjects(IEnumerable<IPackageManagementSelectedProject> projects)
+ {
+ SelectProjectsView view = CreateSelectProjectsView(projects);
+ return view.ShowDialog() ?? false;
+ }
+
+ SelectProjectsView CreateSelectProjectsView(IEnumerable<IPackageManagementSelectedProject> projects)
+ {
+ var viewModel = new SelectProjectsViewModel(projects);
+ return CreateSelectProjectsView(viewModel);
+ }
+
+ SelectProjectsView CreateSelectProjectsView(SelectProjectsViewModel viewModel)
+ {
+ var view = new SelectProjectsView();
+ view.DataContext = viewModel;
+ view.Owner = Owner;
+ return view;
+ }
+ }
+}
View
69 src/AddIns/Misc/PackageManagement/Project/Src/SelectProjectsView.xaml
@@ -0,0 +1,69 @@
+<Window
+ x:Class="ICSharpCode.PackageManagement.SelectProjectsView"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:core="http://icsharpcode.net/sharpdevelop/core"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:pm="clr-namespace:ICSharpCode.PackageManagement"
+ xmlns:pmd="clr-namespace:ICSharpCode.PackageManagement.Design"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ mc:Ignorable="d"
+ WindowStartupLocation="CenterOwner"
+ Style="{x:Static core:GlobalStyles.DialogWindowStyle}"
+ Title="Select Projects"
+ Height="300"
+ Width="480"
+ MinHeight="300"
+ MinWidth="300">
+
+ <Window.Resources>
+ <Style TargetType="Button" BasedOn="{x:Static core:GlobalStyles.ButtonStyle}"/>
+ <DataTemplate x:Key="ListBoxItemTemplate">
+ <Grid>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="Auto"/>
+ <ColumnDefinition />
+ </Grid.ColumnDefinitions>
+
+ <CheckBox
+ Margin="4, 2"
+ IsChecked="{Binding IsSelected}"/>
+
+ <TextBlock
+ Grid.Column="1"
+ Margin="4, 0"
+ Text="{Binding Name}"/>
+ </Grid>
+ </DataTemplate>
+ </Window.Resources>
+
+ <Grid
+ d:DataContext="{d:DesignInstance pmd:DesignTimeSelectProjectsViewModel, IsDesignTimeCreatable=True}">
+ <Grid.RowDefinitions>
+ <RowDefinition Height="Auto"/>
+ <RowDefinition />
+ <RowDefinition Height="Auto"/>
+ </Grid.RowDefinitions>
+
+ <TextBlock
+ Grid.Row="0"
+ Margin="4"
+ Text="Install the package into the following projects:"/>
+ <ListBox
+ Grid.Row="1"
+ ItemTemplate="{StaticResource ListBoxItemTemplate}"
+ ItemsSource="{Binding Path=Projects}"/>
+ <StackPanel
+ Grid.Row="2"
+ Margin="4"
+ Orientation="Horizontal"
+ HorizontalAlignment="Right">
+ <Button
+ Content="_Cancel"
+ IsCancel="True"/>
+ <Button
+ Content="_OK"
+ Click="AcceptButtonClick"/>
+ </StackPanel>
+ </Grid>
+</Window>
View
21 src/AddIns/Misc/PackageManagement/Project/Src/SelectProjectsView.xaml.cs
@@ -0,0 +1,21 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Windows;
+
+namespace ICSharpCode.PackageManagement
+{
+ public partial class SelectProjectsView : Window
+ {
+ public SelectProjectsView()
+ {
+ InitializeComponent();
+ }
+
+ void AcceptButtonClick(object sender, RoutedEventArgs e)
+ {
+ DialogResult = true;
+ }
+ }
+}
View
36 src/AddIns/Misc/PackageManagement/Project/Src/SelectProjectsViewModel.cs
@@ -0,0 +1,36 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+
+namespace ICSharpCode.PackageManagement
+{
+ public class SelectProjectsViewModel
+ {
+ ObservableCollection<IPackageManagementSelectedProject> projects =
+ new ObservableCollection<IPackageManagementSelectedProject>();
+
+ public SelectProjectsViewModel(IEnumerable<IPackageManagementSelectedProject> projects)
+ {
+ AddProjects(projects);
+ }
+
+ void AddProjects(IEnumerable<IPackageManagementSelectedProject> projects)
+ {
+ foreach (IPackageManagementSelectedProject project in projects) {
+ AddProject(project);
+ }
+ }
+
+ void AddProject(IPackageManagementSelectedProject project)
+ {
+ projects.Add(project);
+ }
+
+ public ObservableCollection<IPackageManagementSelectedProject> Projects {
+ get { return projects; }
+ }
+ }
+}
View
11 src/AddIns/Misc/PackageManagement/Project/Src/SharpDevelopPackageManager.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using ICSharpCode.PackageManagement.Scripting;
using ICSharpCode.SharpDevelop.Project;
using NuGet;
@@ -16,15 +17,13 @@ public class SharpDevelopPackageManager : PackageManager, ISharpDevelopPackageMa
public SharpDevelopPackageManager(
IPackageRepository sourceRepository,
IProjectSystem projectSystem,
- IFileSystem fileSystem,
- ISharedPackageRepository localRepository,
- IPackagePathResolver pathResolver,
+ ISolutionPackageRepository solutionPackageRepository,
IPackageOperationResolverFactory packageOperationResolverFactory)
: base(
sourceRepository,
- pathResolver,
- fileSystem,
- localRepository)
+ solutionPackageRepository.PackagePathResolver,
+ solutionPackageRepository.FileSystem,
+ solutionPackageRepository.Repository)
{
this.projectSystem = projectSystem;
this.packageOperationResolverFactory = packageOperationResolverFactory;
View
31 src/AddIns/Misc/PackageManagement/Project/Src/SharpDevelopPackageManagerFactory.cs
@@ -31,37 +31,26 @@ public SharpDevelopPackageManagerFactory()
this.options = options;
}
- public ISharpDevelopPackageManager CreatePackageManager(IPackageRepository packageRepository, MSBuildBasedProject project)
- {
- IFileSystem fileSystem = CreateFileSystemThatWillContainPackages(project);
- return CreatePackageManager(fileSystem, packageRepository, project);
- }
-
- IFileSystem CreateFileSystemThatWillContainPackages(MSBuildBasedProject project)
- {
- var repositoryPath = new SolutionPackageRepositoryPath(project, options);
- return new PhysicalFileSystem(repositoryPath.PackageRepositoryPath);
- }
-
- ISharpDevelopPackageManager CreatePackageManager(
- IFileSystem fileSystem,
- IPackageRepository packageRepository,
+ public ISharpDevelopPackageManager CreatePackageManager(
+ IPackageRepository sourceRepository,
MSBuildBasedProject project)
{
- DefaultPackagePathResolver pathResolver = new DefaultPackagePathResolver(fileSystem);
- ISharedPackageRepository sharedRepository = CreateSharedRepository(pathResolver, fileSystem);
+ SolutionPackageRepository solutionPackageRepository = CreateSolutionPackageRepository(project.ParentSolution);
IProjectSystem projectSystem = CreateProjectSystem(project);
PackageOperationsResolverFactory packageOperationResolverFactory = new PackageOperationsResolverFactory();
return new SharpDevelopPackageManager(
- packageRepository,
+ sourceRepository,
projectSystem,
- fileSystem,
- sharedRepository,
- pathResolver,
+ solutionPackageRepository,
packageOperationResolverFactory);
}
+ SolutionPackageRepository CreateSolutionPackageRepository(Solution solution)
+ {
+ return new SolutionPackageRepository(solution, packageRepositoryFactory, options);
+ }
+
IProjectSystem CreateProjectSystem(MSBuildBasedProject project)
{
return projectSystemFactory.CreateProjectSystem(project);
View
25 src/AddIns/Misc/PackageManagement/Project/Src/SolutionPackageRepository.cs
@@ -3,7 +3,8 @@
using System;
using System.Collections.Generic;
-using ICSharpCode.PackageManagement.Scripting;
+using System.Linq;
+
using ICSharpCode.SharpDevelop.Project;
using NuGet;
@@ -52,6 +53,18 @@ void CreateRepository()
repository = repositoryFactory.CreateSharedRepository(packagePathResolver, fileSystem);
}
+ public ISharedPackageRepository Repository {
+ get { return repository; }
+ }
+
+ public IFileSystem FileSystem {
+ get { return fileSystem; }
+ }
+
+ public IPackagePathResolver PackagePathResolver {
+ get { return packagePathResolver; }
+ }
+
public string GetInstallPath(IPackage package)
{
return repositoryPath.GetInstallPath(package);
@@ -62,5 +75,15 @@ public IEnumerable<IPackage> GetPackagesByDependencyOrder()
var packageSorter = new PackageSorter();
return packageSorter.GetPackagesByDependencyOrder(repository);
}
+
+ public bool IsInstalled(IPackage package)
+ {
+ return repository.Exists(package);
+ }
+
+ public IQueryable<IPackage> GetPackages()
+ {
+ return repository.GetPackages();
+ }
}
}
View
34 src/AddIns/Misc/PackageManagement/Project/Src/SolutionPackageRepositoryFactory.cs
@@ -0,0 +1,34 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using ICSharpCode.PackageManagement.Scripting;
+using ICSharpCode.SharpDevelop.Project;
+using NuGet;
+
+namespace ICSharpCode.PackageManagement
+{
+ public class SolutionPackageRepositoryFactory : ISolutionPackageRepositoryFactory
+ {
+ ISharpDevelopPackageRepositoryFactory repositoryFactory;
+ PackageManagementOptions options;
+
+ public SolutionPackageRepositoryFactory()
+ : this(PackageManagementServices.PackageRepositoryCache, PackageManagementServices.Options)
+ {
+ }
+
+ public SolutionPackageRepositoryFactory(
+ ISharpDevelopPackageRepositoryFactory repositoryFactory,
+ PackageManagementOptions options)
+ {
+ this.repositoryFactory = repositoryFactory;
+ this.options = options;
+ }
+
+ public ISolutionPackageRepository CreateSolutionPackageRepository(Solution solution)
+ {
+ return new SolutionPackageRepository(solution, repositoryFactory, options);
+ }
+ }
+}
View
10 src/AddIns/Misc/PackageManagement/Project/Src/ThreadSafePackageManagementEvents.cs
@@ -145,6 +145,11 @@ void RaiseParentPackageUninstalledEvent(object sender, ParentPackageOperationEve
remove { unsafeEvents.PackageOperationMessageLogged -= value; }
}
+ public event EventHandler<SelectProjectsEventArgs> SelectProjects {
+ add { unsafeEvents.SelectProjects += value; }
+ remove { unsafeEvents.SelectProjects -= value; }
+ }
+
public void OnPackageOperationsStarting()
{
unsafeEvents.OnPackageOperationsStarting();
@@ -174,5 +179,10 @@ public void OnPackageOperationMessageLogged(MessageLevel level, string message,
{
unsafeEvents.OnPackageOperationMessageLogged(level, message, args);
}
+
+ public bool OnSelectProjects(IEnumerable<IPackageManagementSelectedProject> selectedProjects)
+ {
+ return unsafeEvents.OnSelectProjects(selectedProjects);
+ }
}
}
View
22 src/AddIns/Misc/PackageManagement/Project/Src/UpdatedPackages.cs
@@ -12,26 +12,40 @@ namespace ICSharpCode.PackageManagement
{
public class UpdatedPackages
{
- IPackageManagementProject project;
IPackageRepository sourceRepository;
+ IQueryable<IPackage> installedPackages;
public UpdatedPackages(
IPackageManagementProject project,
IPackageRepository aggregateRepository)
+ : this(
+ project.GetPackages(),
+ aggregateRepository)
{
- this.project = project;
- this.sourceRepository = aggregateRepository;
+ }
+
+ public UpdatedPackages(
+ IQueryable<IPackage> installedPackages,
+ IPackageRepository aggregrateRepository)
+ {
+ this.installedPackages = installedPackages;
+ this.sourceRepository = aggregrateRepository;
}
public string SearchTerms { get; set; }
public IEnumerable<IPackage> GetUpdatedPackages()
{
- IQueryable<IPackage> localPackages = project.GetPackages();
+ IQueryable<IPackage> localPackages = installedPackages;
localPackages = FilterPackages(localPackages);
return GetUpdatedPackages(sourceRepository, localPackages);
}
+ IQueryable<IPackage> GetInstalledPackages()
+ {
+ return installedPackages;
+ }
+
IQueryable<IPackage> FilterPackages(IQueryable<IPackage> localPackages)
{
return localPackages.Find(SearchTerms);
View
10 src/AddIns/Misc/PackageManagement/Project/Src/UpdatedPackagesViewModel.cs
@@ -45,13 +45,19 @@ protected override void UpdateRepositoryBeforeReadPackagesTaskStarts()
{
try {
IPackageRepository aggregateRepository = RegisteredPackageRepositories.CreateAggregateRepository();
- IPackageManagementProject project = solution.GetActiveProject(aggregateRepository);
- updatedPackages = new UpdatedPackages(project, aggregateRepository);
+ IQueryable<IPackage> installedPackages = GetInstalledPackages(aggregateRepository);
+ updatedPackages = new UpdatedPackages(installedPackages, aggregateRepository);
} catch (Exception ex) {
errorMessage = ex.Message;
}
}
+ IQueryable<IPackage> GetInstalledPackages(IPackageRepository aggregateRepository)
+ {
+ var selectedProjects = new PackageManagementSelectedProjects(solution);
+ return selectedProjects.GetInstalledPackages(aggregateRepository);
+ }
+
protected override IQueryable<IPackage> GetAllPackages()
{
if (updatedPackages == null) {
View
6 src/AddIns/Misc/PackageManagement/Test/PackageManagement.Tests.csproj
@@ -69,6 +69,9 @@
<Compile Include="..\..\..\..\Main\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
+ <Compile Include="Src\Helpers\FakeSelectProjectsService.cs" />
+ <Compile Include="Src\Helpers\FakeSolutionPackageRepositoryFactory.cs" />
+ <Compile Include="Src\Helpers\SelectedProjectCollectionAssert.cs" />
<Compile Include="Src\Helpers\TestablePackageFromRepository.cs" />
<Compile Include="Src\ManagePackagesCommandTests.cs" />
<Compile Include="Src\ConsolePackageActionRunnerTests.cs" />
@@ -133,6 +136,8 @@
<Compile Include="Src\PackageManagementEventsTests.cs" />
<Compile Include="Src\PackageManagementLoggerTests.cs" />
<Compile Include="Src\PackageManagementProjectTests.cs" />
+ <Compile Include="Src\PackageManagementSelectedProjectsTests.cs" />
+ <Compile Include="Src\PackageManagementSelectedProjectTests.cs" />
<Compile Include="Src\PackageOperationMessageTests.cs" />
<Compile Include="Src\PackageReferenceInstallerTests.cs" />
<Compile Include="Src\PackageReferencesForProjectTests.cs" />
@@ -216,6 +221,7 @@
<Compile Include="Src\Scripting\PowerShellMissingConsoleHostTests.cs" />
<Compile Include="Src\Scripting\PowerShellWorkingDirectoryTests.cs" />
<Compile Include="Src\Scripting\ResetPowerShellWorkingDirectoryOnSolutionClosedTests.cs" />
+ <Compile Include="Src\SelectProjectsViewModelTests.cs" />
<Compile Include="Src\SolutionPackageRepositoryPathTests.cs" />
<Compile Include="Src\PackageSourceViewModelTests.cs" />
<Compile Include="Src\PackagesViewModelTests.cs" />
View
15 src/AddIns/Misc/PackageManagement/Test/Src/Helpers/ExceptionThrowingPackageManagementProject.cs
@@ -2,24 +2,35 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
+using System.Collections.Generic;
using ICSharpCode.PackageManagement;
using ICSharpCode.PackageManagement.Design;
+using NuGet;
namespace PackageManagement.Tests.Helpers
{
public class ExceptionThrowingPackageManagementProject : FakePackageManagementProject
{
- public Exception ExceptionToThrowWhenCreateInstallPackageTaskCalled { get; set; }
+ public Exception ExceptionToThrowWhenCreateInstallPackageActionCalled { get; set; }
public Exception ExceptionToThrowWhenCreateUninstallPackageActionCalled { get; set; }
+ public Exception ExceptionToThrowWhenGetInstallPackageOperationsCalled { get; set; }
public override InstallPackageAction CreateInstallPackageAction()
{
- throw ExceptionToThrowWhenCreateInstallPackageTaskCalled;
+ throw ExceptionToThrowWhenCreateInstallPackageActionCalled;
}
public override UninstallPackageAction CreateUninstallPackageAction()
{
throw ExceptionToThrowWhenCreateUninstallPackageActionCalled;
}
+
+ public override IEnumerable<PackageOperation> GetInstallPackageOperations(IPackage package, bool ignoreDependencies)
+ {
+ if (ExceptionToThrowWhenGetInstallPackageOperationsCalled != null) {
+ throw ExceptionToThrowWhenGetInstallPackageOperationsCalled;
+ }
+ return base.GetInstallPackageOperations(package, ignoreDependencies);
+ }
}
}
View
2  src/AddIns/Misc/PackageManagement/Test/Src/Helpers/FakeLicenseAcceptanceService.cs
@@ -17,7 +17,7 @@ public class FakeLicenseAcceptanceService : ILicenseAcceptanceService
public bool AcceptLicenses(IEnumerable<IPackage> packages)
{
IsAcceptLicensesCalled = true;
- PackagesPassedToAcceptLicenses = packages;
+ PackagesPassedToAcceptLicenses = packages;
return AcceptLicensesReturnValue;
}
View
6 src/AddIns/Misc/PackageManagement/Test/Src/Helpers/FakeLogger.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using NuGet;
namespace PackageManagement.Tests.Helpers
@@ -38,5 +39,10 @@ public void Log(MessageLevel level, string message, params object[] args)
string formattedMessage = String.Format(message, args);
FormattedMessagesLogged.Add(formattedMessage);
}
+
+ public bool FormattedMessagesLoggedContainsText(string text)
+ {
+ return FormattedMessagesLogged.Any(message => message.Contains(text));
+ }
}
}
View
8 src/AddIns/Misc/PackageManagement/Test/Src/Helpers/FakePackageActionRunner.cs
@@ -10,9 +10,11 @@ namespace PackageManagement.Tests.Helpers
public class FakePackageActionRunner : IPackageActionRunner
{
public ProcessPackageAction ActionPassedToRun;
+ public bool IsRunCalled;
public void Run(ProcessPackageAction action)
{
+ IsRunCalled = true;
ActionPassedToRun = action;
ActionsPassedToRun.Add(action);
}
@@ -22,9 +24,15 @@ public void Run(ProcessPackageAction action)
public void Run(IEnumerable<ProcessPackageAction> actions)
{
+ IsRunCalled = true;
ActionsRunInOneCall = actions;
}
public IEnumerable<ProcessPackageAction> ActionsRunInOneCall;
+
+ public List<ProcessPackageAction> GetActionsRunInOneCallAsList()
+ {
+ return new List<ProcessPackageAction>(ActionsRunInOneCall);
+ }
}
}
View
41 src/AddIns/Misc/PackageManagement/Test/Src/Helpers/FakePackageManagementEvents.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using ICSharpCode.PackageManagement;
using NuGet;
@@ -13,6 +14,7 @@ public class FakePackageManagementEvents : IThreadSafePackageManagementEvents
#pragma warning disable 0067
public event EventHandler PackageOperationsStarting;
public event EventHandler<AcceptLicensesEventArgs> AcceptLicenses;
+ public event EventHandler<SelectProjectsEventArgs> SelectProjects;
public event EventHandler<PackageOperationExceptionEventArgs> PackageOperationError;
public event EventHandler<ParentPackageOperationEventArgs> ParentPackageInstalled;
public event EventHandler<ParentPackageOperationEventArgs> ParentPackageUninstalled;
@@ -33,15 +35,18 @@ public void OnPackageOperationError(Exception ex)
ExceptionPassedToOnPackageOperationError = ex;
}
- public IEnumerable<IPackage> PackagesPassedToOnAcceptLicenses;
+ public IEnumerable<IPackage> LastPackagesPassedToOnAcceptLicenses;
public bool IsOnAcceptLicensesCalled;
- public bool AcceptLicensesReturnValue;
+ public bool OnAcceptLicensesReturnValue;
+ public List<IEnumerable<IPackage>> PackagesPassedToAcceptLicenses =
+ new List<IEnumerable<IPackage>>();
public bool OnAcceptLicenses(IEnumerable<IPackage> packages)
{
- PackagesPassedToOnAcceptLicenses = packages;
+ LastPackagesPassedToOnAcceptLicenses = packages;
+ PackagesPassedToAcceptLicenses.Add(packages);
IsOnAcceptLicensesCalled = true;
- return AcceptLicensesReturnValue;
+ return OnAcceptLicensesReturnValue;
}
public IPackage PackagePassedToOnParentPackageInstalled;
@@ -73,5 +78,33 @@ public void Dispose()
{
IsDisposed = true;
}
+
+ public bool OnSelectProjectsReturnValue;
+ public IEnumerable<IPackageManagementSelectedProject> SelectedProjectsPassedToOnSelectProjects;
+ public bool IsOnSelectProjectsCalled;
+ public List<string> ProjectsToSelect = new List<string>();
+
+ public bool OnSelectProjects(IEnumerable<IPackageManagementSelectedProject> selectedProjects)
+ {
+ IsOnSelectProjectsCalled = true;
+ SelectedProjectsPassedToOnSelectProjects = selectedProjects;
+
+ SetIsSelectedForSelectedProjects(selectedProjects);
+
+ return OnSelectProjectsReturnValue;
+ }
+
+ void SetIsSelectedForSelectedProjects(IEnumerable<IPackageManagementSelectedProject> selectedProjects)
+ {
+ if (ProjectsToSelect.Any()) {
+ List<IPackageManagementSelectedProject> selectedProjectsAsList = selectedProjects.ToList();
+ selectedProjects