Esempio n. 1
0
        /// <summary>
        /// Loads an existing <see cref="PackageSetup"/> from the config file at the
        /// specified path.
        /// </summary>
        /// <param name="configFilePath"></param>
        /// <returns></returns>
        public static PackageSetup Load(string configFilePath)
        {
            PackageSetup setup = new PackageSetup();

            setup.Populate(configFilePath);
            return(setup);
        }
Esempio n. 2
0
        public PackageManager(PackageManagerEnvironment workEnvironment, PackageSetup packageSetup)
        {
            // If no external package setup is provided, load it from the config file
            if (packageSetup == null)
            {
                string configFilePath = workEnvironment.ConfigFilePath;
                if (!File.Exists(configFilePath))
                {
                    packageSetup = new PackageSetup();
                    packageSetup.Save(configFilePath);
                }
                else
                {
                    try
                    {
                        packageSetup = PackageSetup.Load(configFilePath);
                    }
                    catch (Exception e)
                    {
                        Logs.Editor.WriteError(
                            "Failed to load PackageManager config file '{0}': {1}",
                            configFilePath,
                            LogFormat.Exception(e));
                    }
                }
            }

            // Assign work environment and package setup to work with
            this.env   = workEnvironment;
            this.setup = packageSetup;

            // Create internal package management objects
            IPackageRepository[] repositories = this.setup.RepositoryUrls
                                                .Select(x => this.CreateRepository(x))
                                                .Where(x => x != null)
                                                .ToArray();
            this.repository = new AggregateRepository(repositories);
            this.manager    = new NuGet.PackageManager(this.repository, this.env.RepositoryPath);
            this.manager.PackageInstalling  += this.manager_PackageInstalling;
            this.manager.PackageInstalled   += this.manager_PackageInstalled;
            this.manager.PackageUninstalled += this.manager_PackageUninstalled;
            this.cache = new PackageCache(
                this.repository,
                repositories.OfType <LocalPackageRepository>().Any());

            this.logger         = new PackageManagerLogger();
            this.manager.Logger = this.logger;

            this.dependencyWalker = new PackageDependencyWalker(this.GetPackage);

            // Retrieve information about local packages
            this.RetrieveLocalPackageInfo();
        }