Skip to content

Commit 6611b15

Browse files
Merge pull request #13 from atc-net/feature/maintenance
Maintenance
2 parents 9438f98 + ada6465 commit 6611b15

File tree

16 files changed

+81
-105
lines changed

16 files changed

+81
-105
lines changed

Directory.Build.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<ItemGroup Label="Code Analyzers">
4242
<PackageReference Include="AsyncFixer" Version="1.6.0" PrivateAssets="All" />
4343
<PackageReference Include="Asyncify" Version="0.9.7" PrivateAssets="All" />
44-
<PackageReference Include="Meziantou.Analyzer" Version="2.0.105" PrivateAssets="All" />
44+
<PackageReference Include="Meziantou.Analyzer" Version="2.0.106" PrivateAssets="All" />
4545
<PackageReference Include="SecurityCodeScan.VS2019" Version="5.6.7" PrivateAssets="All" />
4646
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.507" PrivateAssets="All" />
4747
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.12.0.78982" PrivateAssets="All" />

src/Atc.Installer.Integration.WindowsApplication/GlobalUsings.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
global using System.Diagnostics.CodeAnalysis;
33
global using System.Runtime.CompilerServices;
44
global using System.Runtime.Versioning;
5-
global using System.ServiceProcess;
5+
global using System.ServiceProcess;
6+
7+
global using Atc.Helpers;

src/Atc.Installer.Integration.WindowsApplication/IWindowsApplicationInstallerService.cs

-4
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ bool StopApplication(
3030
FileInfo applicationFile,
3131
ushort timeoutInSeconds = 60);
3232

33-
bool StartApplication(
34-
string applicationName,
35-
ushort timeoutInSeconds = 60);
36-
3733
bool StartApplication(
3834
FileInfo applicationFile,
3935
ushort timeoutInSeconds = 60);

src/Atc.Installer.Integration.WindowsApplication/WindowsApplicationInstallerService.cs

+5-22
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ public async Task<bool> StopService(
6060
try
6161
{
6262
var services = ServiceController.GetServices();
63-
var service =
64-
services.FirstOrDefault(x => x.ServiceName.Equals(serviceName, StringComparison.OrdinalIgnoreCase));
63+
var service = services.FirstOrDefault(x => x.ServiceName.Equals(serviceName, StringComparison.OrdinalIgnoreCase));
64+
6565
if (service is null ||
6666
service.Status != ServiceControllerStatus.Running)
6767
{
@@ -93,8 +93,8 @@ public async Task<bool> StartService(
9393
try
9494
{
9595
var services = ServiceController.GetServices();
96-
var service =
97-
services.FirstOrDefault(x => x.ServiceName.Equals(serviceName, StringComparison.OrdinalIgnoreCase));
96+
var service = services.FirstOrDefault(x => x.ServiceName.Equals(serviceName, StringComparison.OrdinalIgnoreCase));
97+
9898
if (service is null ||
9999
service.Status != ServiceControllerStatus.Stopped)
100100
{
@@ -195,23 +195,6 @@ public bool StopApplication(
195195
return StopApplication(applicationName, timeoutInSeconds);
196196
}
197197

198-
public bool StartApplication(
199-
string applicationName,
200-
ushort timeoutInSeconds = 60)
201-
{
202-
ArgumentException.ThrowIfNullOrEmpty(applicationName);
203-
204-
try
205-
{
206-
Process.Start(applicationName);
207-
return true;
208-
}
209-
catch
210-
{
211-
return false;
212-
}
213-
}
214-
215198
public bool StartApplication(
216199
FileInfo applicationFile,
217200
ushort timeoutInSeconds = 60)
@@ -220,7 +203,7 @@ public bool StartApplication(
220203

221204
try
222205
{
223-
Process.Start(applicationFile.FullName);
206+
ProcessHelper.Execute(applicationFile.Directory!, applicationFile, string.Empty);
224207
return true;
225208
}
226209
catch

src/Atc.Installer.Wpf.App/AssemblyInfo.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
[assembly: AssemblyCompany("atc-net")]
66
[assembly: AssemblyProduct("Atc.Installer")]
77
[assembly: AssemblyTitle("Atc.Installer")]
8-
[assembly: AssemblyVersion("1.0.12.0")]
9-
[assembly: AssemblyInformationalVersion("1.0.12.0")]
10-
[assembly: AssemblyFileVersion("1.0.12.0")]
8+
[assembly: AssemblyVersion("1.0.14.0")]
9+
[assembly: AssemblyInformationalVersion("1.0.14.0")]
10+
[assembly: AssemblyFileVersion("1.0.14.0")]
1111
[assembly: System.Resources.NeutralResourcesLanguage("en")]
1212
[assembly: System.Runtime.Versioning.TargetPlatform("Windows7.0")]
1313
[assembly: System.Runtime.Versioning.SupportedOSPlatform("Windows7.0")]

src/Atc.Installer.Wpf.App/Atc.Installer.Wpf.App.csproj

+5-5
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@
4343
</ItemGroup>
4444

4545
<ItemGroup>
46-
<PackageReference Include="Atc.Wpf" Version="2.0.290" />
47-
<PackageReference Include="Atc.Wpf.Controls" Version="2.0.290" />
48-
<PackageReference Include="Atc.Wpf.FontIcons" Version="2.0.290" />
49-
<PackageReference Include="Atc.Wpf.Theming" Version="2.0.290" />
46+
<PackageReference Include="Atc.Wpf" Version="2.0.297" />
47+
<PackageReference Include="Atc.Wpf.Controls" Version="2.0.297" />
48+
<PackageReference Include="Atc.Wpf.FontIcons" Version="2.0.297" />
49+
<PackageReference Include="Atc.Wpf.Theming" Version="2.0.297" />
5050
<PackageReference Include="ClosedXML" Version="0.104.0-preview2" />
5151
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0-rc.2.23479.6" />
5252
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0-rc.2.23479.6" />
5353
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0-rc.2.23479.6" />
5454
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0-rc.2.23479.6" />
5555
<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="8.0.0-rc.2.23479.6" />
56-
<PackageReference Include="Serilog" Version="3.1.0-dev-02086" />
56+
<PackageReference Include="Serilog" Version="3.1.1" />
5757
<PackageReference Include="Serilog.Exceptions" Version="8.4.0" />
5858
<PackageReference Include="Serilog.Extensions.Hosting" Version="7.0.0" />
5959
<PackageReference Include="Serilog.Sinks.File" Version="5.0.1-dev-00968" />

src/Atc.Installer.Wpf.ComponentProvider.ElasticSearch/Atc.Installer.Wpf.ComponentProvider.ElasticSearch.csproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Atc.Wpf" Version="2.0.290" />
12-
<PackageReference Include="Atc.Wpf.Controls" Version="2.0.290" />
13-
<PackageReference Include="Atc.Wpf.FontIcons" Version="2.0.290" />
14-
<PackageReference Include="Atc.Wpf.Theming" Version="2.0.290" />
11+
<PackageReference Include="Atc.Wpf" Version="2.0.297" />
12+
<PackageReference Include="Atc.Wpf.Controls" Version="2.0.297" />
13+
<PackageReference Include="Atc.Wpf.FontIcons" Version="2.0.297" />
14+
<PackageReference Include="Atc.Wpf.Theming" Version="2.0.297" />
1515
</ItemGroup>
1616

1717
<ItemGroup>

src/Atc.Installer.Wpf.ComponentProvider.InternetInformationServer/Atc.Installer.Wpf.ComponentProvider.InternetInformationServer.csproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Atc.Wpf" Version="2.0.290" />
12-
<PackageReference Include="Atc.Wpf.Controls" Version="2.0.290" />
13-
<PackageReference Include="Atc.Wpf.FontIcons" Version="2.0.290" />
14-
<PackageReference Include="Atc.Wpf.Theming" Version="2.0.290" />
11+
<PackageReference Include="Atc.Wpf" Version="2.0.297" />
12+
<PackageReference Include="Atc.Wpf.Controls" Version="2.0.297" />
13+
<PackageReference Include="Atc.Wpf.FontIcons" Version="2.0.297" />
14+
<PackageReference Include="Atc.Wpf.Theming" Version="2.0.297" />
1515
</ItemGroup>
1616

1717
<ItemGroup>

src/Atc.Installer.Wpf.ComponentProvider.InternetInformationServer/Controls/X509CertificateView.xaml

+2-8
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,7 @@
106106
IsEnabled="{Binding Path=EnableEditingMode}"
107107
Spacing="10">
108108
<Button
109-
Width="70"
110-
Background="Transparent"
111-
BorderBrush="Transparent"
112-
BorderThickness="0"
109+
Width="60"
113110
Command="{Binding Path=EditX509CertificateCommand}"
114111
CommandParameter="{Binding}"
115112
ToolTip="Edit">
@@ -124,10 +121,7 @@
124121
</StackPanel>
125122
</Button>
126123
<Button
127-
Width="70"
128-
Background="Transparent"
129-
BorderBrush="Transparent"
130-
BorderThickness="0"
124+
Width="60"
131125
Command="{Binding Path=NewX509CertificateCommand}"
132126
CommandParameter="{Binding}"
133127
ToolTip="New">

src/Atc.Installer.Wpf.ComponentProvider.InternetInformationServer/InternetInformationServerComponentProviderViewModel.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ private async Task ServiceDeployAndStart(
623623
return;
624624
}
625625

626-
IsBusy = true;
626+
await SetIsBusy(value: true, delayInMs: 500).ConfigureAwait(true);
627627

628628
AddLogItem(LogLevel.Trace, "Deploy");
629629

src/Atc.Installer.Wpf.ComponentProvider.PostgreSql/Atc.Installer.Wpf.ComponentProvider.PostgreSql.csproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Atc.Wpf" Version="2.0.290" />
12-
<PackageReference Include="Atc.Wpf.Controls" Version="2.0.290" />
13-
<PackageReference Include="Atc.Wpf.FontIcons" Version="2.0.290" />
14-
<PackageReference Include="Atc.Wpf.Theming" Version="2.0.290" />
11+
<PackageReference Include="Atc.Wpf" Version="2.0.297" />
12+
<PackageReference Include="Atc.Wpf.Controls" Version="2.0.297" />
13+
<PackageReference Include="Atc.Wpf.FontIcons" Version="2.0.297" />
14+
<PackageReference Include="Atc.Wpf.Theming" Version="2.0.297" />
1515
</ItemGroup>
1616

1717
<ItemGroup>

src/Atc.Installer.Wpf.ComponentProvider.WindowsApplication/Atc.Installer.Wpf.ComponentProvider.WindowsApplication.csproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Atc.Wpf" Version="2.0.290" />
12-
<PackageReference Include="Atc.Wpf.Controls" Version="2.0.290" />
13-
<PackageReference Include="Atc.Wpf.FontIcons" Version="2.0.290" />
14-
<PackageReference Include="Atc.Wpf.Theming" Version="2.0.290" />
11+
<PackageReference Include="Atc.Wpf" Version="2.0.297" />
12+
<PackageReference Include="Atc.Wpf.Controls" Version="2.0.297" />
13+
<PackageReference Include="Atc.Wpf.FontIcons" Version="2.0.297" />
14+
<PackageReference Include="Atc.Wpf.Theming" Version="2.0.297" />
1515
</ItemGroup>
1616

1717
<ItemGroup>

src/Atc.Installer.Wpf.ComponentProvider.WindowsApplication/WindowsApplicationComponentProviderViewModel.cs

+17-6
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,19 @@ public override void CheckServiceState()
4747
{
4848
base.CheckServiceState();
4949

50-
RunningState = IsWindowsService
51-
? waInstallerService.GetServiceState(ServiceName!)
52-
: waInstallerService.GetApplicationState(Name);
50+
if (IsWindowsService)
51+
{
52+
RunningState = waInstallerService.GetServiceState(ServiceName!);
53+
}
54+
else
55+
{
56+
RunningState = waInstallerService.GetApplicationState(Name);
57+
if (RunningState == ComponentRunningState.NotAvailable &&
58+
InstallationState is ComponentInstallationState.Installed or ComponentInstallationState.InstalledWithOldVersion)
59+
{
60+
RunningState = ComponentRunningState.Stopped;
61+
}
62+
}
5363

5464
if (RunningState is ComponentRunningState.Unknown or ComponentRunningState.Checking)
5565
{
@@ -77,7 +87,8 @@ public override async Task ServiceStopCommandHandler()
7787
.StopService(ServiceName!)
7888
.ConfigureAwait(true);
7989

80-
if (isStopped)
90+
if (isStopped ||
91+
waInstallerService.GetServiceState(ServiceName!) == ComponentRunningState.Stopped)
8192
{
8293
RunningState = ComponentRunningState.Stopped;
8394
LogAndSendToastNotificationMessage(
@@ -159,7 +170,7 @@ public override async Task ServiceStartCommandHandler()
159170
else
160171
{
161172
var isStarted = waInstallerService
162-
.StartApplication(InstalledMainFilePath!.GetValueAsString());
173+
.StartApplication(new FileInfo(InstalledMainFilePath!.GetValueAsString()));
163174

164175
if (isStarted)
165176
{
@@ -559,7 +570,7 @@ private async Task ServiceDeployAndStart(
559570
return;
560571
}
561572

562-
IsBusy = true;
573+
await SetIsBusy(value: true, delayInMs: 500).ConfigureAwait(true);
563574

564575
AddLogItem(LogLevel.Trace, "Deploy");
565576

src/Atc.Installer.Wpf.ComponentProvider/Atc.Installer.Wpf.ComponentProvider.csproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
<ItemGroup>
1818
<PackageReference Include="Atc" Version="2.0.386" />
19-
<PackageReference Include="Atc.Wpf" Version="2.0.290" />
20-
<PackageReference Include="Atc.Wpf.Controls" Version="2.0.290" />
21-
<PackageReference Include="Atc.Wpf.FontIcons" Version="2.0.290" />
22-
<PackageReference Include="Atc.Wpf.Theming" Version="2.0.290" />
19+
<PackageReference Include="Atc.Wpf" Version="2.0.297" />
20+
<PackageReference Include="Atc.Wpf.Controls" Version="2.0.297" />
21+
<PackageReference Include="Atc.Wpf.FontIcons" Version="2.0.297" />
22+
<PackageReference Include="Atc.Wpf.Theming" Version="2.0.297" />
2323
</ItemGroup>
2424

2525
<ItemGroup>

src/Atc.Installer.Wpf.ComponentProvider/ComponentProviderViewModel_LogicBase.cs

+24-11
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,8 @@ private string AdjustInstalledMainFilePathIfNeededAndGetInstallationMainPath()
933933
"wwwroot",
934934
"_framework");
935935
}
936+
937+
return tmpInstalledMainFilePath;
936938
}
937939

938940
return UnpackedZipFolderPath;
@@ -992,25 +994,19 @@ private void WorkOnAnalyzeAndUpdateStatesForDotNetVersion()
992994
return;
993995
}
994996

995-
var installationMainPath = AdjustInstalledMainFilePathIfNeededAndGetInstallationMainPath();
996-
997-
var installationMainFile = Path.Combine(installationMainPath, $"{Name}.exe");
998-
if (!File.Exists(installationMainFile))
999-
{
1000-
installationMainFile = Path.Combine(installationMainPath, $"{Name}.dll");
1001-
}
1002-
1003997
var resolvedInstalledMainFilePath = InstalledMainFilePath.GetValueAsString();
1004998
if (!File.Exists(resolvedInstalledMainFilePath))
1005999
{
10061000
InstallationState = ComponentInstallationState.NotInstalled;
10071001
}
10081002

1009-
if (File.Exists(installationMainFile) &&
1003+
var installationMainFilePath = GetInstallationMainFilePath();
1004+
1005+
if (installationMainFilePath is not null &&
10101006
File.Exists(resolvedInstalledMainFilePath))
10111007
{
10121008
Version? sourceVersion = null;
1013-
var installationMainFileVersion = FileVersionInfo.GetVersionInfo(installationMainFile);
1009+
var installationMainFileVersion = FileVersionInfo.GetVersionInfo(installationMainFilePath);
10141010
if (installationMainFileVersion?.FileVersion != null)
10151011
{
10161012
sourceVersion = new Version(installationMainFileVersion.FileVersion);
@@ -1027,7 +1023,7 @@ private void WorkOnAnalyzeAndUpdateStatesForDotNetVersion()
10271023

10281024
if (VersionHelper.IsDefault(sourceVersion, destinationVersion))
10291025
{
1030-
var sourcePath = new DirectoryInfo(installationMainFile).Parent!;
1026+
var sourcePath = new DirectoryInfo(installationMainFilePath).Parent!;
10311027
var destinationPath = new DirectoryInfo(resolvedInstalledMainFilePath).Parent!;
10321028
if (sourcePath.GetTotalFilesLength("*.dll") != destinationPath.GetTotalFilesLength("*.dll"))
10331029
{
@@ -1097,4 +1093,21 @@ private void WorkOnAnalyzeAndUpdateStatesForNodeJsVersion()
10971093
}
10981094
}
10991095
}
1096+
1097+
private string? GetInstallationMainFilePath()
1098+
{
1099+
var installationMainPath = AdjustInstalledMainFilePathIfNeededAndGetInstallationMainPath();
1100+
var installationMainFile = installationMainPath.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)
1101+
? installationMainPath
1102+
: Path.Combine(installationMainPath, $"{Name}.exe");
1103+
1104+
if (!File.Exists(installationMainFile))
1105+
{
1106+
installationMainFile = Path.Combine(installationMainPath, $"{Name}.dll");
1107+
}
1108+
1109+
return File.Exists(installationMainFile)
1110+
? installationMainFile
1111+
: null;
1112+
}
11001113
}

test/Atc.Installer.Integration.WindowsApplication.Tests/WindowsApplicationInstallerServiceTests.cs

-23
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,6 @@ namespace Atc.Installer.Integration.WindowsApplication.Tests;
77
[Trait(Traits.Category, Traits.Categories.SkipWhenLiveUnitTesting)]
88
public class WindowsApplicationInstallerServiceTests
99
{
10-
[Fact]
11-
public void StopAndStartApplicationFlow_ApplicationName()
12-
{
13-
var iaInstallerService = new InstalledAppsInstallerService();
14-
var sut = new WindowsApplicationInstallerService(iaInstallerService);
15-
16-
const string applicationName = "notepad";
17-
18-
var runningState = sut.GetApplicationState(applicationName);
19-
Assert.Equal(ComponentRunningState.NotAvailable, runningState);
20-
21-
var isStarted = sut.StartApplication(applicationName);
22-
Assert.True(isStarted);
23-
24-
Thread.Sleep(1_000);
25-
26-
runningState = sut.GetApplicationState(applicationName);
27-
Assert.Equal(ComponentRunningState.Running, runningState);
28-
29-
var isStopped = sut.StopApplication(applicationName);
30-
Assert.True(isStopped);
31-
}
32-
3310
[Fact]
3411
public void StopAndStartApplicationFlow_ApplicationFile()
3512
{

0 commit comments

Comments
 (0)