public async Task <IEnumerable <NuGetProjectAction> > PreviewUninstallPackageAsync( CancellationToken token) { solutionManager = project.GetSolutionManager(); nugetProject = project.CreateNuGetProject(solutionManager); packageManager = new MonoDevelopNuGetPackageManager(solutionManager); uninstallationContext = new UninstallationContext(message.RemoveDependencies, message.Force); projectContext = new ConsoleHostNuGetProjectContext(solutionManager.Settings); return(await packageManager.PreviewUninstallPackageAsync( nugetProject, message.PackageId, uninstallationContext, projectContext, token ).ConfigureAwait(false)); }
Task UpdateNuGetPackage(DotNetProject project, string packageId) { var solutionManager = new MonoDevelopSolutionManager(project.ParentSolution); var context = CreateNuGetProjectContext(solutionManager.Settings); var packageManager = new MonoDevelopNuGetPackageManager(solutionManager); var action = new UpdateNuGetPackageAction( solutionManager, new DotNetProjectProxy(project), context, packageManager, PackageManagementServices.PackageManagementEvents) { PackageId = packageId }; return(Task.Run(() => { action.Execute(); })); }
public async Task <IEnumerable <NuGetProjectAction> > PreviewInstallPackage( SourceCacheContext sourceCacheContext, CancellationToken token) { solutionManager = project.GetSolutionManager(); nugetProject = project.CreateNuGetProject(solutionManager); packageManager = new MonoDevelopNuGetPackageManager(solutionManager); var repositoryProvider = solutionManager.CreateSourceRepositoryProvider(); var repositories = repositoryProvider.GetRepositories(message.PackageSources); projectContext = new ConsoleHostNuGetProjectContext( solutionManager.Settings, message.FileConflictAction.ToFileConflictActionEnum()); var dependencyBehavior = message.DependencyBehavior.ToDependencyBehaviorEnum(); NuGetVersion version = null; if (string.IsNullOrEmpty(message.PackageVersion)) { version = await GetLatestPackageVersion(repositories, dependencyBehavior, sourceCacheContext, token); } else { version = NuGetVersion.Parse(message.PackageVersion); } identity = new PackageIdentity(message.PackageId, version); var resolutionContext = new ResolutionContext( dependencyBehavior, message.AllowPrerelease, true, VersionConstraints.None, new GatherCache(), sourceCacheContext ); try { return(await packageManager.PreviewInstallPackageAsync( nugetProject, identity, resolutionContext, projectContext, repositories, null, token ).ConfigureAwait(false)); } catch (InvalidOperationException ex) { if (ex.InnerException is PackageAlreadyInstalledException) { IsPackageAlreadyInstalled = true; return(Enumerable.Empty <NuGetProjectAction> ()); } else { throw; } } }