Permalink
Browse files

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

…tep.
  • Loading branch information...
1 parent a70cd67 commit 051bda8c6a7e6ddae9ca456a501d24f01919bfd2 @mrward mrward committed Jul 16, 2011
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
@@ -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">
@@ -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">
@@ -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; }
+ }
+}
@@ -7,6 +7,11 @@ namespace ICSharpCode.PackageManagement.Design
{
public class FakeInstallPackageAction : InstallPackageAction
{
+ public FakeInstallPackageAction()
+ : this(null)
+ {
+ }
+
public FakeInstallPackageAction(IPackageManagementProject project)
: base(project, null)
{
@@ -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();
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using ICSharpCode.Core;
using ICSharpCode.PackageManagement;
using ICSharpCode.PackageManagement.Scripting;
@@ -43,14 +44,17 @@ public virtual IPackageManagementProject GetActiveProject(IPackageRepository sou
return FakeActiveProject;
}
+ public FakePackageManagementProject FakeProjectToReturnFromGetProject =
+ new FakePackageManagementProject();
+
public PackageSource PackageSourcePassedToGetProject;
public string ProjectNamePassedToGetProject;
public IPackageManagementProject GetProject(PackageSource source, string projectName)
{
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;
+ }
}
}
@@ -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; }
+ }
+}
Oops, something went wrong.

0 comments on commit 051bda8

Please sign in to comment.