async Task <IEnumerable <PackageReference> > GetInstalledPackages(DotNetProject project) { var solutionManager = project.GetSolutionManager(); var nugetProject = project.CreateNuGetProject(solutionManager); return(await Task.Run(() => nugetProject.GetInstalledPackagesAsync(Token)).ConfigureAwait(false)); }
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)); }
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; } } }