Save() public method

Saves the packages.config file and populates it with given installed NugetPackages.
public Save ( string filepath ) : void
filepath string The filepath to where this packages.config will be saved.
return void
コード例 #1
0
ファイル: PackagesConfigFile.cs プロジェクト: whuop/CPM
        /// <summary>
        /// Loads a list of all currently installed packages by reading the packages.config file.
        /// </summary>
        /// <returns>A newly created <see cref="PackagesConfigFile"/>.</returns>
        public static PackagesConfigFile Load(string filepath)
        {
            PackagesConfigFile configFile = new PackagesConfigFile();

            configFile.Packages = new List <NugetPackageIdentifier>();

            // Create a package.config file, if there isn't already one in the project
            if (!File.Exists(filepath))
            {
                Debug.LogFormat("No packages.config file found. Creating default at {0}", filepath);

                configFile.Save(filepath);

                AssetDatabase.Refresh();
            }

            XDocument packagesFile = XDocument.Load(filepath);

            foreach (var packageElement in packagesFile.Root.Elements())
            {
                NugetPackage package = new NugetPackage();
                package.Id      = packageElement.Attribute("id").Value;
                package.Version = packageElement.Attribute("version").Value;
                configFile.Packages.Add(package);
            }

            return(configFile);
        }
コード例 #2
0
        /// <summary>
        /// Loads a list of all currently installed packages by reading the packages.config file.
        /// </summary>
        /// <returns>A newly created <see cref="PackagesConfigFile"/>.</returns>
        public static PackagesConfigFile Load(string filepath)
        {
            var configFile = new PackagesConfigFile {
                Packages = new List <NugetPackageIdentifier>()
            };

            // Create a package.config file, if there isn't already one in the project
            if (!File.Exists(filepath))
            {
                SystemProxy.Log($"No packages.config file found. Creating default at {filepath}");

                configFile.Save(filepath);

                SystemProxy.RefreshAssets();
            }

            var packagesFile = XDocument.Load(filepath);

            foreach (var packageElement in packagesFile.Root.Elements())
            {
                var package = new NugetPackage
                {
                    Id                  = packageElement.Attribute("id").Value,
                    Version             = packageElement.Attribute("version").Value,
                    IsManuallyInstalled = packageElement.Attribute("manual") != null
                };
                configFile.Packages.Add(package);
            }

            return(configFile);
        }
コード例 #3
0
        /// <summary>
        /// Loads a list of all currently installed packages by reading the packages.config file.
        /// </summary>
        /// <returns>A newly created <see cref="PackagesConfigFile"/>.</returns>
        public static PackagesConfigFile Load(string filepath)
        {
            PackagesConfigFile configFile = new PackagesConfigFile();
            configFile.Packages = new List<NugetPackageIdentifier>();

            // Create a package.config file, if there isn't already one in the project
            if (!File.Exists(filepath))
            {
                Debug.LogFormat("No packages.config file found. Creating default at {0}", filepath);

                configFile.Save(filepath);

                AssetDatabase.Refresh();
            }

            XDocument packagesFile = XDocument.Load(filepath);
            foreach (var packageElement in packagesFile.Root.Elements())
            {
                NugetPackage package = new NugetPackage();
                package.Id = packageElement.Attribute("id").Value;
                package.Version = packageElement.Attribute("version").Value;
                configFile.Packages.Add(package);
            }

            return configFile;
        }