public static async Task Extract (
			Solution solution,
			PackageIdentity packageIdentity,
			DownloadResourceResult downloadResult,
			CancellationToken token)
		{
			string globalPackagesFolder = await GetPackagesDirectory (solution);

			var defaultPackagePathResolver = new VersionFolderPathResolver (globalPackagesFolder);

			string hashPath = defaultPackagePathResolver.GetHashPath (packageIdentity.Id, packageIdentity.Version);

			if (File.Exists (hashPath))
				return;

			var versionFolderPathContext = new VersionFolderPathContext (
				packageIdentity,
				globalPackagesFolder,
				NullLogger.Instance,
				PackageSaveMode.Defaultv3,
				PackageExtractionBehavior.XmlDocFileSaveMode);

			downloadResult.PackageStream.Position = 0;
			await PackageExtractor.InstallFromSourceAsync (
				stream => downloadResult.PackageStream.CopyToAsync (stream, BufferSize, token),
				versionFolderPathContext,
				token);
		}
		public static string GetPackagesRootDirectory (Solution solution)
		{
			var solutionManager = PackageManagementServices.Workspace.GetSolutionManager (solution);
			string globalPackagesPath = SettingsUtility.GetGlobalPackagesFolder (solutionManager.Settings);

			return new FilePath (globalPackagesPath).FullPath;
		}
Пример #3
0
        public IEnumerable<string> GetAllProjectFileNames(IFileSystem fileSystem, string solutionFile)
        {
            var solution = new Solution(fileSystem, solutionFile);
            var solutionDirectory = Path.GetDirectoryName(fileSystem.GetFullPath(solutionFile));

            return solution.Projects.Where(p => !p.IsSolutionFolder)
                .Select(p => Path.Combine(solutionDirectory, p.RelativePath));
        }
        public void Init()
        {
            var solution = new Solution(this.Solution.DirectoryName + Path.DirectorySeparatorChar + this.Solution.SolutionName);

            Trace.TraceInformation("Processing solution <"+solution.SolutionName+">");

            using (var pc = new ProjectCollection())
            {
                foreach (ProjectInSolution prj in solution.Projects.Where(p => !p.IsSolutionFolder))
                {
                    var project = new ProjectProcessor(pc.LoadProject(Path.Combine(solution.DirectoryName, prj.RelativePath)));
                    project.Init();
                }
            }
        }
 public SolutionProcessor(string solution)
 {
     var configuration = Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyConfigurationAttribute>();
     this.Solution = new Solution(solution);
 }
		async Task RestoreAndCheckForUpdates (Solution solution)
		{
			bool checkUpdatesAfterRestore = ShouldCheckForUpdates && AnyProjectHasPackages (solution);

			var action = new RestoreAndCheckForUpdatesAction (solution) {
				CheckForUpdatesAfterRestore = checkUpdatesAfterRestore
			};
			bool packagesToRestore = await action.HasMissingPackages ();
			if (packagesToRestore) {
				ProgressMonitorStatusMessage message = ProgressMonitorStatusMessageFactory.CreateRestoringPackagesInSolutionMessage ();
				PackageManagementServices.BackgroundPackageActionRunner.Run (message, action);
			} else if (checkUpdatesAfterRestore) {
				CheckForUpdates (solution);
			}
		}
		void ClearUpdatedPackagesInSolution (Solution solution)
		{
			PackageManagementServices.UpdatedPackagesInWorkspace.Clear (new SolutionProxy (solution));
		}
		void CheckForUpdates (Solution solution)
		{
			CheckForUpdates (new SolutionProxy (solution));
		}
		bool AnyProjectHasPackages (Solution solution)
		{
			return solution
				.GetAllProjectsWithPackages ()
				.Any ();
		}
		static Task<string> GetPackagesDirectory (Solution solution)
		{
			return Runtime.RunInMainThread (() => {
				return MSBuildNuGetImportGenerator.GetPackagesRootDirectory (solution);
			});
		}