Exemple #1
0
        /// <summary>
        /// The raw RepoData contains only the fixed + toolset packages that we need to track.  This method will examine the current
        /// state of the repo and add in the current data.  If any conflicting package definitions are detected this method 
        /// will throw.
        /// </summary>
        internal static RepoData Create(RepoConfig config, string sourcesDir)
        {
            List<NuGetPackageConflict> conflicts;
            var repoData = Create(config, sourcesDir, out conflicts);
            if (conflicts?.Count > 0)
            {
                throw new ConflictingPackagesException(conflicts);
            }

            return repoData;
        }
Exemple #2
0
        /// <summary>
        /// The raw RepoData contains only the fixed + toolset packages that we need to track.  This method will examine the current
        /// state of the repo and add in the current data.  If any conflicting package definitions are detected this method 
        /// will throw.
        /// </summary>
        internal static RepoData Create(RepoConfig config, string sourcesPath)
        {
            List<NuGetPackageConflict> conflicts;
            var repoData = Create(config, sourcesPath, out conflicts);
            if (conflicts?.Count > 0)
            {
                throw new Exception("Creation failed because of conflicting packages");
            }

            return repoData;
        }
Exemple #3
0
        /// <summary>
        /// The raw RepoData contains only the fixed + toolset packages that we need to track.  This method will examine the current
        /// state of the repo and add in the current data.  If any conflicting package definitions are detected this method
        /// will throw.
        /// </summary>
        internal static RepoData Create(RepoConfig config, string sourcesDir, bool ignoreConflicts)
        {
            var repoData = Create(config, sourcesDir, out var conflicts);

            if (conflicts?.Count > 0 && !ignoreConflicts)
            {
                throw new ConflictingPackagesException(conflicts);
            }

            return(repoData);
        }
Exemple #4
0
        internal static RepoData Create(RepoConfig config, string sourcesDir, out List <NuGetPackageConflict> conflicts)
        {
            var nugetFeeds = new List <NuGetFeed>();

            foreach (var nugetConfig in NuGetConfigUtil.GetNuGetConfigFiles(sourcesDir))
            {
                var nugetFeed = NuGetConfigUtil.GetNuGetFeeds(nugetConfig);
                nugetFeeds.AddRange(nugetFeed);
            }

            conflicts = null;

            var fixedPackageSet    = new HashSet <NuGetPackage>(config.FixedPackages, default(Constants.IgnoreGenerateNameComparer));
            var floatingPackageMap = new Dictionary <string, NuGetPackageSource>(Constants.NugetPackageNameComparer);

            foreach (var filePath in ProjectJsonUtil.GetProjectJsonFiles(sourcesDir))
            {
                var fileName = FileName.FromFullPath(sourcesDir, filePath);

                if (config.ProjectJsonExcludes.Any(x => x.IsMatch(fileName.RelativePath)))
                {
                    continue;
                }

                foreach (var package in ProjectJsonUtil.GetDependencies(filePath))
                {
                    if (fixedPackageSet.Contains(package))
                    {
                        continue;
                    }

                    // If this is the first time we've seen the package then record where it was found.  Need the source
                    // information to provide better error messages later.
                    var packageSource = new NuGetPackageSource(package, fileName);
                    NuGetPackageSource originalSource;
                    if (floatingPackageMap.TryGetValue(package.Name, out originalSource))
                    {
                        if (originalSource.NuGetPackage.Version != package.Version)
                        {
                            var conflict = new NuGetPackageConflict(original: originalSource, conflict: packageSource);
                            conflicts = conflicts ?? new List <NuGetPackageConflict>();
                            conflicts.Add(conflict);
                        }
                    }
                    else
                    {
                        floatingPackageMap.Add(package.Name, packageSource);
                    }
                }
            }

            return(new RepoData(config, sourcesDir, nugetFeeds, floatingPackageMap.Values.Select(x => x.NuGetPackage)));
        }
Exemple #5
0
        /// <summary>
        /// The raw RepoData contains only the fixed + toolset packages that we need to track.  This method will examine the current
        /// state of the repo and add in the current data.  If any conflicting package definitions are detected this method
        /// will throw.
        /// </summary>
        internal static RepoData Create(RepoConfig config, string sourcesPath)
        {
            List <NuGetPackageConflict> conflicts;
            var repoData = Create(config, sourcesPath, out conflicts);

            if (conflicts?.Count > 0)
            {
                throw new Exception("Creation failed because of conflicting packages");
            }

            return(repoData);
        }
Exemple #6
0
        /// <summary>
        /// The raw RepoData contains only the fixed + toolset packages that we need to track.  This method will examine the current
        /// state of the repo and add in the current data.  If any conflicting package definitions are detected this method
        /// will throw.
        /// </summary>
        internal static RepoData Create(RepoConfig config, string sourcesDir)
        {
            List <NuGetPackageConflict> conflicts;
            var repoData = Create(config, sourcesDir, out conflicts);

            if (conflicts?.Count > 0)
            {
                throw new ConflictingPackagesException(conflicts);
            }

            return(repoData);
        }
Exemple #7
0
        internal static RepoData Create(RepoConfig config, string sourcesDir, out List<NuGetPackageConflict> conflicts)
        {
            var nugetFeeds = new List<NuGetFeed>();
            foreach (var nugetConfig in NuGetConfigUtil.GetNuGetConfigFiles(sourcesDir))
            {
                var nugetFeed = NuGetConfigUtil.GetNuGetFeeds(nugetConfig);
                nugetFeeds.AddRange(nugetFeed);
            }

            conflicts = null;

            var fixedPackageSet = new HashSet<NuGetPackage>(config.FixedPackages, default(Constants.IgnoreGenerateNameComparer));
            var floatingPackageMap = new Dictionary<string, NuGetPackageSource>(Constants.NugetPackageNameComparer);
            foreach (var filePath in ProjectJsonUtil.GetProjectJsonFiles(sourcesDir))
            {
                if (config.ProjectJsonExcludes.Any(x => x.IsMatch(filePath)))
                {
                    continue;
                }

                var fileName = FileName.FromFullPath(sourcesDir, filePath);
                foreach (var package in ProjectJsonUtil.GetDependencies(filePath))
                {
                    if (fixedPackageSet.Contains(package))
                    {
                        continue;
                    }

                    // If this is the first time we've seen the package then record where it was found.  Need the source
                    // information to provide better error messages later.
                    var packageSource = new NuGetPackageSource(package, fileName);
                    NuGetPackageSource originalSource;
                    if (floatingPackageMap.TryGetValue(package.Name, out originalSource))
                    {
                        if (originalSource.NuGetPackage.Version != package.Version)
                        {
                            var conflict = new NuGetPackageConflict(original: originalSource, conflict: packageSource);
                            conflicts = conflicts ?? new List<NuGetPackageConflict>();
                            conflicts.Add(conflict);
                        }
                    }
                    else
                    {
                        floatingPackageMap.Add(package.Name, packageSource);
                    }
                }
            }

            return new RepoData(config, sourcesDir, nugetFeeds, floatingPackageMap.Values.Select(x => x.NuGetPackage));
        }
Exemple #8
0
        private static bool Run(string[] args)
        {
            ParsedArgs parsedArgs;
            CreateCommand func;
            if (!TryParseCommandLine(args, out parsedArgs, out func))
            {
                return false;
            }

            RepoConfig repoConfig = null;
            if (!string.IsNullOrEmpty(parsedArgs.RepoDataPath))
                repoConfig = RepoConfig.ReadFrom(parsedArgs.RepoDataPath);
            var command = func(repoConfig, parsedArgs.SourcesPath);
            return command.Run(Console.Out, parsedArgs.RemainingArgs);
        }
Exemple #9
0
        private static bool Run(string[] args)
        {
            ParsedArgs    parsedArgs;
            CreateCommand func;

            if (!TryParseCommandLine(args, out parsedArgs, out func))
            {
                return(false);
            }

            var repoConfig = RepoConfig.ReadFrom(parsedArgs.RepoDataPath);
            var command    = func(repoConfig, parsedArgs.SourcesPath);

            return(command.Run(Console.Out, parsedArgs.RemainingArgs));
        }
Exemple #10
0
 private RepoData(RepoConfig config, string sourcesPath, IEnumerable <NuGetPackage> floatingPackages)
 {
     SourcesPath             = sourcesPath;
     RepoConfig              = config;
     FloatingToolsetPackages = floatingPackages
                               .Where(x => RepoConfig.ToolsetPackages.Contains(x.Name, Constants.NugetPackageNameComparer))
                               .OrderBy(x => x.Name)
                               .ToImmutableArray();
     FloatingBuildPackages = floatingPackages
                             .Where(x => !RepoConfig.ToolsetPackages.Contains(x.Name, Constants.NugetPackageNameComparer))
                             .OrderBy(x => x.Name)
                             .ToImmutableArray();
     FloatingPackages = floatingPackages
                        .OrderBy(x => x.Name)
                        .ToImmutableArray();
     AllPackages = Combine(FloatingBuildPackages, FloatingToolsetPackages, FixedPackages);
 }
Exemple #11
0
 private RepoData(RepoConfig config, string sourcesPath, IEnumerable<NuGetPackage> floatingPackages)
 {
     SourcesPath = sourcesPath;
     RepoConfig = config;
     FloatingToolsetPackages = floatingPackages
         .Where(x => RepoConfig.ToolsetPackages.Contains(x.Name, Constants.NugetPackageNameComparer))
         .OrderBy(x => x.Name)
         .ToImmutableArray();
     FloatingBuildPackages = floatingPackages
         .Where(x => !RepoConfig.ToolsetPackages.Contains(x.Name, Constants.NugetPackageNameComparer))
         .OrderBy(x => x.Name)
         .ToImmutableArray();
     FloatingPackages = floatingPackages
         .OrderBy(x => x.Name)
         .ToImmutableArray();
     AllPackages = Combine(FloatingBuildPackages, FloatingToolsetPackages, FixedPackages);
 }
Exemple #12
0
 private RepoData(RepoConfig config, string sourcesDir, IEnumerable <NuGetFeed> nugetFeeds, IEnumerable <NuGetPackage> floatingPackages)
 {
     SourcesDirectory        = sourcesDir;
     RepoConfig              = config;
     NuGetFeeds              = nugetFeeds.ToImmutableArray();
     FloatingToolsetPackages = floatingPackages
                               .Where(x => RepoConfig.ToolsetPackages.Contains(x.Name, Constants.NugetPackageNameComparer))
                               .OrderBy(x => x.Name)
                               .ToImmutableArray();
     FloatingBuildPackages = floatingPackages
                             .Where(x => !RepoConfig.ToolsetPackages.Contains(x.Name, Constants.NugetPackageNameComparer))
                             .OrderBy(x => x.Name)
                             .ToImmutableArray();
     FloatingPackages = floatingPackages
                        .OrderBy(x => x.Name)
                        .ToImmutableArray();
     AllPackages = Combine(
         FloatingBuildPackages,
         FloatingToolsetPackages,
         FixedPackages.Select(x => x).ToImmutableArray());
 }
Exemple #13
0
 private RepoData(RepoConfig config, string sourcesDir, IEnumerable<NuGetFeed> nugetFeeds, IEnumerable<NuGetPackage> floatingPackages)
 {
     SourcesDirectory = sourcesDir;
     RepoConfig = config;
     NuGetFeeds = nugetFeeds.ToImmutableArray();
     FloatingToolsetPackages = floatingPackages
         .Where(x => RepoConfig.ToolsetPackages.Contains(x.Name, Constants.NugetPackageNameComparer))
         .OrderBy(x => x.Name)
         .ToImmutableArray();
     FloatingBuildPackages = floatingPackages
         .Where(x => !RepoConfig.ToolsetPackages.Contains(x.Name, Constants.NugetPackageNameComparer))
         .OrderBy(x => x.Name)
         .ToImmutableArray();
     FloatingPackages = floatingPackages
         .OrderBy(x => x.Name)
         .ToImmutableArray();
     AllPackages = Combine(
         FloatingBuildPackages,
         FloatingToolsetPackages,
         FixedPackages.Select(x => x).ToImmutableArray());
 }
Exemple #14
0
        private static bool Run(string[] args)
        {
            if (!TryParseCommandLine(args, out var parsedArgs, out var func))
            {
                Usage();
                return(false);
            }

            var repoConfig = RepoConfig.ReadFrom(parsedArgs.RepoUtilDataPath);
            var command    = func(repoConfig, parsedArgs.SourcesDirectory, parsedArgs.GenerateDirectory);

            if (command.Run(Console.Out, parsedArgs.RemainingArgs))
            {
                return(true);
            }
            else
            {
                Console.WriteLine($"RepoUtil config read from: {parsedArgs.RepoUtilDataPath}");
                return(false);
            }
        }
Exemple #15
0
        private static bool Run(string[] args)
        {
            ParsedArgs    parsedArgs;
            CreateCommand func;

            if (!TryParseCommandLine(args, out parsedArgs, out func))
            {
                return(false);
            }

            var repoConfig = RepoConfig.ReadFrom(parsedArgs.RepoUtilDataPath);
            var command    = func(repoConfig, parsedArgs.SourcesPath);

            if (command.Run(Console.Out, parsedArgs.RemainingArgs))
            {
                return(true);
            }
            else
            {
                Console.WriteLine($"RepoUtil config read from: {parsedArgs.RepoUtilDataPath}");
                return(false);
            }
        }
Exemple #16
0
 internal VerifyCommand(RepoConfig repoConfig, string sourcesDir, string generateDir)
 {
     _repoConfig        = repoConfig;
     _sourcesDirectory  = sourcesDir;
     _generateDirectory = generateDir;
 }
Exemple #17
0
 internal ViewCommand(RepoConfig repoConfig, string sourcesPath)
 {
     _repoConfig = repoConfig;
     _sourcesPath = sourcesPath;
 }
Exemple #18
0
 internal ViewCommand(RepoConfig repoConfig, string sourcesPath)
 {
     _repoConfig  = repoConfig;
     _sourcesPath = sourcesPath;
 }
Exemple #19
0
 internal VerifyCommand(RepoConfig repoConfig, string sourcesDir, string generateDir)
 {
     _repoConfig = repoConfig;
     _sourcesDirectory = sourcesDir;
     _generateDirectory = generateDir;
 }