IEnumerable <INuGetPackageAction> CreateInstallActions( IEnumerable <SourceRepository> repositories, Project project, IEnumerable <PackageManagementPackageReference> packages, bool licensesAccepted) { List <INuGetPackageAction> actions = null; Runtime.RunInMainThread(() => { var solutionManager = PackageManagementServices.Workspace.GetSolutionManager(project.ParentSolution); var dotNetProject = new DotNetProjectProxy((DotNetProject)project); var context = new NuGetProjectContext(); actions = packages.Select(packageReference => { var action = new InstallNuGetPackageAction( repositories, solutionManager, dotNetProject, context); action.PackageId = packageReference.Id; action.Version = packageReference.GetNuGetVersion(); action.LicensesMustBeAccepted = !licensesAccepted; return((INuGetPackageAction)action); }).ToList(); }).Wait(); return(actions); }
public static AllPackagesViewModel Create(RecentNuGetPackagesRepository recentPackagesRepository) { var solutionManager = new MonoDevelopSolutionManager(IdeApp.ProjectOperations.CurrentSelectedSolution); var dotNetProject = new DotNetProjectProxy((DotNetProject)IdeApp.ProjectOperations.CurrentSelectedProject); return(new AllPackagesViewModel(solutionManager, dotNetProject, recentPackagesRepository)); }
public static IPackageManagementProject GetProject(this IPackageManagementSolution solution, DotNetProject project) { var projectProxy = new DotNetProjectProxy(project); var repository = PackageManagementServices.PackageRepositoryCache.CreateAggregateWithPriorityMachineCacheRepository(); return(solution.GetProject(repository, projectProxy)); }
public static AllPackagesViewModel Create( DotNetProject project, RecentNuGetPackagesRepository recentPackagesRepository) { if (project == null) { return(Create(recentPackagesRepository)); } var solutionManager = PackageManagementServices.Workspace.GetSolutionManager(project.ParentSolution); var dotNetProject = new DotNetProjectProxy(project); return(new AllPackagesViewModel(solutionManager, dotNetProject, recentPackagesRepository)); }
public ProjectJsonBuildIntegratedNuGetProject( string jsonConfigPath, string msbuildProjectFilePath, DotNetProject dotNetProject, ISettings settings) : base(jsonConfigPath, msbuildProjectFilePath) { this.dotNetProject = new DotNetProjectProxy(dotNetProject); packageManagementEvents = (PackageManagementEvents)PackageManagementServices.PackageManagementEvents; string path = SettingsUtility.GetGlobalPackagesFolder(settings); packagePathResolver = new VersionFolderPathResolver(path); }
public BuildIntegratedProjectSystem( string jsonConfigPath, string msbuildProjectFilePath, DotNetProject dotNetProject, IMSBuildNuGetProjectSystem msbuildProjectSystem, string uniqueName, ISettings settings) : base(jsonConfigPath, msbuildProjectFilePath, msbuildProjectSystem) { this.dotNetProject = new DotNetProjectProxy(dotNetProject); packageManagementEvents = (PackageManagementEvents)PackageManagementServices.PackageManagementEvents; string path = SettingsUtility.GetGlobalPackagesFolder(settings); packagePathResolver = new VersionFolderPathResolver(path, normalizePackageId: false); }
async Task <List <InstallNuGetPackageAction> > CreatePackageActions(DotNetProject project, IEnumerable <TemplatePackageReference> packageReferences) { var repositoryProvider = SourceRepositoryProviderFactory.CreateSourceRepositoryProvider(); var repositories = repositoryProvider.GetRepositories().ToList(); var solutionManager = PackageManagementServices.Workspace.GetSolutionManager(project.ParentSolution); var installPackageActions = new List <InstallNuGetPackageAction> (); var context = new NuGetProjectContext(solutionManager.Settings) { FileConflictResolution = FileConflictAction.IgnoreAll }; var dotNetProject = new DotNetProjectProxy(project); var nugetProject = solutionManager.GetNuGetProject(dotNetProject); var installedPackages = (await nugetProject.GetInstalledPackagesAsync(CancellationToken.None)).ToList(); foreach (var packageReference in packageReferences) { var version = new NuGetVersion(packageReference.Version); if (!ShouldInstallPackage(packageReference.Id, version, installedPackages)) { continue; } var action = new InstallNuGetPackageAction( repositories, solutionManager, dotNetProject, context) { LicensesMustBeAccepted = false, OpenReadmeFile = false, PackageId = packageReference.Id, Version = version }; installPackageActions.Add(action); } return(installPackageActions); }
/// <summary> /// Execute will restore packages for all projects that transitively reference the project /// passed to the constructor of this restore action if this method is passed. /// </summary> void IncludeTransitiveProjectReferences() { var projects = project.DotNetProject.GetReferencingProjects(); if (!projects.Any()) { return; } referencingProjects = new List <BuildIntegratedNuGetProject> (); foreach (var referencingProject in projects) { var projectProxy = new DotNetProjectProxy(referencingProject); var currentNuGetProject = solutionManager.GetNuGetProject(projectProxy) as BuildIntegratedNuGetProject; if (currentNuGetProject != null) { referencingProjects.Add(currentNuGetProject); } } }
IEnumerable <INuGetPackageAction> CreateUninstallActions( Project project, IEnumerable <string> packages, bool removeDependencies) { List <INuGetPackageAction> actions = null; Runtime.RunInMainThread(() => { var solutionManager = PackageManagementServices.Workspace.GetSolutionManager(project.ParentSolution); var dotNetProject = new DotNetProjectProxy((DotNetProject)project); actions = packages.Select(packageId => { var action = new UninstallNuGetPackageAction( solutionManager, dotNetProject); action.PackageId = packageId; action.RemoveDependencies = removeDependencies; action.IsErrorWhenPackageNotInstalled = false; return((INuGetPackageAction)action); }).ToList(); }).Wait(); return(actions); }
IPackageManagementProject CreatePackageManagementProject (DotNetProject project) { var dotNetProject = new DotNetProjectProxy (project); return packageManagementSolution.GetProject (packageRepositoryCache.CreateAggregateRepository (), dotNetProject); }
protected override void Run() { DotNetProject project = IdeApp.ProjectOperations.CurrentSelectedProject as DotNetProject; var dotNetProjectProxy = new DotNetProjectProxy (project); if (project == null) { return; } INativeTypesHandler nativeTypesHandler = null; //SupportedLanguage names currently returns an empty item and the 'languageName' the DotNetProject //is initialized with. This might be an array to enable extension for other projects? DotNetProject //only returns an empty and languageName. See source link. // https://github.com/mono/monodevelop/blob/dcafac668cbe8f63b4e42ea7f8f032f13aba8221/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProject.cs#L198 if (project.SupportedLanguages.Contains ("C#")) { nativeTypesHandler = NativeTypeHandlers.CSharpNativeTypesHandler; } if (project.SupportedLanguages.Contains ("F#")) { nativeTypesHandler = NativeTypeHandlers.FSharpNativeTypesHandler; } if (project.SupportedLanguages.Contains ("VBNet")) { nativeTypesHandler = NativeTypeHandlers.VbNetNativeTypesHandler; } if (nativeTypesHandler == null) { throw new ArgumentNullException ("No supported languages found"); } string fileName = "ServiceReference"; int count = 0; bool exists = true; while (exists) { count++; var existingFile = project.Files.FirstOrDefault (x => x.FilePath.FileName == fileName + count.ToString () + nativeTypesHandler.CodeFileExtension); exists = existingFile != null; } var dialog = new AddReferenceDialog (fileName + count.ToString (), nativeTypesHandler); dialog.Run (); string finalFileName = dialog.ReferenceName + nativeTypesHandler.CodeFileExtension; string code = dialog.CodeTemplate; dialog.Destroy (); if (!dialog.AddReferenceSucceeded) { return; } IdeApp.Workbench.StatusBar.ShowReady (); IdeApp.Workbench.StatusBar.ShowMessage ("Adding ServiceStack Reference..."); IdeApp.Workbench.StatusBar.Pulse (); string fullPath = Path.Combine (project.BaseDirectory.FullPath.ToString (), finalFileName); using (var streamWriter = File.CreateText (fullPath)) { streamWriter.Write (code); streamWriter.Flush (); } project.AddFile (fullPath, BuildAction.Compile); try { Task.Run (() => { AddNuGetPackageReference (dotNetProjectProxy, "ServiceStack.Client"); AddNuGetPackageReference (dotNetProjectProxy, "ServiceStack.Interfaces"); AddNuGetPackageReference (dotNetProjectProxy, "ServiceStack.Text"); }).ContinueWith (task => { IdeApp.Workbench.StatusBar.Pulse (); IdeApp.Workbench.StatusBar.ShowReady (); },TaskScheduler.FromCurrentSynchronizationContext ()); } catch (Exception ex) { //TODO Error message for user var messageDialog = new MessageDialog ( (Gtk.Window)IdeApp.Workbench.RootWindow.Toplevel, DialogFlags.Modal, MessageType.Warning, ButtonsType.Close, "An error occurred trying to add required NuGet packages. Error : " + ex.Message + "\r\n\r\nGenerated service reference will require ServiceStack.Interfaces as a minimum."); messageDialog.Run (); messageDialog.Destroy (); } }
IEnumerable<INuGetPackageAction> CreateInstallActions ( IEnumerable<SourceRepository> repositories, Project project, IEnumerable<PackageManagementPackageReference> packages, bool licensesAccepted) { List<INuGetPackageAction> actions = null; Runtime.RunInMainThread (() => { var solutionManager = PackageManagementServices.Workspace.GetSolutionManager (project.ParentSolution); var dotNetProject = new DotNetProjectProxy ((DotNetProject)project); var context = new NuGetProjectContext (); actions = packages.Select (packageReference => { var action = new InstallNuGetPackageAction ( repositories, solutionManager, dotNetProject, context); action.PackageId = packageReference.Id; action.Version = packageReference.GetNuGetVersion (); action.LicensesMustBeAccepted = !licensesAccepted; return (INuGetPackageAction)action; }).ToList (); }).Wait (); return actions; }
IPackageManagementProject CreatePackageManagementProject(DotNetProject project) { var dotNetProject = new DotNetProjectProxy(project); return(packageManagementSolution.GetProject(packageRepositoryCache.CreateAggregateWithPriorityMachineCacheRepository(), dotNetProject)); }
public static IPackageManagementProject GetProject (this IPackageManagementSolution solution, DotNetProject project) { var projectProxy = new DotNetProjectProxy (project); var repository = PackageManagementServices.PackageRepositoryCache.CreateAggregateWithPriorityMachineCacheRepository (); return solution.GetProject (repository, projectProxy); }
IEnumerable<INuGetPackageAction> CreateUninstallActions ( Project project, IEnumerable<string> packages, bool removeDependencies) { List<INuGetPackageAction> actions = null; Runtime.RunInMainThread (() => { var solutionManager = PackageManagementServices.Workspace.GetSolutionManager (project.ParentSolution); var dotNetProject = new DotNetProjectProxy ((DotNetProject)project); actions = packages.Select (packageId => { var action = new UninstallNuGetPackageAction ( solutionManager, dotNetProject); action.PackageId = packageId; action.RemoveDependencies = removeDependencies; action.IsErrorWhenPackageNotInstalled = false; return (INuGetPackageAction)action; }).ToList (); }).Wait (); return actions; }
public static IPackageManagementProject GetProject(this IPackageManagementSolution solution, DotNetProject project) { var projectProxy = new DotNetProjectProxy(project); return(solution.GetProject(projectProxy)); }
static Task<AnalyzersFromAssembly> GetProjectDiagnosticsAsync (Project project, string language, CancellationToken cancellationToken) { if (project == null) return Task.FromResult (AnalyzersFromAssembly.Empty); AnalyzersFromAssembly result; if (diagnosticCache.TryGetValue(project, out result)) return Task.FromResult (result); result = new AnalyzersFromAssembly (); var dotNetProject = project as DotNetProject; if (dotNetProject != null) { var proxy = new DotNetProjectProxy (dotNetProject); if (proxy.HasPackages ()) { var packagesPath = new SolutionPackageRepositoryPath (proxy); foreach (var file in Directory.EnumerateFiles (packagesPath.PackageRepositoryPath, "*.dll", SearchOption.AllDirectories)) { cancellationToken.ThrowIfCancellationRequested (); try { var asm = Assembly.LoadFrom (file); result.AddAssembly (asm); } catch (Exception) { } } } } diagnosticCache[project] = result; return Task.FromResult (result); }