protected bool ShowLicenseAgreement( IPackage package, IVsPackageManager packageManager, IEnumerable<Project> projects, out IList<PackageOperation> operations) { var allOperations = new List<PackageOperation>(); foreach (Project project in projects) { var walker = new InstallWalker( packageManager.GetProjectManager(project).LocalRepository, packageManager.SourceRepository, project.GetTargetFrameworkName(), this, ignoreDependencies: false, allowPrereleaseVersions: IncludePrerelease, dependencyVersion: packageManager.DependencyVersion); allOperations.AddRange(walker.ResolveOperations(package)); } operations = allOperations.Reduce(); return ShowLicenseAgreement(packageManager, operations); }
protected void ExecuteCommandOnProject(Project activeProject, PackageItem item, IVsPackageManager activePackageManager, IList<PackageOperation> operations) { IProjectManager projectManager = null; try { projectManager = activePackageManager.GetProjectManager(activeProject); RegisterPackageOperationEvents(activePackageManager, projectManager); ExecuteCommand(projectManager, item, activePackageManager, operations); } finally { if (projectManager != null) { UnregisterPackageOperationEvents(activePackageManager, projectManager); } } }
public void OnBeforeAddPackageReference(Project project) { RegisterPackageOperationEvents(null, _activePackageManager.GetProjectManager(project)); }
protected override bool ExecuteCore(PackageItem item) { _activePackageManager = GetActivePackageManager(); ShowProgressWindow(); IList<Project> selectedProjectsList; if (_activePackageManager.IsProjectLevel(item.PackageIdentity)) { HideProgressWindow(); var selectedProjects = _userNotifierServices.ShowProjectSelectorWindow( Resources.Dialog_UpdatesSolutionInstruction, item.PackageIdentity, // Selector function to return the initial checkbox state for a Project. // We check a project if it has the current package installed by Id, but not version project => _activePackageManager.GetProjectManager(project).LocalRepository.Exists(item.Id), project => { var localRepository = _activePackageManager.GetProjectManager(project).LocalRepository; // for the Updates solution dialog, we only enable a project if it has a old version of // the package installed. return localRepository.Exists(item.Id) && !localRepository.Exists(item.Id, item.PackageIdentity.Version); } ); if (selectedProjects == null) { // user presses Cancel button on the Solution dialog return false; } selectedProjectsList = selectedProjects.ToList(); if (selectedProjectsList.Count == 0) { return false; } } else { // solution package. just update into the solution selectedProjectsList = new Project[0]; } IList<PackageOperation> operations; bool acceptLicense = CheckPSScriptAndShowLicenseAgreement(item, _activePackageManager, out operations); if (!acceptLicense) { return false; } try { RegisterPackageOperationEvents(_activePackageManager, null); _activePackageManager.UpdatePackage( selectedProjectsList, item.PackageIdentity, operations, updateDependencies: true, allowPrereleaseVersions: false, logger: this, eventListener: this); } finally { UnregisterPackageOperationEvents(_activePackageManager, null); } return true; }
internal void InstallPackage(IPackageRepository repository, Project project, string packageId, SemanticVersion version, bool ignoreDependencies, bool skipAssemblyReferences) { if (project == null) { throw new ArgumentNullException("project"); } if (repository == null) { throw new ArgumentNullException("repository"); } using (_vsCommonOperations.SaveSolutionExplorerNodeStates(_solutionManager)) { IVsPackageManager packageManager = _packageManagerFactory.CreatePackageManager(repository, useFallbackForDependencies: false); IProjectManager projectManager = packageManager.GetProjectManager(project); EventHandler <PackageOperationEventArgs> installedHandler = (sender, e) => { _scriptExecutor.ExecuteInitScript( e.InstallPath, e.Package, NullLogger.Instance); }; EventHandler <PackageOperationEventArgs> addedHandler = (sender, e) => { _scriptExecutor.ExecuteScript( e.InstallPath, PowerShellScripts.Install, e.Package, project, project.GetTargetFrameworkName(), NullLogger.Instance); }; bool oldBindingRedirectValue = packageManager.BindingRedirectEnabled; try { projectManager.PackageReferenceAdded += addedHandler; packageManager.PackageInstalled += installedHandler; // if skipping assembly references, disable binding redirects too. packageManager.BindingRedirectEnabled = !skipAssemblyReferences; // locate the package to install IPackage package = PackageRepositoryHelper.ResolvePackage( packageManager.SourceRepository, packageManager.LocalRepository, packageId, version, allowPrereleaseVersions: true); if (skipAssemblyReferences) { package = new SkipAssemblyReferencesPackage(package); } // resolve actions var resolver = new ActionResolver() { Logger = NullLogger.Instance, DependencyVersion = packageManager.DependencyVersion, IgnoreDependencies = ignoreDependencies, AllowPrereleaseVersions = true }; resolver.AddOperation(PackageAction.Install, package, projectManager); var actions = resolver.ResolveActions(); // execute actions var actionExecutor = new ActionExecutor(); actionExecutor.Execute(actions); } finally { packageManager.BindingRedirectEnabled = oldBindingRedirectValue; projectManager.PackageReferenceAdded -= addedHandler; packageManager.PackageInstalled -= installedHandler; } } }
private void EnablePackageRestore(Project project, IVsPackageManager packageManager) { var projectManager = packageManager.GetProjectManager(project); var projectPackageReferences = GetPackageReferences(projectManager); if (projectPackageReferences.IsEmpty()) { // don't enable package restore for the project if it doesn't have at least one // nuget package installed return; } EnablePackageRestore(project); }
protected IEnumerable<Resolver.PackageAction> ResolveActionsForInstall( IPackage package, IVsPackageManager packageManager, IEnumerable<Project> selectedProjectsList) { // Resolve operations var resolver = new Resolver.ActionResolver() { Logger = this, DependencyVersion = packageManager.DependencyVersion, AllowPrereleaseVersions = IncludePrerelease }; foreach (var project in selectedProjectsList) { var projectManager = packageManager.GetProjectManager(project); projectManager.Logger = this; resolver.AddOperation( PackageAction.Install, package, projectManager); } var actions = resolver.ResolveActions(); return actions; }
protected override bool ExecuteCore(PackageItem item) { _activePackageManager = GetActivePackageManager(); using (_activePackageManager.SourceRepository.StartOperation(RepositoryOperationNames.Update, item.Id, item.Version)) { ShowProgressWindow(); IList<Project> selectedProjectsList; bool isProjectLevel = _activePackageManager.IsProjectLevel(item.PackageIdentity); if (isProjectLevel) { HideProgressWindow(); var selectedProjects = _userNotifierServices.ShowProjectSelectorWindow( Resources.Dialog_UpdatesSolutionInstruction, item.PackageIdentity, // Selector function to return the initial checkbox state for a Project. // We check a project if it has the current package installed by Id, but not version project => { var localRepository = _activePackageManager.GetProjectManager(project).LocalRepository; return localRepository.Exists(item.Id) && IsVersionConstraintSatisfied(item, localRepository); }, project => { var localRepository = _activePackageManager.GetProjectManager(project).LocalRepository; // for the Updates solution dialog, we only enable a project if it has an old version of // the package installed. return localRepository.Exists(item.Id) && !localRepository.Exists(item.Id, item.PackageIdentity.Version) && IsVersionConstraintSatisfied(item, localRepository); } ); if (selectedProjects == null) { // user presses Cancel button on the Solution dialog return false; } selectedProjectsList = selectedProjects.ToList(); if (selectedProjectsList.Count == 0) { return false; } ShowProgressWindow(); } else { // solution package. just install into the active project. selectedProjectsList = new Project[] { _solutionManager.DefaultProject }; } // resolve operations var actionsByProject = ResolveActionsByProjectForInstall( item.PackageIdentity, _activePackageManager, selectedProjectsList); // ask for license agreement var allActions = new List<Resolver.PackageAction>(); foreach (var actions in actionsByProject.Values) { allActions.AddRange(actions); } bool acceptLicense = ShowLicenseAgreement(allActions); if (!acceptLicense) { return false; } var actionExecutor = new Resolver.ActionExecutor(); actionExecutor.Logger = this; actionExecutor.PackageOperationEventListener = this; actionExecutor.CatchProjectOperationException = true; // execute operations by project foreach (var actionsForOneProject in actionsByProject) { var projectManager = actionsForOneProject.Key; var project = ((VsProjectSystem)(projectManager.Project)).Project; try { RegisterPackageOperationEvents(_activePackageManager, projectManager); actionExecutor.Execute(actionsForOneProject.Value); } catch (Exception ex) { AddFailedProject(project, ex); } finally { UnregisterPackageOperationEvents(_activePackageManager, projectManager); } } return true; } }
private void SetupProviders(Project activeProject, DTE dte, IVsPackageManagerFactory packageManagerFactory, IPackageRepositoryFactory packageRepositoryFactory, IPackageSourceProvider packageSourceProvider, ProviderServices providerServices, IHttpClientEvents httpClientEvents, ISolutionManager solutionManager, IPackageRestoreManager packageRestoreManager, RestartRequestBar restartRequestBar) { // This package manager is not used for installing from a remote source, and therefore does not need a fallback repository for resolving dependencies IVsPackageManager packageManager = packageManagerFactory.CreatePackageManager(ServiceLocator.GetInstance <IPackageRepository>(), useFallbackForDependencies: false); IPackageRepository localRepository; // we need different sets of providers depending on whether the dialog is open for solution or a project OnlineProvider onlineProvider; InstalledProvider installedProvider; UpdatesProvider updatesProvider; if (activeProject == null) { Title = String.Format( CultureInfo.CurrentUICulture, NuGet.Dialog.Resources.Dialog_Title, dte.Solution.GetName() + ".sln"); localRepository = packageManager.LocalRepository; onlineProvider = new SolutionOnlineProvider( localRepository, Resources, packageRepositoryFactory, packageSourceProvider, packageManagerFactory, providerServices, httpClientEvents, solutionManager); installedProvider = new SolutionInstalledProvider( packageManager, localRepository, Resources, providerServices, httpClientEvents, solutionManager, packageRestoreManager); updatesProvider = new SolutionUpdatesProvider( localRepository, Resources, packageRepositoryFactory, packageSourceProvider, packageManagerFactory, providerServices, httpClientEvents, solutionManager); } else { IProjectManager projectManager = packageManager.GetProjectManager(activeProject); localRepository = projectManager.LocalRepository; Title = String.Format( CultureInfo.CurrentUICulture, NuGet.Dialog.Resources.Dialog_Title, activeProject.GetDisplayName()); onlineProvider = new OnlineProvider( activeProject, localRepository, Resources, packageRepositoryFactory, packageSourceProvider, packageManagerFactory, providerServices, httpClientEvents, solutionManager); installedProvider = new InstalledProvider( packageManager, activeProject, localRepository, Resources, providerServices, httpClientEvents, solutionManager, packageRestoreManager); updatesProvider = new UpdatesProvider( activeProject, localRepository, Resources, packageRepositoryFactory, packageSourceProvider, packageManagerFactory, providerServices, httpClientEvents, solutionManager); } explorer.Providers.Add(installedProvider); explorer.Providers.Add(onlineProvider); explorer.Providers.Add(updatesProvider); installedProvider.IncludePrerelease = onlineProvider.IncludePrerelease = updatesProvider.IncludePrerelease = _providerSettings.IncludePrereleasePackages; installedProvider.ExecuteCompleted += restartRequestBar.NotifyOnUnsuccessfulUninstall; }
protected override bool ExecuteCore(PackageItem item) { _activePackageManager = GetActivePackageManager(); using (_activePackageManager.SourceRepository.StartOperation(RepositoryOperationNames.Update)) { ShowProgressWindow(); IList <Project> selectedProjectsList; bool isProjectLevel = _activePackageManager.IsProjectLevel(item.PackageIdentity); if (isProjectLevel) { HideProgressWindow(); var selectedProjects = _userNotifierServices.ShowProjectSelectorWindow( Resources.Dialog_UpdatesSolutionInstruction, item.PackageIdentity, // Selector function to return the initial checkbox state for a Project. // We check a project if it has the current package installed by Id, but not version project => _activePackageManager.GetProjectManager(project).LocalRepository.Exists(item.Id), project => { var localRepository = _activePackageManager.GetProjectManager(project).LocalRepository; // for the Updates solution dialog, we only enable a project if it has an old version of // the package installed. return(localRepository.Exists(item.Id) && !localRepository.Exists(item.Id, item.PackageIdentity.Version)); } ); if (selectedProjects == null) { // user presses Cancel button on the Solution dialog return(false); } selectedProjectsList = selectedProjects.ToList(); if (selectedProjectsList.Count == 0) { return(false); } ShowProgressWindow(); } else { // solution package. just update into the solution selectedProjectsList = new Project[0]; } IList <PackageOperation> operations; bool acceptLicense = isProjectLevel ? ShowLicenseAgreement(item.PackageIdentity, _activePackageManager, selectedProjectsList, out operations) : ShowLicenseAgreement(item.PackageIdentity, _activePackageManager, targetFramework: null, operations: out operations); if (!acceptLicense) { return(false); } if (!isProjectLevel && operations.Any()) { // When dealing with solution level packages, only the set of actions specified under operations are executed. // In such a case, no operation to uninstall the current package is specified. We'll identify the package that is being updated and // explicitly add a uninstall operation. var packageToUpdate = _activePackageManager.LocalRepository.FindPackage(item.Id); if (packageToUpdate != null) { operations.Insert(0, new PackageOperation(packageToUpdate, PackageAction.Uninstall)); } } try { RegisterPackageOperationEvents(_activePackageManager, null); _activePackageManager.UpdatePackage( selectedProjectsList, item.PackageIdentity, operations, updateDependencies: true, allowPrereleaseVersions: IncludePrerelease, logger: this, eventListener: this); } finally { UnregisterPackageOperationEvents(_activePackageManager, null); } return(true); } }
// Resolve actions to update all packages in all projects. private IEnumerable<Resolver.PackageAction> ResolveActionsForUpdateAll(IVsPackageManager activePackageManager) { var resolver = new ActionResolver() { Logger = this, AllowPrereleaseVersions = IncludePrerelease, DependencyVersion = activePackageManager.DependencyVersion }; var allPackages = SelectedNode.GetPackages(String.Empty, IncludePrerelease); foreach (Project project in _solutionManager.GetProjects()) { IProjectManager projectManager = activePackageManager.GetProjectManager(project); foreach (var package in allPackages) { // Update if an older version package is installed in the project var localPackge = projectManager.LocalRepository.FindPackage(package.Id); if (localPackge != null && localPackge.Version < package.Version) { resolver.AddOperation(PackageAction.Install, package, projectManager); } } } var actions = resolver.ResolveActions(); return actions; }
private void SetupProviders(DTE dte, IVsPackageManagerFactory packageManagerFactory, IPackageRepositoryFactory packageRepositoryFactory, IPackageSourceProvider packageSourceProvider, ProviderServices providerServices, IPackageRepository recentPackagesRepository, IHttpClientEvents httpClientEvents) { IVsPackageManager packageManager = packageManagerFactory.CreatePackageManager(); Project activeProject = dte.GetActiveProject(); // Create a cached project manager so that checking for installed packages is fast IProjectManager projectManager = packageManager.GetProjectManager(activeProject); var recentProvider = new RecentProvider( activeProject, projectManager, Resources, packageRepositoryFactory, packageManagerFactory, recentPackagesRepository, packageSourceProvider, providerServices, httpClientEvents); var updatesProvider = new UpdatesProvider( activeProject, projectManager, Resources, packageRepositoryFactory, packageSourceProvider, packageManagerFactory, providerServices, httpClientEvents); var onlineProvider = new OnlineProvider( activeProject, projectManager, Resources, packageRepositoryFactory, packageSourceProvider, packageManagerFactory, providerServices, httpClientEvents); var installedProvider = new InstalledProvider( packageManager, activeProject, projectManager, Resources, providerServices, httpClientEvents); explorer.Providers.Add(installedProvider); explorer.Providers.Add(onlineProvider); explorer.Providers.Add(updatesProvider); explorer.Providers.Add(recentProvider); // retrieve the selected provider from the settings int selectedProvider = Math.Min(3, _selectedProviderSettings.SelectedProvider); explorer.SelectedProvider = explorer.Providers[selectedProvider]; }
protected override bool ExecuteCore(PackageItem item) { _activePackageManager = GetActivePackageManager(); using (_activePackageManager.SourceRepository.StartOperation(RepositoryOperationNames.Update, item.Id, item.Version)) { ShowProgressWindow(); IList <Project> selectedProjectsList; bool isProjectLevel = _activePackageManager.IsProjectLevel(item.PackageIdentity); if (isProjectLevel) { HideProgressWindow(); var selectedProjects = _userNotifierServices.ShowProjectSelectorWindow( Resources.Dialog_UpdatesSolutionInstruction, item.PackageIdentity, // Selector function to return the initial checkbox state for a Project. // We check a project if it has the current package installed by Id, but not version project => { var localRepository = _activePackageManager.GetProjectManager(project).LocalRepository; return(localRepository.Exists(item.Id) && IsVersionConstraintSatisfied(item, localRepository)); }, project => { var localRepository = _activePackageManager.GetProjectManager(project).LocalRepository; // for the Updates solution dialog, we only enable a project if it has an old version of // the package installed. return(localRepository.Exists(item.Id) && !localRepository.Exists(item.Id, item.PackageIdentity.Version) && IsVersionConstraintSatisfied(item, localRepository)); } ); if (selectedProjects == null) { // user presses Cancel button on the Solution dialog return(false); } selectedProjectsList = selectedProjects.ToList(); if (selectedProjectsList.Count == 0) { return(false); } ShowProgressWindow(); } else { // solution package. just install into the active project. selectedProjectsList = new Project[] { _solutionManager.DefaultProject }; } // resolve operations var actionsByProject = ResolveActionsByProjectForInstall( item.PackageIdentity, _activePackageManager, selectedProjectsList); // ask for license agreement var allActions = new List <Resolver.PackageAction>(); foreach (var actions in actionsByProject.Values) { allActions.AddRange(actions); } bool acceptLicense = ShowLicenseAgreement(allActions); if (!acceptLicense) { return(false); } var actionExecutor = new Resolver.ActionExecutor(); actionExecutor.Logger = this; actionExecutor.PackageOperationEventListener = this; actionExecutor.CatchProjectOperationException = true; // execute operations by project foreach (var actionsForOneProject in actionsByProject) { var projectManager = actionsForOneProject.Key; var project = ((VsProjectSystem)(projectManager.Project)).Project; try { RegisterPackageOperationEvents(_activePackageManager, projectManager); actionExecutor.Execute(actionsForOneProject.Value); } catch (Exception ex) { AddFailedProject(project, ex); } finally { UnregisterPackageOperationEvents(_activePackageManager, projectManager); } } return(true); } }
// Resolve actions to install a package into the projects. // The returned actions are grouped by project. protected Dictionary<IProjectManager, IEnumerable<Resolver.PackageAction>> ResolveActionsByProjectForInstall( IPackage package, IVsPackageManager packageManager, IEnumerable<Project> selectedProjectsList) { var retValue = new Dictionary<IProjectManager, IEnumerable<Resolver.PackageAction>>(); foreach (var project in selectedProjectsList) { var projectManager = packageManager.GetProjectManager(project); projectManager.Logger = this; var resolver = new Resolver.ActionResolver() { Logger = this, DependencyVersion = packageManager.DependencyVersion, AllowPrereleaseVersions = IncludePrerelease }; resolver.AddOperation( PackageAction.Install, package, projectManager); var actions = resolver.ResolveActions(); if (actions.Any()) { retValue[projectManager] = actions; } } return retValue; }
protected bool CheckPSScriptAndShowLicenseAgreement( PackageItem item, IList<Project> projects, IVsPackageManager packageManager, out IList<PackageOperation> operations) { ShowProgressWindow(); // combine the operations of all selected project var allOperations = new List<PackageOperation>(); foreach (Project project in projects) { IProjectManager projectManager = packageManager.GetProjectManager(project); IList<PackageOperation> projectOperations; CheckInstallPSScripts( item.PackageIdentity, projectManager.LocalRepository, packageManager.SourceRepository, project.GetTargetFrameworkName(), IncludePrerelease, out projectOperations); allOperations.AddRange(projectOperations); } // reduce the operations before checking for license agreements operations = allOperations.Reduce(); return ShowLicenseAgreement(packageManager, operations); }
private void SetupProviders(Project activeProject, DTE dte, IVsPackageManagerFactory packageManagerFactory, IPackageRepositoryFactory packageRepositoryFactory, IPackageSourceProvider packageSourceProvider, ProviderServices providerServices, IHttpClientEvents httpClientEvents, ISolutionManager solutionManager, IPackageRestoreManager packageRestoreManager, RestartRequestBar restartRequestBar) { IVsPackageManager packageManager = packageManagerFactory.CreatePackageManagerToManageInstalledPackages(); IPackageRepository localRepository; // we need different sets of providers depending on whether the dialog is open for solution or a project OnlineProvider onlineProvider; InstalledProvider installedProvider; UpdatesProvider updatesProvider; if (activeProject == null) { Title = String.Format( CultureInfo.CurrentUICulture, NuGet.Dialog.Resources.Dialog_Title, dte.Solution.GetName() + ".sln"); localRepository = packageManager.LocalRepository; onlineProvider = new SolutionOnlineProvider( localRepository, Resources, packageRepositoryFactory, packageSourceProvider, packageManagerFactory, providerServices, httpClientEvents, solutionManager); installedProvider = new SolutionInstalledProvider( packageManager, localRepository, Resources, providerServices, httpClientEvents, solutionManager, packageRestoreManager); updatesProvider = new SolutionUpdatesProvider( localRepository, Resources, packageRepositoryFactory, packageSourceProvider, packageManagerFactory, providerServices, httpClientEvents, solutionManager); } else { IProjectManager projectManager = packageManager.GetProjectManager(activeProject); localRepository = projectManager.LocalRepository; Title = String.Format( CultureInfo.CurrentUICulture, NuGet.Dialog.Resources.Dialog_Title, activeProject.GetDisplayName()); onlineProvider = new OnlineProvider( activeProject, localRepository, Resources, packageRepositoryFactory, packageSourceProvider, packageManagerFactory, providerServices, httpClientEvents, solutionManager); installedProvider = new InstalledProvider( packageManager, activeProject, localRepository, Resources, providerServices, httpClientEvents, solutionManager, packageRestoreManager); updatesProvider = new UpdatesProvider( activeProject, localRepository, Resources, packageRepositoryFactory, packageSourceProvider, packageManagerFactory, providerServices, httpClientEvents, solutionManager); } explorer.Providers.Add(installedProvider); explorer.Providers.Add(onlineProvider); explorer.Providers.Add(updatesProvider); installedProvider.IncludePrerelease = onlineProvider.IncludePrerelease = updatesProvider.IncludePrerelease = _providerSettings.IncludePrereleasePackages; installedProvider.ExecuteCompletedCallback = onlineProvider.ExecuteCompletedCallback = updatesProvider.ExecuteCompletedCallback = restartRequestBar.CheckForUnsuccessfulUninstall; Loaded += (o, e) => restartRequestBar.CheckForUnsuccessfulUninstall(); }
protected override bool ExecuteCore(PackageItem item) { _activePackageManager = GetActivePackageManager(); using (_activePackageManager.SourceRepository.StartOperation(RepositoryOperationNames.Update)) { ShowProgressWindow(); IList<Project> selectedProjectsList; bool isProjectLevel = _activePackageManager.IsProjectLevel(item.PackageIdentity); if (isProjectLevel) { HideProgressWindow(); var selectedProjects = _userNotifierServices.ShowProjectSelectorWindow( Resources.Dialog_UpdatesSolutionInstruction, item.PackageIdentity, // Selector function to return the initial checkbox state for a Project. // We check a project if it has the current package installed by Id, but not version project => _activePackageManager.GetProjectManager(project).LocalRepository.Exists(item.Id), project => { var localRepository = _activePackageManager.GetProjectManager(project).LocalRepository; // for the Updates solution dialog, we only enable a project if it has an old version of // the package installed. return localRepository.Exists(item.Id) && !localRepository.Exists(item.Id, item.PackageIdentity.Version); } ); if (selectedProjects == null) { // user presses Cancel button on the Solution dialog return false; } selectedProjectsList = selectedProjects.ToList(); if (selectedProjectsList.Count == 0) { return false; } ShowProgressWindow(); } else { // solution package. just update into the solution selectedProjectsList = new Project[0]; } IList<PackageOperation> operations; bool acceptLicense = isProjectLevel ? ShowLicenseAgreement(item.PackageIdentity, _activePackageManager, selectedProjectsList, out operations) : ShowLicenseAgreement(item.PackageIdentity, _activePackageManager, targetFramework: null, operations: out operations); if (!acceptLicense) { return false; } if (!isProjectLevel && operations.Any()) { // When dealing with solution level packages, only the set of actions specified under operations are executed. // In such a case, no operation to uninstall the current package is specified. We'll identify the package that is being updated and // explicitly add a uninstall operation. var packageToUpdate = _activePackageManager.LocalRepository.FindPackage(item.Id); if (packageToUpdate != null) { operations.Insert(0, new PackageOperation(packageToUpdate, PackageAction.Uninstall)); } } try { RegisterPackageOperationEvents(_activePackageManager, null); _activePackageManager.UpdatePackage( selectedProjectsList, item.PackageIdentity, operations, updateDependencies: true, allowPrereleaseVersions: IncludePrerelease, logger: this, eventListener: this); } finally { UnregisterPackageOperationEvents(_activePackageManager, null); } return true; } }
/// <summary> /// Gets all package references in all projects of the current solution plus package /// references specified in the solution packages.config /// </summary> private IEnumerable <PackageReference> GetAllPackageReferences(IVsPackageManager packageManager) { IEnumerable <PackageReference> projectReferences = from project in _solutionManager.GetProjects() from reference in GetPackageReferences(packageManager.GetProjectManager(project)) select reference; var localRepository = packageManager.LocalRepository as SharedPackageRepository; if (localRepository != null) { IEnumerable <PackageReference> solutionReferences = localRepository.PackageReferenceFile.GetPackageReferences(); return(projectReferences.Concat(solutionReferences).Distinct()); } return(projectReferences.Distinct()); }
/// <summary> /// Gets all package references in all projects of the current solution plus package /// references specified in the solution packages.config /// </summary> private IEnumerable<PackageReference> GetAllPackageReferences(IVsPackageManager packageManager) { IEnumerable<PackageReference> projectReferences = from project in _solutionManager.GetProjects() from reference in GetPackageReferences(packageManager.GetProjectManager(project)) select reference; var localRepository = packageManager.LocalRepository as SharedPackageRepository; if (localRepository != null) { IEnumerable<PackageReference> solutionReferences = localRepository.PackageReferenceFile.GetPackageReferences(); return projectReferences.Concat(solutionReferences).Distinct(); } return projectReferences.Distinct(); }
/// <summary> /// Gets all package references in all projects of the current solution. /// </summary> private IEnumerable<PackageReference> GetAllPackageReferences(IVsPackageManager packageManager) { return from project in _solutionManager.GetProjects() from reference in GetPackageReferences(packageManager.GetProjectManager(project)) select reference; }