Ejemplo n.º 1
0
        private static bool TryParsePackage(TextWriter writer, string packageLine, List <NuGetPackage> changes)
        {
            var match = Regex.Match(packageLine, @"([^\s]*)\s*(.*)");

            if (match.Success)
            {
                var package = new NuGetPackage(
                    match.Groups[1].Value,
                    match.Groups[2].Value);
                changes.Add(package);
                return(true);
            }

            match = Regex.Match(packageLine, @"([^\s]*)\s*-\s*(.*)");
            if (match.Success)
            {
                var package = new NuGetPackage(
                    match.Groups[1].Value,
                    match.Groups[2].Value);
                changes.Add(package);
                return(true);
            }

            writer.WriteLine($"Unable to parse package {packageLine}");
            return(false);
        }
Ejemplo n.º 2
0
        internal static RepoConfig ReadFrom(string jsonFilePath)
        {
            // Need to track any file that has dependencies
            var obj               = JObject.Parse(File.ReadAllText(jsonFilePath));
            var fixedPackages     = (JObject)obj["fixedPackages"];
            var fixedPackagesList = ImmutableArray.CreateBuilder <NuGetPackage>();

            foreach (var prop in fixedPackages.Properties())
            {
                if (prop.Value.Type == JTokenType.String)
                {
                    var version  = (string)prop.Value;
                    var nugetRef = new NuGetPackage(prop.Name, version);
                    fixedPackagesList.Add(nugetRef);
                }
                else
                {
                    foreach (var version in ((JArray)prop.Value).Values <string>())
                    {
                        var nugetRef = new NuGetPackage(prop.Name, version);
                        fixedPackagesList.Add(nugetRef);
                    }
                }
            }

            var toolsetPackagesProp = obj.Property("toolsetPackages");
            var toolsetPackages     = ((JArray)toolsetPackagesProp.Value).Values <string>();

            GenerateData?msbuildGenerateData = null;
            var          generateObj         = (JObject)obj.Property("generate").Value;

            if (generateObj != null)
            {
                msbuildGenerateData = ReadGenerateData(generateObj, "msbuild");
            }

            var nuspecExcludes     = new List <Regex>();
            var nuspecExcludesProp = obj.Property("nuspecExcludes");

            if (nuspecExcludesProp != null)
            {
                nuspecExcludes.AddRange(((JArray)nuspecExcludesProp.Value).Values <string>().Select(x => new Regex(x)));
            }

            var projectJsonExcludes     = new List <Regex>();
            var projectJsonExcludesProp = obj.Property("projectJsonExcludes");

            if (projectJsonExcludesProp != null)
            {
                projectJsonExcludes.AddRange(((JArray)projectJsonExcludesProp.Value).Values <string>().Select(x => new Regex(x)));
            }

            return(new RepoConfig(
                       fixedPackagesList,
                       toolsetPackages,
                       nuspecExcludes,
                       projectJsonExcludes,
                       msbuildGenerateData));
        }
Ejemplo n.º 3
0
 private static JProperty GetProperty(NuGetPackage package)
 {
     return(new JProperty(package.Name, package.Version));
 }
Ejemplo n.º 4
0
 private static string GetKey(NuGetPackage nugetRef)
 {
     return($"{nugetRef.Name}:{nugetRef.Version}");
 }
Ejemplo n.º 5
0
 internal NuGetPackageSource(NuGetPackage package, FileName fileName)
 {
     NuGetPackage = package;
     FileName     = fileName;
 }