From 57334cc5c0c5e37887a8d9921c1c3ea8f2b49371 Mon Sep 17 00:00:00 2001 From: David Kallesen Date: Sat, 11 Nov 2023 23:26:17 +0100 Subject: [PATCH 1/9] chore: Nuget update --- Directory.Build.props | 2 +- src/Atc.Installer.Wpf.App/Atc.Installer.Wpf.App.csproj | 10 +++++----- ...nstaller.Wpf.ComponentProvider.ElasticSearch.csproj | 8 ++++---- ....ComponentProvider.InternetInformationServer.csproj | 8 ++++---- ...c.Installer.Wpf.ComponentProvider.PostgreSql.csproj | 8 ++++---- ...ler.Wpf.ComponentProvider.WindowsApplication.csproj | 8 ++++---- .../Atc.Installer.Wpf.ComponentProvider.csproj | 8 ++++---- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 1d9e59c..18d3a42 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -41,7 +41,7 @@ - + diff --git a/src/Atc.Installer.Wpf.App/Atc.Installer.Wpf.App.csproj b/src/Atc.Installer.Wpf.App/Atc.Installer.Wpf.App.csproj index c27e1a2..7a42784 100644 --- a/src/Atc.Installer.Wpf.App/Atc.Installer.Wpf.App.csproj +++ b/src/Atc.Installer.Wpf.App/Atc.Installer.Wpf.App.csproj @@ -43,17 +43,17 @@ - - - - + + + + - + diff --git a/src/Atc.Installer.Wpf.ComponentProvider.ElasticSearch/Atc.Installer.Wpf.ComponentProvider.ElasticSearch.csproj b/src/Atc.Installer.Wpf.ComponentProvider.ElasticSearch/Atc.Installer.Wpf.ComponentProvider.ElasticSearch.csproj index 7122cae..43cf5ab 100644 --- a/src/Atc.Installer.Wpf.ComponentProvider.ElasticSearch/Atc.Installer.Wpf.ComponentProvider.ElasticSearch.csproj +++ b/src/Atc.Installer.Wpf.ComponentProvider.ElasticSearch/Atc.Installer.Wpf.ComponentProvider.ElasticSearch.csproj @@ -8,10 +8,10 @@ - - - - + + + + diff --git a/src/Atc.Installer.Wpf.ComponentProvider.InternetInformationServer/Atc.Installer.Wpf.ComponentProvider.InternetInformationServer.csproj b/src/Atc.Installer.Wpf.ComponentProvider.InternetInformationServer/Atc.Installer.Wpf.ComponentProvider.InternetInformationServer.csproj index 11b5881..a2af9f4 100644 --- a/src/Atc.Installer.Wpf.ComponentProvider.InternetInformationServer/Atc.Installer.Wpf.ComponentProvider.InternetInformationServer.csproj +++ b/src/Atc.Installer.Wpf.ComponentProvider.InternetInformationServer/Atc.Installer.Wpf.ComponentProvider.InternetInformationServer.csproj @@ -8,10 +8,10 @@ - - - - + + + + diff --git a/src/Atc.Installer.Wpf.ComponentProvider.PostgreSql/Atc.Installer.Wpf.ComponentProvider.PostgreSql.csproj b/src/Atc.Installer.Wpf.ComponentProvider.PostgreSql/Atc.Installer.Wpf.ComponentProvider.PostgreSql.csproj index ca9c30c..a0197d7 100644 --- a/src/Atc.Installer.Wpf.ComponentProvider.PostgreSql/Atc.Installer.Wpf.ComponentProvider.PostgreSql.csproj +++ b/src/Atc.Installer.Wpf.ComponentProvider.PostgreSql/Atc.Installer.Wpf.ComponentProvider.PostgreSql.csproj @@ -8,10 +8,10 @@ - - - - + + + + diff --git a/src/Atc.Installer.Wpf.ComponentProvider.WindowsApplication/Atc.Installer.Wpf.ComponentProvider.WindowsApplication.csproj b/src/Atc.Installer.Wpf.ComponentProvider.WindowsApplication/Atc.Installer.Wpf.ComponentProvider.WindowsApplication.csproj index cffeb19..6ee20a7 100644 --- a/src/Atc.Installer.Wpf.ComponentProvider.WindowsApplication/Atc.Installer.Wpf.ComponentProvider.WindowsApplication.csproj +++ b/src/Atc.Installer.Wpf.ComponentProvider.WindowsApplication/Atc.Installer.Wpf.ComponentProvider.WindowsApplication.csproj @@ -8,10 +8,10 @@ - - - - + + + + diff --git a/src/Atc.Installer.Wpf.ComponentProvider/Atc.Installer.Wpf.ComponentProvider.csproj b/src/Atc.Installer.Wpf.ComponentProvider/Atc.Installer.Wpf.ComponentProvider.csproj index d7e7e41..f490fa1 100644 --- a/src/Atc.Installer.Wpf.ComponentProvider/Atc.Installer.Wpf.ComponentProvider.csproj +++ b/src/Atc.Installer.Wpf.ComponentProvider/Atc.Installer.Wpf.ComponentProvider.csproj @@ -16,10 +16,10 @@ - - - - + + + + From 9c1b7c0031a8c57bf83a9901dba2e7d67f54bf46 Mon Sep 17 00:00:00 2001 From: David Kallesen Date: Sat, 11 Nov 2023 23:45:49 +0100 Subject: [PATCH 2/9] fix: Set working dir for process-execute --- .../GlobalUsings.cs | 4 ++- .../IWindowsApplicationInstallerService.cs | 4 --- .../WindowsApplicationInstallerService.cs | 27 ++++--------------- ...wsApplicationComponentProviderViewModel.cs | 18 ++++++++++--- ...WindowsApplicationInstallerServiceTests.cs | 23 ---------------- 5 files changed, 22 insertions(+), 54 deletions(-) diff --git a/src/Atc.Installer.Integration.WindowsApplication/GlobalUsings.cs b/src/Atc.Installer.Integration.WindowsApplication/GlobalUsings.cs index d7b7962..860cdb3 100644 --- a/src/Atc.Installer.Integration.WindowsApplication/GlobalUsings.cs +++ b/src/Atc.Installer.Integration.WindowsApplication/GlobalUsings.cs @@ -2,4 +2,6 @@ global using System.Diagnostics.CodeAnalysis; global using System.Runtime.CompilerServices; global using System.Runtime.Versioning; -global using System.ServiceProcess; \ No newline at end of file +global using System.ServiceProcess; + +global using Atc.Helpers; \ No newline at end of file diff --git a/src/Atc.Installer.Integration.WindowsApplication/IWindowsApplicationInstallerService.cs b/src/Atc.Installer.Integration.WindowsApplication/IWindowsApplicationInstallerService.cs index 364602c..73ffc71 100644 --- a/src/Atc.Installer.Integration.WindowsApplication/IWindowsApplicationInstallerService.cs +++ b/src/Atc.Installer.Integration.WindowsApplication/IWindowsApplicationInstallerService.cs @@ -30,10 +30,6 @@ bool StopApplication( FileInfo applicationFile, ushort timeoutInSeconds = 60); - bool StartApplication( - string applicationName, - ushort timeoutInSeconds = 60); - bool StartApplication( FileInfo applicationFile, ushort timeoutInSeconds = 60); diff --git a/src/Atc.Installer.Integration.WindowsApplication/WindowsApplicationInstallerService.cs b/src/Atc.Installer.Integration.WindowsApplication/WindowsApplicationInstallerService.cs index 3e4c1ab..cc15a4a 100644 --- a/src/Atc.Installer.Integration.WindowsApplication/WindowsApplicationInstallerService.cs +++ b/src/Atc.Installer.Integration.WindowsApplication/WindowsApplicationInstallerService.cs @@ -60,8 +60,8 @@ public async Task StopService( try { var services = ServiceController.GetServices(); - var service = - services.FirstOrDefault(x => x.ServiceName.Equals(serviceName, StringComparison.OrdinalIgnoreCase)); + var service = services.FirstOrDefault(x => x.ServiceName.Equals(serviceName, StringComparison.OrdinalIgnoreCase)); + if (service is null || service.Status != ServiceControllerStatus.Running) { @@ -93,8 +93,8 @@ public async Task StartService( try { var services = ServiceController.GetServices(); - var service = - services.FirstOrDefault(x => x.ServiceName.Equals(serviceName, StringComparison.OrdinalIgnoreCase)); + var service = services.FirstOrDefault(x => x.ServiceName.Equals(serviceName, StringComparison.OrdinalIgnoreCase)); + if (service is null || service.Status != ServiceControllerStatus.Stopped) { @@ -195,23 +195,6 @@ public bool StopApplication( return StopApplication(applicationName, timeoutInSeconds); } - public bool StartApplication( - string applicationName, - ushort timeoutInSeconds = 60) - { - ArgumentException.ThrowIfNullOrEmpty(applicationName); - - try - { - Process.Start(applicationName); - return true; - } - catch - { - return false; - } - } - public bool StartApplication( FileInfo applicationFile, ushort timeoutInSeconds = 60) @@ -220,7 +203,7 @@ public bool StartApplication( try { - Process.Start(applicationFile.FullName); + ProcessHelper.Execute(applicationFile.Directory!, applicationFile, string.Empty); return true; } catch diff --git a/src/Atc.Installer.Wpf.ComponentProvider.WindowsApplication/WindowsApplicationComponentProviderViewModel.cs b/src/Atc.Installer.Wpf.ComponentProvider.WindowsApplication/WindowsApplicationComponentProviderViewModel.cs index acc2ece..619e6d6 100644 --- a/src/Atc.Installer.Wpf.ComponentProvider.WindowsApplication/WindowsApplicationComponentProviderViewModel.cs +++ b/src/Atc.Installer.Wpf.ComponentProvider.WindowsApplication/WindowsApplicationComponentProviderViewModel.cs @@ -47,9 +47,19 @@ public override void CheckServiceState() { base.CheckServiceState(); - RunningState = IsWindowsService - ? waInstallerService.GetServiceState(ServiceName!) - : waInstallerService.GetApplicationState(Name); + if (IsWindowsService) + { + RunningState = waInstallerService.GetServiceState(ServiceName!); + } + else + { + RunningState = waInstallerService.GetApplicationState(Name); + if (RunningState == ComponentRunningState.NotAvailable && + InstallationState is ComponentInstallationState.Installed or ComponentInstallationState.InstalledWithOldVersion) + { + RunningState = ComponentRunningState.Stopped; + } + } if (RunningState is ComponentRunningState.Unknown or ComponentRunningState.Checking) { @@ -159,7 +169,7 @@ public override async Task ServiceStartCommandHandler() else { var isStarted = waInstallerService - .StartApplication(InstalledMainFilePath!.GetValueAsString()); + .StartApplication(new FileInfo(InstalledMainFilePath!.GetValueAsString())); if (isStarted) { diff --git a/test/Atc.Installer.Integration.WindowsApplication.Tests/WindowsApplicationInstallerServiceTests.cs b/test/Atc.Installer.Integration.WindowsApplication.Tests/WindowsApplicationInstallerServiceTests.cs index ff7920a..384c1d2 100644 --- a/test/Atc.Installer.Integration.WindowsApplication.Tests/WindowsApplicationInstallerServiceTests.cs +++ b/test/Atc.Installer.Integration.WindowsApplication.Tests/WindowsApplicationInstallerServiceTests.cs @@ -7,29 +7,6 @@ namespace Atc.Installer.Integration.WindowsApplication.Tests; [Trait(Traits.Category, Traits.Categories.SkipWhenLiveUnitTesting)] public class WindowsApplicationInstallerServiceTests { - [Fact] - public void StopAndStartApplicationFlow_ApplicationName() - { - var iaInstallerService = new InstalledAppsInstallerService(); - var sut = new WindowsApplicationInstallerService(iaInstallerService); - - const string applicationName = "notepad"; - - var runningState = sut.GetApplicationState(applicationName); - Assert.Equal(ComponentRunningState.NotAvailable, runningState); - - var isStarted = sut.StartApplication(applicationName); - Assert.True(isStarted); - - Thread.Sleep(1_000); - - runningState = sut.GetApplicationState(applicationName); - Assert.Equal(ComponentRunningState.Running, runningState); - - var isStopped = sut.StopApplication(applicationName); - Assert.True(isStopped); - } - [Fact] public void StopAndStartApplicationFlow_ApplicationFile() { From 0537eb81a7041806208afce5a4b445f35f3a7888 Mon Sep 17 00:00:00 2001 From: David Kallesen Date: Sat, 11 Nov 2023 23:46:47 +0100 Subject: [PATCH 3/9] fix: Make buttons more visible --- .../Controls/X509CertificateView.xaml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/Atc.Installer.Wpf.ComponentProvider.InternetInformationServer/Controls/X509CertificateView.xaml b/src/Atc.Installer.Wpf.ComponentProvider.InternetInformationServer/Controls/X509CertificateView.xaml index afe8689..b531abc 100644 --- a/src/Atc.Installer.Wpf.ComponentProvider.InternetInformationServer/Controls/X509CertificateView.xaml +++ b/src/Atc.Installer.Wpf.ComponentProvider.InternetInformationServer/Controls/X509CertificateView.xaml @@ -106,10 +106,7 @@ IsEnabled="{Binding Path=EnableEditingMode}" Spacing="10">