├── .gitignore ├── DetectDuplicates.sln ├── DetectDuplicates ├── DetectDuplicates.csproj └── Program.cs ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | obj/ 3 | nupkg/ 4 | .idea/ 5 | .vscode/ -------------------------------------------------------------------------------- /DetectDuplicates.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DetectDuplicates", "DetectDuplicates\DetectDuplicates.csproj", "{7A1946BC-5DDF-4D50-8DF6-39085BF430BB}" 4 | EndProject 5 | Global 6 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 7 | Debug|Any CPU = Debug|Any CPU 8 | Release|Any CPU = Release|Any CPU 9 | EndGlobalSection 10 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 11 | {7A1946BC-5DDF-4D50-8DF6-39085BF430BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 12 | {7A1946BC-5DDF-4D50-8DF6-39085BF430BB}.Debug|Any CPU.Build.0 = Debug|Any CPU 13 | {7A1946BC-5DDF-4D50-8DF6-39085BF430BB}.Release|Any CPU.ActiveCfg = Release|Any CPU 14 | {7A1946BC-5DDF-4D50-8DF6-39085BF430BB}.Release|Any CPU.Build.0 = Release|Any CPU 15 | EndGlobalSection 16 | EndGlobal 17 | -------------------------------------------------------------------------------- /DetectDuplicates/DetectDuplicates.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | true 7 | ./nupkg 8 | Jonathan Channon 9 | A .NET Global tool that scans csproj files for duplicate package references 10 | asp.net core;.net core;tooling;csproj;CI;dependency;dependencies; 11 | https://github.com/jchannon/DetectDuplicates 12 | MIT 13 | latest 14 | true 15 | 1.2.0 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /DetectDuplicates/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text.RegularExpressions; 6 | 7 | namespace DetectDuplicates 8 | { 9 | class Program 10 | { 11 | static int Main(string[] args) 12 | { 13 | var path = string.Empty; 14 | 15 | path = args.Any() ? args[0] : Directory.GetCurrentDirectory(); 16 | 17 | Console.WriteLine($"Looking for duplicates in {path}"); 18 | Console.WriteLine(""); 19 | 20 | bool duplicatesFound = false; 21 | 22 | var files = "*.csproj;*.fsproj".Split(';') 23 | .SelectMany(g => Directory.EnumerateFiles(path, g, SearchOption.AllDirectories)); 24 | 25 | //var files = Directory.GetFiles(path, "*.csproj", SearchOption.AllDirectories); 26 | foreach (var file in files) 27 | { 28 | var fileName = Path.GetFileName(file); 29 | var line = string.Empty; 30 | try 31 | { 32 | var hash = new HashSet(); 33 | using var fs = File.OpenRead(file); 34 | using var sr = new StreamReader(fs); 35 | 36 | while (!sr.EndOfStream) 37 | { 38 | line = sr.ReadLine()?.Trim(); 39 | if (line == null) 40 | { 41 | continue; 42 | } 43 | 44 | if (!line.StartsWith(@"