using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using SolutionCleanupTool.Interfaces; using SolutionCleanupTool.Services; namespace SolutionCleanupTool { /// /// Main entry point for the Solution Cleanup Tool /// class Program { static void Main(string[] args) { // Set up dependency injection and logging var services = new ServiceCollection(); ConfigureServices(services); var serviceProvider = services.BuildServiceProvider(); var logger = serviceProvider.GetRequiredService>(); logger.LogInformation("Solution Cleanup Tool started"); if (args.Length == 0) { Console.WriteLine("Usage: SolutionCleanupTool "); Console.WriteLine("Example: SolutionCleanupTool C:\\MyProject\\MySolution.sln"); return; } string solutionPath = args[0]; if (!File.Exists(solutionPath)) { logger.LogError("Solution file not found: {SolutionPath}", solutionPath); Console.WriteLine($"Error: Solution file not found: {solutionPath}"); return; } logger.LogInformation("Processing solution file: {SolutionPath}", solutionPath); Console.WriteLine($"Processing solution file: {solutionPath}"); try { // Test the SolutionParser implementation var solutionParser = serviceProvider.GetRequiredService(); var solutionModel = solutionParser.ParseSolution(solutionPath); logger.LogInformation("Successfully parsed solution with {ProjectCount} projects", solutionModel.Projects.Count); Console.WriteLine($"Found {solutionModel.Projects.Count} projects in solution:"); var projectReferences = solutionParser.ExtractProjectReferences(solutionModel); foreach (var project in projectReferences) { var status = project.Exists ? "EXISTS" : "MISSING"; Console.WriteLine($" - {project.Name} ({project.RelativePath}) [{status}]"); logger.LogInformation("Project: {ProjectName} at {ProjectPath} - {Status}", project.Name, project.RelativePath, status); } } catch (Exception ex) { logger.LogError(ex, "Failed to process solution file: {SolutionPath}", solutionPath); Console.WriteLine($"Error processing solution: {ex.Message}"); return; } // TODO: Implement the main cleanup workflow // This will be implemented in subsequent tasks logger.LogInformation("Solution Cleanup Tool completed"); } private static void ConfigureServices(ServiceCollection services) { services.AddLogging(builder => { builder.AddConsole(); builder.SetMinimumLevel(LogLevel.Information); }); // Register service implementations services.AddScoped(); // TODO: Register other service implementations // This will be done in subsequent tasks as we implement the services } } }