/// <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; }
/// <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; }
/// <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); }
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))); }
/// <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); }
/// <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); }
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)); }
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); }
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)); }
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); }
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); }
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()); }
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()); }
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); } }
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); } }
internal VerifyCommand(RepoConfig repoConfig, string sourcesDir, string generateDir) { _repoConfig = repoConfig; _sourcesDirectory = sourcesDir; _generateDirectory = generateDir; }
internal ViewCommand(RepoConfig repoConfig, string sourcesPath) { _repoConfig = repoConfig; _sourcesPath = sourcesPath; }