Skip to content

Commit d1ec770

Browse files
Merge pull request #14 from atc-net/feature/support-blazor-webassembly
Support blazor webassembly & Introduce options=>DisableInstallationActions
2 parents 6611b15 + 9d55ad3 commit d1ec770

File tree

19 files changed

+115
-61
lines changed

19 files changed

+115
-61
lines changed

.editorconfig

+2
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,8 @@ dotnet_diagnostic.S1135.severity = suggestion # https://github.com/atc-net
514514
dotnet_diagnostic.CA1040.severity = none # Avoid empty interface
515515
dotnet_diagnostic.CA1724.severity = none # The type name App conflicts in whole or in part with the namespace name
516516
dotnet_diagnostic.CA1848.severity = none # Skip for now: Use the LoggerMessage delegates
517+
dotnet_diagnostic.CA1859.severity = suggestion # Use concrete types when possible for improved performance
518+
dotnet_diagnostic.CA1860.severity = suggestion # Avoid using 'Enumerable.Any()' extension method
517519
dotnet_diagnostic.CA2227.severity = none # Skip for now: Read only collection
518520
dotnet_diagnostic.CA2254.severity = none # Skip for now: Template should be a static expression
519521
dotnet_diagnostic.CA5351.severity = none # Do Not Use Broken Cryptographic Algorithms - Its ok, only using to calculate a file-hash

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.106" PrivateAssets="All" />
44+
<PackageReference Include="Meziantou.Analyzer" Version="2.0.110" 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.Azure/Atc.Installer.Integration.Azure.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
<ItemGroup>
99
<PackageReference Include="Atc" Version="2.0.386" />
10-
<PackageReference Include="Azure.Identity" Version="1.10.3" />
11-
<PackageReference Include="Azure.Storage.Blobs" Version="12.19.0" />
10+
<PackageReference Include="Azure.Identity" Version="1.10.4" />
11+
<PackageReference Include="Azure.Storage.Blobs" Version="12.19.1" />
1212
</ItemGroup>
1313

1414
</Project>

src/Atc.Installer.Integration.WindowsApplication/Atc.Installer.Integration.WindowsApplication.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<ItemGroup>
99
<PackageReference Include="Atc" Version="2.0.386" />
10-
<PackageReference Include="System.ServiceProcess.ServiceController" Version="8.0.0-rc.2.23479.6" />
10+
<PackageReference Include="System.ServiceProcess.ServiceController" Version="8.0.0" />
1111
</ItemGroup>
1212

1313
<ItemGroup>

src/Atc.Installer.Integration/GitHubReleaseService.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class GitHubReleaseService : IGitHubReleaseService
2323
.GetProperty("tag_name")
2424
.ToString();
2525

26-
if (versionString.StartsWith("v", StringComparison.OrdinalIgnoreCase))
26+
if (versionString.StartsWith('v'))
2727
{
2828
versionString = versionString[1..];
2929
}

src/Atc.Installer.Integration/Helpers/CryptographyHelper.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public static IList<X509Certificate2> GetX509Certificates(
99
StoreLocation storeLocation = StoreLocation.LocalMachine,
1010
bool validOnly = true)
1111
{
12-
IList<X509Certificate2> certificates = new List<X509Certificate2>();
12+
var certificates = new List<X509Certificate2>();
1313

1414
using var store = new X509Store(
1515
storeName,

src/Atc.Installer.Integration/InstallationConfigurations/ApplicationOption.cs

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ public class ApplicationOption
1616

1717
public string? RawInstallationPath { get; set; }
1818

19+
public bool DisableInstallationActions { get; set; }
20+
1921
public IList<string> DependentComponents { get; set; } = new List<string>();
2022

2123
public IList<string> DependentServices { get; init; } = new List<string>();

src/Atc.Installer.Integration/InstalledAppsInstallerService.cs

+1
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ private static bool IsJavaRuntime(
191191
}
192192

193193
[SuppressMessage("Minor Code Smell", "S1075:URIs should not be hardcoded", Justification = "OK.")]
194+
[SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments", Justification = "OK.")]
194195
private async Task<bool> IsNodeJs(
195196
ushort mainVersion)
196197
{

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ await ConfigurationFileHelper
170170
}
171171
}
172172

173-
private static Serilog.ILogger CreateLoggerConfigurationForSerilogFileLog()
173+
private static Serilog.Core.Logger CreateLoggerConfigurationForSerilogFileLog()
174174
{
175175
var systemName = AssemblyHelper.GetSystemNameAsKebabCasing();
176176
var loggerConfig = new LoggerConfiguration();

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.14.0")]
9-
[assembly: AssemblyInformationalVersion("1.0.14.0")]
10-
[assembly: AssemblyFileVersion("1.0.14.0")]
8+
[assembly: AssemblyVersion("1.0.15.0")]
9+
[assembly: AssemblyInformationalVersion("1.0.15.0")]
10+
[assembly: AssemblyFileVersion("1.0.15.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

+6-6
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@
4848
<PackageReference Include="Atc.Wpf.FontIcons" Version="2.0.297" />
4949
<PackageReference Include="Atc.Wpf.Theming" Version="2.0.297" />
5050
<PackageReference Include="ClosedXML" Version="0.104.0-preview2" />
51-
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0-rc.2.23479.6" />
52-
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0-rc.2.23479.6" />
53-
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0-rc.2.23479.6" />
54-
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0-rc.2.23479.6" />
55-
<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="8.0.0-rc.2.23479.6" />
51+
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
52+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
53+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
54+
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
55+
<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="8.0.0" />
5656
<PackageReference Include="Serilog" Version="3.1.1" />
5757
<PackageReference Include="Serilog.Exceptions" Version="8.4.0" />
58-
<PackageReference Include="Serilog.Extensions.Hosting" Version="7.0.0" />
58+
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0" />
5959
<PackageReference Include="Serilog.Sinks.File" Version="5.0.1-dev-00968" />
6060
</ItemGroup>
6161

src/Atc.Installer.Wpf.ComponentProvider.ElasticSearch/ElasticSearchServerComponentProviderViewModel.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ public override void CheckServiceState()
9494
}
9595

9696
public override bool CanServiceStopCommandHandler()
97-
=> RunningState == ComponentRunningState.Running;
97+
=> !DisableInstallationActions &&
98+
RunningState == ComponentRunningState.Running;
9899

99100
public override async Task ServiceStopCommandHandler()
100101
{

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

+26-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ public override string ResolvedVirtualRootFolder(
235235
}
236236

237237
public override bool CanServiceStopCommandHandler()
238-
=> RunningState is ComponentRunningState.Running or ComponentRunningState.PartiallyRunning;
238+
=> !DisableInstallationActions &&
239+
RunningState is ComponentRunningState.Running or ComponentRunningState.PartiallyRunning;
239240

240241
public override async Task ServiceStopCommandHandler()
241242
{
@@ -726,6 +727,18 @@ private void CheckPrerequisitesForHostingFramework()
726727
AddToInstallationPrerequisites("IsComponentInstalledMicrosoftAspNetCoreModule2", LogCategoryType.Warning, "IIS module 'Microsoft ASP.NET Core Module V2' is not installed");
727728
}
728729

730+
if (IsDotNetBlazorWebAssembly())
731+
{
732+
if (iisInstallerService.IsComponentInstalledUrlRewriteModule2())
733+
{
734+
AddToInstallationPrerequisites("IsComponentInstalledUrlRewriteModule2", LogCategoryType.Information, "IIS module 'URL Rewrite Module 2' is installed");
735+
}
736+
else
737+
{
738+
AddToInstallationPrerequisites("IsComponentInstalledUrlRewriteModule2", LogCategoryType.Warning, "IIS module 'URL Rewrite Module 2' is not installed");
739+
}
740+
}
741+
729742
break;
730743

731744
case HostingFrameworkType.DotNet8:
@@ -747,6 +760,18 @@ private void CheckPrerequisitesForHostingFramework()
747760
AddToInstallationPrerequisites("IsComponentInstalledMicrosoftAspNetCoreModule2", LogCategoryType.Warning, "IIS module 'Microsoft ASP.NET Core Module V2' is not installed");
748761
}
749762

763+
if (IsDotNetBlazorWebAssembly())
764+
{
765+
if (iisInstallerService.IsComponentInstalledUrlRewriteModule2())
766+
{
767+
AddToInstallationPrerequisites("IsComponentInstalledUrlRewriteModule2", LogCategoryType.Information, "IIS module 'URL Rewrite Module 2' is installed");
768+
}
769+
else
770+
{
771+
AddToInstallationPrerequisites("IsComponentInstalledUrlRewriteModule2", LogCategoryType.Warning, "IIS module 'URL Rewrite Module 2' is not installed");
772+
}
773+
}
774+
750775
break;
751776

752777
case HostingFrameworkType.NodeJs:

src/Atc.Installer.Wpf.ComponentProvider.PostgreSql/PostgreSqlServerComponentProviderViewModel.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ public override bool TryGetStringFromApplicationSetting(
121121
}
122122

123123
public override bool CanServiceStopCommandHandler()
124-
=> RunningState == ComponentRunningState.Running;
124+
=> !DisableInstallationActions &&
125+
RunningState == ComponentRunningState.Running;
125126

126127
public override async Task ServiceStopCommandHandler()
127128
{

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ public override void CheckServiceState()
6868
}
6969

7070
public override bool CanServiceStopCommandHandler()
71-
=> RunningState == ComponentRunningState.Running;
71+
=> !DisableInstallationActions &&
72+
RunningState == ComponentRunningState.Running;
7273

7374
public override async Task ServiceStopCommandHandler()
7475
{

src/Atc.Installer.Wpf.ComponentProvider/ComponentProviderMenuItemView.xaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313
mc:Ignorable="d">
1414

1515
<UserControl.Resources>
16+
<atcValueConverters:BoolToVisibilityCollapsedValueConverter x:Key="BoolToVisibilityCollapsedValueConverter" />
1617
<atcValueConverters:EnumDescriptionToStringValueConverter x:Key="EnumDescriptionToStringValueConverter" />
1718
<valueConverters:ComponentInstallationStateToBrushValueConverter x:Key="ComponentInstallationStateToBrushValueConverter" />
1819
<valueConverters:ComponentRunningStateToBrushValueConverter x:Key="ComponentRunningStateToBrushValueConverter" />
1920
<atcValueConverters:CollectionNullOrEmptyToVisibilityCollapsedValueConverter x:Key="CollectionNullOrEmptyToVisibilityCollapsedValueConverter" />
2021
</UserControl.Resources>
2122

2223
<UserControl.ContextMenu>
23-
<ContextMenu>
24+
<ContextMenu Visibility="{Binding Path=DisableInstallationActions, Converter={StaticResource BoolToVisibilityCollapsedValueConverter}}">
2425
<MenuItem Command="{Binding Path=ServiceStopCommand}" Header="Stop" />
2526
<MenuItem Command="{Binding Path=ServiceDeployCommand}" Header="Deploy" />
2627
<MenuItem Command="{Binding Path=ServiceRemoveCommand}" Header="Remove" />

src/Atc.Installer.Wpf.ComponentProvider/ComponentProviderServiceActionsView.xaml

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
55
xmlns:atc="https://github.com/atc-net/atc-wpf/tree/main/schemas"
6+
xmlns:atcValueConverters="https://github.com/atc-net/atc-wpf/tree/main/schemas/value-converters"
67
xmlns:componentProvider="clr-namespace:Atc.Installer.Wpf.ComponentProvider"
78
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
89
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@@ -11,11 +12,16 @@
1112
d:DesignWidth="400"
1213
mc:Ignorable="d">
1314

15+
<UserControl.Resources>
16+
<atcValueConverters:BoolToVisibilityCollapsedValueConverter x:Key="BoolToVisibilityCollapsedValueConverter" />
17+
</UserControl.Resources>
18+
1419
<GroupBox
1520
Padding="10"
1621
HorizontalAlignment="Stretch"
1722
VerticalAlignment="Top"
18-
Header="Component actions">
23+
Header="Component actions"
24+
Visibility="{Binding Path=DisableInstallationActions, Converter={StaticResource BoolToVisibilityCollapsedValueConverter}}">
1925
<atc:UniformSpacingPanel Orientation="Vertical" Spacing="10">
2026
<Button Command="{Binding Path=ServiceStopCommand}" Content="Stop" />
2127
<Button Command="{Binding Path=ServiceStartCommand}" Content="Start" />

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

+3
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public ComponentProviderViewModel(
6868
InstallationDirectory = installationDirectory;
6969
ProjectName = projectName;
7070
Name = applicationOption.Name;
71+
DisableInstallationActions = applicationOption.DisableInstallationActions;
7172

7273
DefaultApplicationSettings = new ApplicationSettingsViewModel(isDefaultApplicationSettings: true, refComponentProviders);
7374
DefaultApplicationSettings.Populate(defaultApplicationSettings);
@@ -118,6 +119,8 @@ or ComponentType.InternetInformationService
118119

119120
public DirectoryInfo InstallationDirectory { get; }
120121

122+
public bool DisableInstallationActions { get; }
123+
121124
public string ProjectName { get; }
122125

123126
public bool ShowOnlyBaseSettings

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

+50-39
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,39 @@ protected void WorkOnAnalyzeAndUpdateStatesForVersion()
594594
}
595595
}
596596

597+
protected bool IsDotNetBlazorWebAssembly()
598+
{
599+
if (UnpackedZipFolderPath is null &&
600+
InstalledMainFilePath is null)
601+
{
602+
return false;
603+
}
604+
605+
if (UnpackedZipFolderPath is not null)
606+
{
607+
var path = Path.Combine(UnpackedZipFolderPath, "wwwroot", "_framework");
608+
return Directory.Exists(path);
609+
}
610+
611+
if (InstalledMainFilePath is not null)
612+
{
613+
var tmpInstalledMainFilePath = InstalledMainFilePath.GetValueAsString();
614+
if (tmpInstalledMainFilePath.Contains("_framework", StringComparison.Ordinal))
615+
{
616+
return Directory.Exists(tmpInstalledMainFilePath);
617+
}
618+
619+
var path = Path.Combine(
620+
tmpInstalledMainFilePath,
621+
"wwwroot",
622+
"_framework");
623+
624+
return Directory.Exists(path);
625+
}
626+
627+
return false;
628+
}
629+
597630
public (string Value, IList<string> TemplateLocations) ResolveValueAndTemplateLocations(
598631
string value)
599632
{
@@ -875,39 +908,6 @@ private string GetInstallationFolderPathAsTemplateValue()
875908
return instFolderPath;
876909
}
877910

878-
private bool IsDotNetBlazorWebAssembly()
879-
{
880-
if (UnpackedZipFolderPath is null &&
881-
InstalledMainFilePath is null)
882-
{
883-
return false;
884-
}
885-
886-
if (UnpackedZipFolderPath is not null)
887-
{
888-
var path = Path.Combine(UnpackedZipFolderPath, "wwwroot", "_framework");
889-
return Directory.Exists(path);
890-
}
891-
892-
if (InstalledMainFilePath is not null)
893-
{
894-
var tmpInstalledMainFilePath = InstalledMainFilePath.GetValueAsString();
895-
if (tmpInstalledMainFilePath.Contains("_framework", StringComparison.Ordinal))
896-
{
897-
return Directory.Exists(tmpInstalledMainFilePath);
898-
}
899-
900-
var path = Path.Combine(
901-
tmpInstalledMainFilePath,
902-
"wwwroot",
903-
"_framework");
904-
905-
return Directory.Exists(path);
906-
}
907-
908-
return false;
909-
}
910-
911911
private string AdjustInstalledMainFilePathIfNeededAndGetInstallationMainPath()
912912
{
913913
if (UnpackedZipFolderPath is null ||
@@ -922,11 +922,21 @@ private string AdjustInstalledMainFilePathIfNeededAndGetInstallationMainPath()
922922
if (!tmpInstalledMainFilePath.Contains("_framework", StringComparison.Ordinal))
923923
{
924924
var fileInfo = new FileInfo(tmpInstalledMainFilePath);
925-
InstalledMainFilePath.Value = Path.Combine(
926-
fileInfo.Directory!.FullName,
927-
"wwwroot",
928-
"_framework",
929-
fileInfo.Name);
925+
926+
InstalledMainFilePath.Value = HostingFramework switch
927+
{
928+
HostingFrameworkType.DotNet7 => Path.Combine(
929+
fileInfo.Directory!.FullName,
930+
"wwwroot",
931+
"_framework",
932+
fileInfo.Name),
933+
HostingFrameworkType.DotNet8 => Path.Combine(
934+
fileInfo.Directory!.FullName,
935+
"wwwroot",
936+
"_framework",
937+
fileInfo.Name.Replace(".dll", ".wasm", StringComparison.OrdinalIgnoreCase)),
938+
_ => InstalledMainFilePath.Value,
939+
};
930940

931941
return Path.Combine(
932942
UnpackedZipFolderPath,
@@ -1097,7 +1107,8 @@ private void WorkOnAnalyzeAndUpdateStatesForNodeJsVersion()
10971107
private string? GetInstallationMainFilePath()
10981108
{
10991109
var installationMainPath = AdjustInstalledMainFilePathIfNeededAndGetInstallationMainPath();
1100-
var installationMainFile = installationMainPath.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)
1110+
var installationMainFile = installationMainPath.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) ||
1111+
installationMainPath.EndsWith(".wasm", StringComparison.OrdinalIgnoreCase)
11011112
? installationMainPath
11021113
: Path.Combine(installationMainPath, $"{Name}.exe");
11031114

0 commit comments

Comments
 (0)