コード例 #1
0
ファイル: Helpers.cs プロジェクト: mmacy/nue
        public static string BuildCommandString(PackageAtom package, string rootPath, string configPath, RunSettings runSettings)
        {
            var baseline = $@"install {package.Name} -OutputDirectory ""{rootPath.Trim('"')}"" -Verbosity Quiet -FallbackSource https://api.nuget.org/v3/index.json -ConfigFile ""{configPath.Trim('"')}""";

            if (!string.IsNullOrWhiteSpace(package.CustomProperties.TFM))
            {
                baseline += $" -Framework {package.CustomProperties.TFM}";
            }
            else if (!string.IsNullOrEmpty(runSettings.TFM))
            {
                baseline += $" -Framework {runSettings.TFM}";
            }

            if (!string.IsNullOrWhiteSpace(package.CustomProperties.CustomFeed))
            {
                baseline += $" -Source {package.CustomProperties.CustomFeed}";
            }
            else if (!string.IsNullOrEmpty(runSettings.Feed))
            {
                baseline += $" -Source {runSettings.Feed}";
            }

            if (package.CustomVersionDefined)
            {
                baseline += $" -Version {package.CustomVersion}";
            }
            if (package.IsPrerelease)
            {
                baseline += " -PreRelease";
            }

            return(baseline);
        }
コード例 #2
0
ファイル: Helpers.cs プロジェクト: mmacy/nue
        public static bool CopyLibraryContent(string source, string destination, PackageAtom package, out List <string> binaries)
        {
            binaries = new List <string>();
            var docFiles = new List <string>();

            try
            {
                binaries = Directory.GetFiles(source, "*.*", SearchOption.TopDirectoryOnly)
                           .Where(s => s.EndsWith(".dll") || s.EndsWith(".winmd")).ToList();
            }
            catch
            {
                Console.WriteLine($"[error] Could not get binaries for {package.Name} from {source}.");
                return(false);
            }


            foreach (var binary in binaries)
            {
                File.Copy(binary, Path.Combine(destination, Path.GetFileName(binary)), true);
            }

            try
            {
                docFiles = Directory.GetFiles(source, "*.xml", SearchOption.TopDirectoryOnly).ToList();
                foreach (var docFile in docFiles)
                {
                    File.Copy(docFile, Path.Combine(destination, Path.GetFileName(docFile)), true);
                }
            }
            catch
            {
                Console.WriteLine($"[warning] Could not get documentation files for {package.Name} from {source}.");
            }

            return(true);
        }
コード例 #3
0
        private static List <PackageAtom> GetPackagesFromCSVFile(string packagePath)
        {
            var packages = new List <PackageAtom>();

            using (var parser = new TextFieldParser(packagePath))
            {
                parser.TextFieldType = FieldType.Delimited;
                parser.SetDelimiters(",");

                while (!parser.EndOfData)
                {
                    var fields = parser.ReadFields();

                    if (fields == null)
                    {
                        continue;
                    }

                    // Given the conventions, let's find out how many versions are requested to be downloaded.
                    var pAtom = new PackageAtom();

                    if (fields.Length == 2)
                    {
                        // There is no version specified.
                        pAtom.Moniker       = fields[0];
                        pAtom.Name          = fields[1];
                        pAtom.VersionOption = VersionOption.Latest;
                    }
                    else if (fields.Length > 2)
                    {
                        // There is a version specified.
                        pAtom.Moniker       = fields[0] + "-" + fields[2];
                        pAtom.Name          = fields[1];
                        pAtom.VersionOption = VersionOption.Custom;
                        pAtom.CustomVersion = fields[2];
                    }
                    else
                    {
                        Console.WriteLine("[error] Could not read in package information for " + fields.ToString());
                        break;
                    }

                    // Property bag will be formatted like:
                    // [property1=value1;property2=value2]PackageId
                    var   propertyBagRegex = @"(\[.+\])";
                    Regex formalizedRegEx  = new Regex(propertyBagRegex);
                    var   match            = formalizedRegEx.Match(pAtom.Name);

                    if (match.Success)
                    {
                        // There seems to be a property bag attached to the name.
                        var rawPropertyBag = match.Value.Replace("[", "").Replace("]", "").Trim();
                        if (!string.IsNullOrWhiteSpace(rawPropertyBag))
                        {
                            // Normalize the package name without the property bag.
                            pAtom.Name = pAtom.Name.Replace(match.Value, "");
                            pAtom.CustomPropertyBag = new Dictionary <string, string>();

                            // Avoiding the case of empty property bag, looks like in this case we are good.
                            var properties = rawPropertyBag.Split(new char[] { ';' });
                            foreach (var property in properties)
                            {
                                var splitProperty = property.Split(new char[] { '=' });
                                pAtom.CustomPropertyBag.Add(splitProperty[0], splitProperty[1]);
                            }
                        }
                    }

                    packages.Add(pAtom);
                }
            }

            return(packages);
        }