From 76748f268a37bb1e1bd0bffab79b20462f093883 Mon Sep 17 00:00:00 2001 From: "Martin Hinshelwood nkdAgility.com" Date: Mon, 29 Jul 2024 15:29:46 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20(solution):=20remove=20NKD?= =?UTF-8?q?Agility.AzureDevOps.Tools.CommandHost=20project=20and=20update?= =?UTF-8?q?=20project=20references?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🔧 (docs): update generated XML documentation to reflect latest commit and branch information The NKDAgility.AzureDevOps.Tools.CommandHost project is removed from the solution to streamline the project structure. This change also updates the project references to point to the correct paths, ensuring that the solution builds correctly. The generated XML documentation is updated to reflect the latest commit and branch information, ensuring that the documentation is accurate and up-to-date. ♻️ (refactor): update project references and remove unused code - Update project references to use `MigrationTools.Helpers.Tests` instead of `MigrationTools.Fakes`. - Rename `NKDAgility.AzureDevOps.Tools.CommandHost` project to `MigrationTools.Helpers.Tests`. - Add new fake classes `FakeMigrationToolVersion` and `FakeMigrationToolVersionInfo` for testing. - Replace `RunMigrationTools` with `RunConsoleAsync` in `Program.cs` files. - Remove unused `HostExtensions` and `MigrationService` classes. These changes improve the project structure by consolidating test helpers into a single project, ensuring consistency in project references, and removing obsolete code. This refactor enhances maintainability and clarity in the codebase. ♻️ (MigrationTools.Host): refactor to use Spectre.Console.Extensions.Hosting and remove redundant services 🔧 (MigrationTools.Host): update project references to reflect new structure Refactor the code to use `Spectre.Console.Extensions.Hosting` instead of `Spectre.Console.Cli.Extensions.DependencyInjection` for better integration and maintainability. Remove redundant services like `StartupService` and `DetectVersionService` to simplify the codebase. Update project references to reflect the new structure, ensuring that tests and other dependencies are correctly aligned with the changes. This improves the overall architecture and reduces complexity. ♻️ (tests): update namespace and project references from MigrationTools.Fakes to MigrationTools.Helpers.Tests The namespace and project references are updated to reflect the new location and naming convention for the test helpers. This change improves code organization and clarity by using a more descriptive and accurate namespace. --- MigrationTools.sln | 9 +- docs/Reference/Generated/MigrationTools.xml | 22 ++--- ...ients.AzureDevops.ObjectModel.Tests.csproj | 2 +- .../ServiceProviderHelper.cs | 2 +- ...ools.Clients.AzureDevops.Rest.Tests.csproj | 3 +- .../ServiceProviderHelper.cs | 2 +- ...ationTools.Clients.FileSystem.Tests.csproj | 2 +- .../ServiceProviderHelper.cs | 2 +- ...grationTools.Clients.InMemory.Tests.csproj | 3 +- .../ServiceProviderHelper.cs | 2 +- src/MigrationTools.ConsoleCore/Program.cs | 3 +- src/MigrationTools.ConsoleFull/Program.cs | 3 +- .../FakeMigrationToolVersion.cs | 2 +- .../FakeMigrationToolVersionInfo.cs | 2 +- .../MigrationTools.Helpers.Tests.csproj | 0 .../MigrationTools.Host.Tests.csproj | 2 +- .../Services/DetectVersionService2Tests.cs | 2 +- .../Services/DetectVersionServiceTests.cs | 9 +- src/MigrationTools.Host/HostExtensions.cs | 15 ---- src/MigrationTools.Host/MigrationService.cs | 33 ------- src/MigrationTools.Host/MigrationToolHost.cs | 51 ++--------- .../MigrationTools.Host.csproj | 2 +- .../Services/DetectVersionService.cs | 60 ------------- .../Services/IDetectVersionService.cs | 9 -- src/MigrationTools.Host/StartupService.cs | 87 ------------------- .../MigrationTools.Integration.Tests.csproj | 3 +- .../ServiceProviderHelper.cs | 2 +- .../MigrationTools.Tests.csproj | 3 +- .../ServiceProviderHelper.cs | 2 +- .../Services/MigrationToolVersionInfoTests.cs | 2 +- ...ility.AzureDevOps.Tools.CommandHost.csproj | 17 ---- .../MigrationEngineTests.cs | 2 +- .../VstsSyncMigrator.Core.Tests.csproj | 2 +- 33 files changed, 42 insertions(+), 320 deletions(-) rename src/{MigrationTools.Fakes => MigrationTools.Helpers.Tests}/FakeMigrationToolVersion.cs (88%) rename src/{MigrationTools.Fakes => MigrationTools.Helpers.Tests}/FakeMigrationToolVersionInfo.cs (95%) rename src/{MigrationTools.Fakes => MigrationTools.Helpers.Tests}/MigrationTools.Helpers.Tests.csproj (100%) delete mode 100644 src/MigrationTools.Host/HostExtensions.cs delete mode 100644 src/MigrationTools.Host/MigrationService.cs delete mode 100644 src/MigrationTools.Host/Services/DetectVersionService.cs delete mode 100644 src/MigrationTools.Host/Services/IDetectVersionService.cs delete mode 100644 src/MigrationTools.Host/StartupService.cs delete mode 100644 src/NKDAgility.AzureDevOps.Tools.CommandHost/NKDAgility.AzureDevOps.Tools.CommandHost.csproj diff --git a/MigrationTools.sln b/MigrationTools.sln index 1d248ae92..80b649e78 100644 --- a/MigrationTools.sln +++ b/MigrationTools.sln @@ -126,9 +126,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".build", ".build", "{88C358 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{BB497233-248C-49DF-AE12-F7A76F775E74}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NKDAgility.AzureDevOps.Tools.CommandHost", "src\NKDAgility.AzureDevOps.Tools.CommandHost\NKDAgility.AzureDevOps.Tools.CommandHost.csproj", "{60EF98A1-5AA4-4589-8B6F-A77B3940025D}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MigrationTools.Helpers.Tests", "src\MigrationTools.Fakes\MigrationTools.Helpers.Tests.csproj", "{EB20ED85-8876-4585-BC90-E6976C11DEE3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MigrationTools.Helpers.Tests", "src\MigrationTools.Helpers.Tests\MigrationTools.Helpers.Tests.csproj", "{EB20ED85-8876-4585-BC90-E6976C11DEE3}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -212,10 +210,6 @@ Global {6A259EA6-860B-448A-8943-594DC1A15105}.Debug|Any CPU.Build.0 = Debug|Any CPU {6A259EA6-860B-448A-8943-594DC1A15105}.Release|Any CPU.ActiveCfg = Release|Any CPU {6A259EA6-860B-448A-8943-594DC1A15105}.Release|Any CPU.Build.0 = Release|Any CPU - {60EF98A1-5AA4-4589-8B6F-A77B3940025D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {60EF98A1-5AA4-4589-8B6F-A77B3940025D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {60EF98A1-5AA4-4589-8B6F-A77B3940025D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {60EF98A1-5AA4-4589-8B6F-A77B3940025D}.Release|Any CPU.Build.0 = Release|Any CPU {EB20ED85-8876-4585-BC90-E6976C11DEE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EB20ED85-8876-4585-BC90-E6976C11DEE3}.Debug|Any CPU.Build.0 = Debug|Any CPU {EB20ED85-8876-4585-BC90-E6976C11DEE3}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -253,7 +247,6 @@ Global {6A259EA6-860B-448A-8943-594DC1A15105} = {83F36820-E9BC-4F48-8202-5EAF9530405E} {AC3B5101-83F5-4C28-976C-C325425D1988} = {1F5E9C8C-AD05-4C4F-B370-FF3D080A6541} {BB497233-248C-49DF-AE12-F7A76F775E74} = {83F36820-E9BC-4F48-8202-5EAF9530405E} - {60EF98A1-5AA4-4589-8B6F-A77B3940025D} = {BB497233-248C-49DF-AE12-F7A76F775E74} {EB20ED85-8876-4585-BC90-E6976C11DEE3} = {BB497233-248C-49DF-AE12-F7A76F775E74} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/docs/Reference/Generated/MigrationTools.xml b/docs/Reference/Generated/MigrationTools.xml index a0b92ea79..f7427280b 100644 --- a/docs/Reference/Generated/MigrationTools.xml +++ b/docs/Reference/Generated/MigrationTools.xml @@ -604,37 +604,37 @@ - => @"feature/small-changes-group-1" + => @"main" - => @"0e5f65f" + => @"cd49e40" - => @"0e5f65ff4368b8da72e7e64991c4d0a095637a02" + => @"cd49e4061f2759b8ba15da035f13f8d39f6dbf0a" - => @"2024-07-26T14:20:01+01:00" + => @"2024-07-26T15:59:36+01:00" - => @"26" + => @"0" - => @"v15.1.5-Preview.2-26-g0e5f65f" + => @"v15.1.6" - => @"v15.1.5-Preview.2" + => @"v15.1.6" @@ -649,7 +649,7 @@ - => @"5" + => @"6" @@ -664,17 +664,17 @@ - => @"31" + => @"6" - => @"Preview.2" + => @"" - => @"-Preview.2" + => @"" diff --git a/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/MigrationTools.Clients.AzureDevops.ObjectModel.Tests.csproj b/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/MigrationTools.Clients.AzureDevops.ObjectModel.Tests.csproj index de4d64e22..788bd0750 100644 --- a/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/MigrationTools.Clients.AzureDevops.ObjectModel.Tests.csproj +++ b/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/MigrationTools.Clients.AzureDevops.ObjectModel.Tests.csproj @@ -27,7 +27,7 @@ - + diff --git a/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/ServiceProviderHelper.cs b/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/ServiceProviderHelper.cs index 2375fa7a2..2ba88f728 100644 --- a/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/ServiceProviderHelper.cs +++ b/src/MigrationTools.Clients.AzureDevops.ObjectModel.Tests/ServiceProviderHelper.cs @@ -1,7 +1,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using MigrationTools.Endpoints; -using MigrationTools.Fakes; +using MigrationTools.Helpers.Tests; using MigrationTools.Services; using MigrationTools.TestExtensions; diff --git a/src/MigrationTools.Clients.AzureDevops.Rest.Tests/MigrationTools.Clients.AzureDevops.Rest.Tests.csproj b/src/MigrationTools.Clients.AzureDevops.Rest.Tests/MigrationTools.Clients.AzureDevops.Rest.Tests.csproj index d6e5a72e3..5bcd30efe 100644 --- a/src/MigrationTools.Clients.AzureDevops.Rest.Tests/MigrationTools.Clients.AzureDevops.Rest.Tests.csproj +++ b/src/MigrationTools.Clients.AzureDevops.Rest.Tests/MigrationTools.Clients.AzureDevops.Rest.Tests.csproj @@ -19,8 +19,7 @@ - - + diff --git a/src/MigrationTools.Clients.AzureDevops.Rest.Tests/ServiceProviderHelper.cs b/src/MigrationTools.Clients.AzureDevops.Rest.Tests/ServiceProviderHelper.cs index 0ffb0b124..c1d56e0b9 100644 --- a/src/MigrationTools.Clients.AzureDevops.Rest.Tests/ServiceProviderHelper.cs +++ b/src/MigrationTools.Clients.AzureDevops.Rest.Tests/ServiceProviderHelper.cs @@ -1,7 +1,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using MigrationTools.Endpoints; -using MigrationTools.Fakes; +using MigrationTools.Helpers.Tests; using MigrationTools.Services; using MigrationTools.TestExtensions; diff --git a/src/MigrationTools.Clients.FileSystem.Tests/MigrationTools.Clients.FileSystem.Tests.csproj b/src/MigrationTools.Clients.FileSystem.Tests/MigrationTools.Clients.FileSystem.Tests.csproj index 79ad15394..e24d9dd4b 100644 --- a/src/MigrationTools.Clients.FileSystem.Tests/MigrationTools.Clients.FileSystem.Tests.csproj +++ b/src/MigrationTools.Clients.FileSystem.Tests/MigrationTools.Clients.FileSystem.Tests.csproj @@ -22,7 +22,7 @@ - + diff --git a/src/MigrationTools.Clients.FileSystem.Tests/ServiceProviderHelper.cs b/src/MigrationTools.Clients.FileSystem.Tests/ServiceProviderHelper.cs index c9a23d53f..824fcf365 100644 --- a/src/MigrationTools.Clients.FileSystem.Tests/ServiceProviderHelper.cs +++ b/src/MigrationTools.Clients.FileSystem.Tests/ServiceProviderHelper.cs @@ -1,7 +1,7 @@ using Microsoft.Extensions.DependencyInjection; -using MigrationTools.Fakes; using MigrationTools.Services; using MigrationTools.TestExtensions; +using MigrationTools.Helpers.Tests; namespace MigrationTools.Tests { diff --git a/src/MigrationTools.Clients.InMemory.Tests/MigrationTools.Clients.InMemory.Tests.csproj b/src/MigrationTools.Clients.InMemory.Tests/MigrationTools.Clients.InMemory.Tests.csproj index dd0a554e0..ad3c586ab 100644 --- a/src/MigrationTools.Clients.InMemory.Tests/MigrationTools.Clients.InMemory.Tests.csproj +++ b/src/MigrationTools.Clients.InMemory.Tests/MigrationTools.Clients.InMemory.Tests.csproj @@ -22,8 +22,7 @@ - - + diff --git a/src/MigrationTools.Clients.InMemory.Tests/ServiceProviderHelper.cs b/src/MigrationTools.Clients.InMemory.Tests/ServiceProviderHelper.cs index 418b09d02..9632a2173 100644 --- a/src/MigrationTools.Clients.InMemory.Tests/ServiceProviderHelper.cs +++ b/src/MigrationTools.Clients.InMemory.Tests/ServiceProviderHelper.cs @@ -1,5 +1,5 @@ using Microsoft.Extensions.DependencyInjection; -using MigrationTools.Fakes; +using MigrationTools.Helpers.Tests; using MigrationTools.Services; using MigrationTools.TestExtensions; diff --git a/src/MigrationTools.ConsoleCore/Program.cs b/src/MigrationTools.ConsoleCore/Program.cs index 2038fdb53..995bae7ed 100644 --- a/src/MigrationTools.ConsoleCore/Program.cs +++ b/src/MigrationTools.ConsoleCore/Program.cs @@ -1,5 +1,6 @@ using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using MigrationTools.Clients.AzureDevops.Rest.FieldMaps; using MigrationTools.Host; @@ -35,7 +36,7 @@ public static async Task Main(string[] args) // Core // services.AddTransient(); }); - await hostBuilder.RunMigrationTools(args); + await hostBuilder.RunConsoleAsync(); } } } \ No newline at end of file diff --git a/src/MigrationTools.ConsoleFull/Program.cs b/src/MigrationTools.ConsoleFull/Program.cs index ebcaddb90..cb251d2a5 100644 --- a/src/MigrationTools.ConsoleFull/Program.cs +++ b/src/MigrationTools.ConsoleFull/Program.cs @@ -1,4 +1,5 @@ using System.Threading.Tasks; +using Microsoft.Extensions.Hosting; using MigrationTools; using MigrationTools.Host; @@ -27,7 +28,7 @@ public static async Task Main(string[] args) services.AddMigrationToolServicesForClientLegacyCore(); }); - await hostBuilder.RunMigrationTools(args); + await hostBuilder.RunConsoleAsync(); } } } \ No newline at end of file diff --git a/src/MigrationTools.Fakes/FakeMigrationToolVersion.cs b/src/MigrationTools.Helpers.Tests/FakeMigrationToolVersion.cs similarity index 88% rename from src/MigrationTools.Fakes/FakeMigrationToolVersion.cs rename to src/MigrationTools.Helpers.Tests/FakeMigrationToolVersion.cs index dabe9cd68..fdedad236 100644 --- a/src/MigrationTools.Fakes/FakeMigrationToolVersion.cs +++ b/src/MigrationTools.Helpers.Tests/FakeMigrationToolVersion.cs @@ -1,6 +1,6 @@ using MigrationTools.Services; -namespace MigrationTools.Fakes +namespace MigrationTools.Helpers.Tests { public class FakeMigrationToolVersion : IMigrationToolVersion { diff --git a/src/MigrationTools.Fakes/FakeMigrationToolVersionInfo.cs b/src/MigrationTools.Helpers.Tests/FakeMigrationToolVersionInfo.cs similarity index 95% rename from src/MigrationTools.Fakes/FakeMigrationToolVersionInfo.cs rename to src/MigrationTools.Helpers.Tests/FakeMigrationToolVersionInfo.cs index f20f8cdfb..c0c84ef39 100644 --- a/src/MigrationTools.Fakes/FakeMigrationToolVersionInfo.cs +++ b/src/MigrationTools.Helpers.Tests/FakeMigrationToolVersionInfo.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; using MigrationTools.Services; -namespace MigrationTools.Fakes +namespace MigrationTools.Helpers.Tests { public class FakeMigrationToolVersionInfo : MigrationToolVersionInfo { diff --git a/src/MigrationTools.Fakes/MigrationTools.Helpers.Tests.csproj b/src/MigrationTools.Helpers.Tests/MigrationTools.Helpers.Tests.csproj similarity index 100% rename from src/MigrationTools.Fakes/MigrationTools.Helpers.Tests.csproj rename to src/MigrationTools.Helpers.Tests/MigrationTools.Helpers.Tests.csproj diff --git a/src/MigrationTools.Host.Tests/MigrationTools.Host.Tests.csproj b/src/MigrationTools.Host.Tests/MigrationTools.Host.Tests.csproj index c70cc31c0..2f8cefdce 100644 --- a/src/MigrationTools.Host.Tests/MigrationTools.Host.Tests.csproj +++ b/src/MigrationTools.Host.Tests/MigrationTools.Host.Tests.csproj @@ -26,7 +26,7 @@ - + diff --git a/src/MigrationTools.Host.Tests/Services/DetectVersionService2Tests.cs b/src/MigrationTools.Host.Tests/Services/DetectVersionService2Tests.cs index dacdd87dc..09d2ae5c2 100644 --- a/src/MigrationTools.Host.Tests/Services/DetectVersionService2Tests.cs +++ b/src/MigrationTools.Host.Tests/Services/DetectVersionService2Tests.cs @@ -7,7 +7,7 @@ using Serilog.Events; using MigrationTools.Host.Tests; using MigrationTools.Tests; -using MigrationTools.Fakes; +using MigrationTools.Helpers.Tests; namespace MigrationTools.Host.Services.Tests { diff --git a/src/MigrationTools.Host.Tests/Services/DetectVersionServiceTests.cs b/src/MigrationTools.Host.Tests/Services/DetectVersionServiceTests.cs index 6a2170402..355fb10c4 100644 --- a/src/MigrationTools.Host.Tests/Services/DetectVersionServiceTests.cs +++ b/src/MigrationTools.Host.Tests/Services/DetectVersionServiceTests.cs @@ -6,13 +6,6 @@ namespace MigrationTools.Host.Services.Tests [TestClass] public class DetectVersionServiceTests { - [Ignore] - [TestMethod, TestCategory("L3")] - public void DetectVersionServiceTest() - { - var dos = new DetectVersionService(new TelemetryLoggerMock()); - var result = dos.GetLatestVersion(); - Assert.IsNotNull(result); - } + } } \ No newline at end of file diff --git a/src/MigrationTools.Host/HostExtensions.cs b/src/MigrationTools.Host/HostExtensions.cs deleted file mode 100644 index 9e07b8294..000000000 --- a/src/MigrationTools.Host/HostExtensions.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; - -namespace MigrationTools.Host -{ - public static class HostExtensions - { - public static IStartupService InitializeMigrationSetup(this IHost host, string[] args) - { - var startup = host.Services.GetRequiredService(); - startup.RunStartupLogic(args); - return startup; - } - } -} \ No newline at end of file diff --git a/src/MigrationTools.Host/MigrationService.cs b/src/MigrationTools.Host/MigrationService.cs deleted file mode 100644 index d4b2f69ff..000000000 --- a/src/MigrationTools.Host/MigrationService.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; -using Serilog.Core; -using Spectre.Console.Cli; - -namespace MigrationTools.Host -{ - internal class MigrationService : BackgroundService - { - private ICommandApp AppCommand { get; } - private IHostApplicationLifetime AppLifetime { get; } - private ILogger Logger { get; } - - public MigrationService(ICommandApp appCommand, IHostApplicationLifetime appLifetime, ILogger logger) - { - AppCommand = appCommand; - AppLifetime = appLifetime; - Logger = logger; - } - - protected override async Task ExecuteAsync(CancellationToken stoppingToken) - { - await AppCommand.RunAsync(Environment.GetCommandLineArgs().Skip(1)); - AppLifetime.StopApplication(); - } - } -} diff --git a/src/MigrationTools.Host/MigrationToolHost.cs b/src/MigrationTools.Host/MigrationToolHost.cs index 422cbdc8c..1e5c61e8b 100644 --- a/src/MigrationTools.Host/MigrationToolHost.cs +++ b/src/MigrationTools.Host/MigrationToolHost.cs @@ -18,13 +18,13 @@ using Serilog.Core; using Serilog.Events; using Serilog.Sinks.SystemConsole.Themes; -using Spectre.Console.Cli.Extensions.DependencyInjection; using Spectre.Console.Cli; using Serilog.Filters; using MigrationTools.Host.Commands; using System.Diagnostics; using System.Text.RegularExpressions; using MigrationTools.Services; +using Spectre.Console.Extensions.Hosting; namespace MigrationTools.Host { @@ -42,7 +42,6 @@ public static IHostBuilder CreateDefaultBuilder(string[] args) var mtv = new MigrationToolVersion(); var hostBuilder = Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder(args); - hostBuilder.UseSerilog((hostingContext, services, loggerConfiguration) => { string outputTemplate = "[{Timestamp:HH:mm:ss} {Level:u3}] [" + mtv.GetRunningVersion().versionString + "] {Message:lj}{NewLine}{Exception}"; // {SourceContext} @@ -135,31 +134,14 @@ public static IHostBuilder CreateDefaultBuilder(string[] args) services.AddMigrationToolServicesLegacy(); // New v2Bits services.AddMigrationToolServices(); - - // Host Services - services.AddTransient(); - }); - hostBuilder.ConfigureServices((context, services) => - { - using var registrar = new DependencyInjectionRegistrar(services); - var app = new CommandApp(registrar); - app.Configure(config => - { - config.PropagateExceptions(); - config.AddCommand("execute"); - config.AddCommand("init"); - - }); - services.AddSingleton(app); - }); - - hostBuilder.ConfigureServices((context, services) => + hostBuilder.UseSpectreConsole(config => { - services.AddHostedService(); + config.AddCommand("execute"); + config.AddCommand("init"); + config.PropagateExceptions(); }); - hostBuilder.UseConsoleLifetime(); @@ -167,29 +149,6 @@ public static IHostBuilder CreateDefaultBuilder(string[] args) return hostBuilder; } - public static async Task RunMigrationTools(this IHostBuilder hostBuilder, string[] args) - { - var host = hostBuilder.Build(); - var startupService = host.InitializeMigrationSetup(args); - if (startupService == null) - { - return; - } - - - // Disanle telemitery from options - //bool DisableTelemetry = false; - //Serilog.ILogger logger = host.Services.GetService(); - //if (executeOptions is not null && bool.TryParse(executeOptions.DisableTelemetry, out DisableTelemetry)) - //{ - // TelemetryConfiguration ai = host.Services.GetService(); - // ai.DisableTelemetry = DisableTelemetry; - //} - //logger.Information("Telemetry: {status}", !DisableTelemetry); - - await host.RunAsync(); - } - static string logDate = DateTime.Now.ToString("yyyyMMddHHmmss"); private static string CreateLogsPath() diff --git a/src/MigrationTools.Host/MigrationTools.Host.csproj b/src/MigrationTools.Host/MigrationTools.Host.csproj index 966f7654b..3fad7a497 100644 --- a/src/MigrationTools.Host/MigrationTools.Host.csproj +++ b/src/MigrationTools.Host/MigrationTools.Host.csproj @@ -32,7 +32,7 @@ - + diff --git a/src/MigrationTools.Host/Services/DetectVersionService.cs b/src/MigrationTools.Host/Services/DetectVersionService.cs deleted file mode 100644 index 56eee408e..000000000 --- a/src/MigrationTools.Host/Services/DetectVersionService.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Threading; -using Microsoft.ApplicationInsights.DataContracts; -using NuGet.Common; -using NuGet.Configuration; -using NuGet.Protocol; -using NuGet.Protocol.Core.Types; -using NuGet.Versioning; -using Serilog; -using WGetNET; - -namespace MigrationTools.Host.Services -{ - public class DetectVersionService : IDetectVersionService - { - private readonly ITelemetryLogger _Telemetry; - - public string PackageId { get; set; } - - - public DetectVersionService(ITelemetryLogger telemetry) - { - _Telemetry = telemetry; - PackageId = "nkdAgility.AzureDevOpsMigrationTools"; - } - - public Version GetLatestVersion() - { - DateTime startTime = DateTime.Now; - Stopwatch mainTimer = Stopwatch.StartNew(); - ////////////////////////////////// - Version latestPackageVersion = null; - bool sucess = false; - try - { - WinGetPackageManager packageManager = new WinGetPackageManager(); - var package = packageManager.GetInstalledPackages(PackageId, true).FirstOrDefault(); - - if (package != null) - { - latestPackageVersion = package.AvailableVersion; - sucess = true; - } - _Telemetry.TrackDependency(new DependencyTelemetry("PackageRepository", "winget", PackageId, latestPackageVersion == null ? "nullVersion" : latestPackageVersion.ToString(), startTime, mainTimer.Elapsed, "200", sucess)); - } - catch (Exception ex) - { - Log.Error(ex, "DetectVersionService"); - sucess = false; - _Telemetry.TrackDependency(new DependencyTelemetry("PackageRepository", "winget", PackageId, latestPackageVersion == null ? "nullVersion" : latestPackageVersion.ToString(), startTime, mainTimer.Elapsed, "500", sucess)); - } - ///////////////// - mainTimer.Stop(); - return latestPackageVersion; - } - } -} diff --git a/src/MigrationTools.Host/Services/IDetectVersionService.cs b/src/MigrationTools.Host/Services/IDetectVersionService.cs deleted file mode 100644 index 55b2972f3..000000000 --- a/src/MigrationTools.Host/Services/IDetectVersionService.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace MigrationTools.Host.Services -{ - public interface IDetectVersionService - { - Version GetLatestVersion(); - } -} \ No newline at end of file diff --git a/src/MigrationTools.Host/StartupService.cs b/src/MigrationTools.Host/StartupService.cs deleted file mode 100644 index cad76110e..000000000 --- a/src/MigrationTools.Host/StartupService.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Diagnostics.Eventing.Reader; -using System.Linq; -using System.Reflection; -using System.Threading; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; -using MigrationTools.Host.Services; -using Serilog; -using static System.Net.Mime.MediaTypeNames; - -namespace MigrationTools.Host -{ - public interface IStartupService - { - void RunStartupLogic(string[] args); - - void RunExitLogic(); - } - - internal class StartupService : IStartupService - { - private readonly IHostApplicationLifetime _LifeTime; - private readonly IDetectOnlineService _detectOnlineService; - private readonly IDetectVersionService2 _detectVersionService; - private readonly ILogger _logger; - private readonly ITelemetryLogger _telemetryLogger; - private static Stopwatch _mainTimer = new Stopwatch(); - - public StartupService(IHostApplicationLifetime lifeTime, IDetectOnlineService detectOnlineService, IDetectVersionService2 detectVersionService, ILogger logger, ITelemetryLogger telemetryLogger) - { - _LifeTime = lifeTime; - _detectOnlineService = detectOnlineService; - _detectVersionService = detectVersionService; - _logger = logger; - _telemetryLogger = telemetryLogger; - } - - public void RunStartupLogic(string[] args) - { - ApplicationStartup(args); - Configure(_LifeTime); - } - - public void Configure(IHostApplicationLifetime appLifetime) - { - appLifetime.ApplicationStarted.Register(() => - { - _logger.LogInformation("Press Ctrl+C to shut down."); - }); - - appLifetime.ApplicationStopped.Register(() => - { - RunExitLogic(); - }); - } - - public void RunExitLogic() - { - _logger.LogTrace("Application Ending"); - _mainTimer.Stop(); - _telemetryLogger.TrackEvent("ApplicationEnd", null, - new Dictionary { - { "Application_Elapsed", _mainTimer.ElapsedMilliseconds } - }); - _telemetryLogger.CloseAndFlush(); - _logger.LogInformation("The application ran in {Application_Elapsed} and finished at {Application_EndTime}", _mainTimer.Elapsed.ToString("c"), DateTime.Now.ToUniversalTime().ToLocalTime()); - } - - private void ApplicationStartup(string[] args) - { - _mainTimer.Start(); - AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; - _logger.LogTrace("Application Starting"); - } - - protected void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) - { - _logger.LogError((Exception)e.ExceptionObject, "An Unhandled exception occured."); - //_logger.LogCloseAndFlush(); - System.Threading.Thread.Sleep(5000); - } - - } -} \ No newline at end of file diff --git a/src/MigrationTools.Integration.Tests/MigrationTools.Integration.Tests.csproj b/src/MigrationTools.Integration.Tests/MigrationTools.Integration.Tests.csproj index 9d03ec9f4..bdbcecb71 100644 --- a/src/MigrationTools.Integration.Tests/MigrationTools.Integration.Tests.csproj +++ b/src/MigrationTools.Integration.Tests/MigrationTools.Integration.Tests.csproj @@ -28,8 +28,7 @@ - - + diff --git a/src/MigrationTools.Integration.Tests/ServiceProviderHelper.cs b/src/MigrationTools.Integration.Tests/ServiceProviderHelper.cs index 7befa5ede..51859285c 100644 --- a/src/MigrationTools.Integration.Tests/ServiceProviderHelper.cs +++ b/src/MigrationTools.Integration.Tests/ServiceProviderHelper.cs @@ -2,7 +2,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using MigrationTools.Endpoints; -using MigrationTools.Fakes; +using MigrationTools.Helpers.Tests; using MigrationTools.Services; using MigrationTools.TestExtensions; diff --git a/src/MigrationTools.Tests/MigrationTools.Tests.csproj b/src/MigrationTools.Tests/MigrationTools.Tests.csproj index bc59cf9bf..aef411cd0 100644 --- a/src/MigrationTools.Tests/MigrationTools.Tests.csproj +++ b/src/MigrationTools.Tests/MigrationTools.Tests.csproj @@ -21,8 +21,7 @@ - - + diff --git a/src/MigrationTools.Tests/ServiceProviderHelper.cs b/src/MigrationTools.Tests/ServiceProviderHelper.cs index f68cccba7..5cfd1c587 100644 --- a/src/MigrationTools.Tests/ServiceProviderHelper.cs +++ b/src/MigrationTools.Tests/ServiceProviderHelper.cs @@ -3,7 +3,7 @@ using MigrationTools.EndpointEnrichers; using MigrationTools.Endpoints; using MigrationTools.Enrichers; -using MigrationTools.Fakes; +using MigrationTools.Helpers.Tests; using MigrationTools.ProcessorEnrichers.WorkItemProcessorEnrichers; using MigrationTools.Processors; using MigrationTools.Services; diff --git a/src/MigrationTools.Tests/Services/MigrationToolVersionInfoTests.cs b/src/MigrationTools.Tests/Services/MigrationToolVersionInfoTests.cs index f14d58c12..e2ee07499 100644 --- a/src/MigrationTools.Tests/Services/MigrationToolVersionInfoTests.cs +++ b/src/MigrationTools.Tests/Services/MigrationToolVersionInfoTests.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -using MigrationTools.Fakes; +using MigrationTools.Helpers.Tests; namespace MigrationTools.Tests { diff --git a/src/NKDAgility.AzureDevOps.Tools.CommandHost/NKDAgility.AzureDevOps.Tools.CommandHost.csproj b/src/NKDAgility.AzureDevOps.Tools.CommandHost/NKDAgility.AzureDevOps.Tools.CommandHost.csproj deleted file mode 100644 index b72bcacd8..000000000 --- a/src/NKDAgility.AzureDevOps.Tools.CommandHost/NKDAgility.AzureDevOps.Tools.CommandHost.csproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - net8.0 - enable - enable - - - - - - - - - - - diff --git a/src/VstsSyncMigrator.Core.Tests/MigrationEngineTests.cs b/src/VstsSyncMigrator.Core.Tests/MigrationEngineTests.cs index bbc4217e2..f0946898a 100644 --- a/src/VstsSyncMigrator.Core.Tests/MigrationEngineTests.cs +++ b/src/VstsSyncMigrator.Core.Tests/MigrationEngineTests.cs @@ -8,7 +8,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using MigrationTools; using MigrationTools._EngineV1.Configuration; -using MigrationTools.Fakes; +using MigrationTools.Helpers.Tests; using MigrationTools.Services; using MigrationTools.TestExtensions; using Serilog; diff --git a/src/VstsSyncMigrator.Core.Tests/VstsSyncMigrator.Core.Tests.csproj b/src/VstsSyncMigrator.Core.Tests/VstsSyncMigrator.Core.Tests.csproj index a1ebe2cea..a7c323e9f 100644 --- a/src/VstsSyncMigrator.Core.Tests/VstsSyncMigrator.Core.Tests.csproj +++ b/src/VstsSyncMigrator.Core.Tests/VstsSyncMigrator.Core.Tests.csproj @@ -22,7 +22,7 @@ - +