Esempio n. 1
0
        /// <summary>
        /// Downloads the packages from the provided sources, if not already downloaded.
        /// Unpacks the packages, if not already unpacked.
        /// </summary>
        public InstalledPackages GetPackages()
        {
            var sw = Stopwatch.StartNew();
            var installedPackages = new List <InstalledPackage>();

            // These Rhetos framework packages are already integrated in Rhetos application when using DeployPackages build process.
            installedPackages.Add(new InstalledPackage("Rhetos", SystemUtility.GetRhetosVersion(), new List <PackageRequest>(), Paths.RhetosServerRootPath,
                                                       new PackageRequest {
                Id = "Rhetos", VersionsRange = null, Source = null, RequestedBy = "Rhetos framework"
            }, ".", new List <ContentFile> {
            }));
            installedPackages.Add(new InstalledPackage("Rhetos.MSBuild", SystemUtility.GetRhetosVersion(), new List <PackageRequest>(), Paths.RhetosServerRootPath,
                                                       new PackageRequest {
                Id = "Rhetos.MSBuild", VersionsRange = null, Source = null, RequestedBy = "Rhetos framework"
            }, ".", new List <ContentFile> {
            }));

            var binFileSyncer = new FileSyncer(_logProvider);

            binFileSyncer.AddDestinations(Paths.PluginsFolder); // Even if there are no packages, this folder must be emptied.

            _filesUtility.SafeCreateDirectory(_packagesCacheFolder);
            var packageRequests = _deploymentConfiguration.PackageRequests;

            while (packageRequests.Any())
            {
                var newDependencies = new List <PackageRequest>();
                foreach (var request in packageRequests)
                {
                    _logger.Trace(() => $"Getting package {request.ReportIdVersionRequestSource()}.");
                    if (!CheckAlreadyDownloaded(request, installedPackages))
                    {
                        var installedPackage = GetPackage(request, binFileSyncer);
                        ValidatePackage(installedPackage, request);
                        installedPackages.Add(installedPackage);
                        newDependencies.AddRange(installedPackage.Dependencies);
                    }
                }
                packageRequests = newDependencies;
            }

            DeleteObsoletePackages(installedPackages);
            SortByDependencies(installedPackages);

            binFileSyncer.UpdateDestination();

            _performanceLogger.Write(sw, "GetPackages.");

            return(new InstalledPackages {
                Packages = installedPackages
            });
        }
Esempio n. 2
0
        /// <summary>
        /// Downloads the packages from the provided sources, if not already downloaded.
        /// Unpacks the packages, if not already unpacked.
        /// </summary>
        public List <InstalledPackage> GetPackages()
        {
            var sw = Stopwatch.StartNew();
            var installedPackages = new List <InstalledPackage>();

            installedPackages.Add(new InstalledPackage("Rhetos", SystemUtility.GetRhetosVersion(), new List <PackageRequest>(), Paths.RhetosServerRootPath,
                                                       new PackageRequest {
                Id = "Rhetos", VersionsRange = "", Source = "", RequestedBy = "Rhetos framework"
            }, ".", new List <ContentFile> {
            }));

            var binFileSyncer = new FileSyncer(_logProvider);

            binFileSyncer.AddDestinations(Paths.PluginsFolder, Paths.ResourcesFolder); // Even if there are no packages, those folders must be created and emptied.

            _filesUtility.SafeCreateDirectory(Paths.PackagesCacheFolder);
            var packageRequests = _deploymentConfiguration.PackageRequests;

            while (packageRequests.Any())
            {
                var newDependencies = new List <PackageRequest>();
                foreach (var request in packageRequests)
                {
                    if (!CheckAlreadyDownloaded(request, installedPackages))
                    {
                        var installedPackage = GetPackage(request, binFileSyncer);
                        ValidatePackage(installedPackage, request, installedPackages);
                        installedPackages.Add(installedPackage);
                        newDependencies.AddRange(installedPackage.Dependencies);
                    }
                }
                packageRequests = newDependencies;
            }

            DeleteObsoletePackages(installedPackages);
            SortByDependencies(installedPackages);

            binFileSyncer.UpdateDestination();

            foreach (var package in installedPackages)
            {
                _packagesLogger.Trace(() => package.Report());
            }

            _performanceLogger.Write(sw, "PackageDownloader.GetPackages.");

            return(installedPackages);
        }