Skip to content

Commit

Permalink
Merge pull request #14 from atc-net/feature/support-blazor-webassembly
Browse files Browse the repository at this point in the history
Support blazor webassembly & Introduce options=>DisableInstallationActions
  • Loading branch information
davidkallesen authored Nov 16, 2023
2 parents 6611b15 + 9d55ad3 commit d1ec770
Show file tree
Hide file tree
Showing 19 changed files with 115 additions and 61 deletions.
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,8 @@ dotnet_diagnostic.S1135.severity = suggestion # https://github.com/atc-net
dotnet_diagnostic.CA1040.severity = none # Avoid empty interface
dotnet_diagnostic.CA1724.severity = none # The type name App conflicts in whole or in part with the namespace name
dotnet_diagnostic.CA1848.severity = none # Skip for now: Use the LoggerMessage delegates
dotnet_diagnostic.CA1859.severity = suggestion # Use concrete types when possible for improved performance
dotnet_diagnostic.CA1860.severity = suggestion # Avoid using 'Enumerable.Any()' extension method
dotnet_diagnostic.CA2227.severity = none # Skip for now: Read only collection
dotnet_diagnostic.CA2254.severity = none # Skip for now: Template should be a static expression
dotnet_diagnostic.CA5351.severity = none # Do Not Use Broken Cryptographic Algorithms - Its ok, only using to calculate a file-hash
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<ItemGroup Label="Code Analyzers">
<PackageReference Include="AsyncFixer" Version="1.6.0" PrivateAssets="All" />
<PackageReference Include="Asyncify" Version="0.9.7" PrivateAssets="All" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.106" PrivateAssets="All" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.110" PrivateAssets="All" />
<PackageReference Include="SecurityCodeScan.VS2019" Version="5.6.7" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.507" PrivateAssets="All" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.12.0.78982" PrivateAssets="All" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

<ItemGroup>
<PackageReference Include="Atc" Version="2.0.386" />
<PackageReference Include="Azure.Identity" Version="1.10.3" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.19.0" />
<PackageReference Include="Azure.Identity" Version="1.10.4" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.19.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<ItemGroup>
<PackageReference Include="Atc" Version="2.0.386" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Atc.Installer.Integration/GitHubReleaseService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class GitHubReleaseService : IGitHubReleaseService
.GetProperty("tag_name")
.ToString();

if (versionString.StartsWith("v", StringComparison.OrdinalIgnoreCase))
if (versionString.StartsWith('v'))
{
versionString = versionString[1..];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public static IList<X509Certificate2> GetX509Certificates(
StoreLocation storeLocation = StoreLocation.LocalMachine,
bool validOnly = true)
{
IList<X509Certificate2> certificates = new List<X509Certificate2>();
var certificates = new List<X509Certificate2>();

using var store = new X509Store(
storeName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class ApplicationOption

public string? RawInstallationPath { get; set; }

public bool DisableInstallationActions { get; set; }

public IList<string> DependentComponents { get; set; } = new List<string>();

public IList<string> DependentServices { get; init; } = new List<string>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ private static bool IsJavaRuntime(
}

[SuppressMessage("Minor Code Smell", "S1075:URIs should not be hardcoded", Justification = "OK.")]
[SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments", Justification = "OK.")]
private async Task<bool> IsNodeJs(
ushort mainVersion)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Atc.Installer.Wpf.App/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ await ConfigurationFileHelper
}
}

private static Serilog.ILogger CreateLoggerConfigurationForSerilogFileLog()
private static Serilog.Core.Logger CreateLoggerConfigurationForSerilogFileLog()
{
var systemName = AssemblyHelper.GetSystemNameAsKebabCasing();
var loggerConfig = new LoggerConfiguration();
Expand Down
6 changes: 3 additions & 3 deletions src/Atc.Installer.Wpf.App/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
[assembly: AssemblyCompany("atc-net")]
[assembly: AssemblyProduct("Atc.Installer")]
[assembly: AssemblyTitle("Atc.Installer")]
[assembly: AssemblyVersion("1.0.14.0")]
[assembly: AssemblyInformationalVersion("1.0.14.0")]
[assembly: AssemblyFileVersion("1.0.14.0")]
[assembly: AssemblyVersion("1.0.15.0")]
[assembly: AssemblyInformationalVersion("1.0.15.0")]
[assembly: AssemblyFileVersion("1.0.15.0")]
[assembly: System.Resources.NeutralResourcesLanguage("en")]
[assembly: System.Runtime.Versioning.TargetPlatform("Windows7.0")]
[assembly: System.Runtime.Versioning.SupportedOSPlatform("Windows7.0")]
12 changes: 6 additions & 6 deletions src/Atc.Installer.Wpf.App/Atc.Installer.Wpf.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@
<PackageReference Include="Atc.Wpf.FontIcons" Version="2.0.297" />
<PackageReference Include="Atc.Wpf.Theming" Version="2.0.297" />
<PackageReference Include="ClosedXML" Version="0.104.0-preview2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="8.0.0" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.Exceptions" Version="8.4.0" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="7.0.0" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.1-dev-00968" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ public override void CheckServiceState()
}

public override bool CanServiceStopCommandHandler()
=> RunningState == ComponentRunningState.Running;
=> !DisableInstallationActions &&
RunningState == ComponentRunningState.Running;

public override async Task ServiceStopCommandHandler()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ public override string ResolvedVirtualRootFolder(
}

public override bool CanServiceStopCommandHandler()
=> RunningState is ComponentRunningState.Running or ComponentRunningState.PartiallyRunning;
=> !DisableInstallationActions &&
RunningState is ComponentRunningState.Running or ComponentRunningState.PartiallyRunning;

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

if (IsDotNetBlazorWebAssembly())
{
if (iisInstallerService.IsComponentInstalledUrlRewriteModule2())
{
AddToInstallationPrerequisites("IsComponentInstalledUrlRewriteModule2", LogCategoryType.Information, "IIS module 'URL Rewrite Module 2' is installed");
}
else
{
AddToInstallationPrerequisites("IsComponentInstalledUrlRewriteModule2", LogCategoryType.Warning, "IIS module 'URL Rewrite Module 2' is not installed");
}
}

break;

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

if (IsDotNetBlazorWebAssembly())
{
if (iisInstallerService.IsComponentInstalledUrlRewriteModule2())
{
AddToInstallationPrerequisites("IsComponentInstalledUrlRewriteModule2", LogCategoryType.Information, "IIS module 'URL Rewrite Module 2' is installed");
}
else
{
AddToInstallationPrerequisites("IsComponentInstalledUrlRewriteModule2", LogCategoryType.Warning, "IIS module 'URL Rewrite Module 2' is not installed");
}
}

break;

case HostingFrameworkType.NodeJs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ public override bool TryGetStringFromApplicationSetting(
}

public override bool CanServiceStopCommandHandler()
=> RunningState == ComponentRunningState.Running;
=> !DisableInstallationActions &&
RunningState == ComponentRunningState.Running;

public override async Task ServiceStopCommandHandler()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public override void CheckServiceState()
}

public override bool CanServiceStopCommandHandler()
=> RunningState == ComponentRunningState.Running;
=> !DisableInstallationActions &&
RunningState == ComponentRunningState.Running;

public override async Task ServiceStopCommandHandler()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
mc:Ignorable="d">

<UserControl.Resources>
<atcValueConverters:BoolToVisibilityCollapsedValueConverter x:Key="BoolToVisibilityCollapsedValueConverter" />
<atcValueConverters:EnumDescriptionToStringValueConverter x:Key="EnumDescriptionToStringValueConverter" />
<valueConverters:ComponentInstallationStateToBrushValueConverter x:Key="ComponentInstallationStateToBrushValueConverter" />
<valueConverters:ComponentRunningStateToBrushValueConverter x:Key="ComponentRunningStateToBrushValueConverter" />
<atcValueConverters:CollectionNullOrEmptyToVisibilityCollapsedValueConverter x:Key="CollectionNullOrEmptyToVisibilityCollapsedValueConverter" />
</UserControl.Resources>

<UserControl.ContextMenu>
<ContextMenu>
<ContextMenu Visibility="{Binding Path=DisableInstallationActions, Converter={StaticResource BoolToVisibilityCollapsedValueConverter}}">
<MenuItem Command="{Binding Path=ServiceStopCommand}" Header="Stop" />
<MenuItem Command="{Binding Path=ServiceDeployCommand}" Header="Deploy" />
<MenuItem Command="{Binding Path=ServiceRemoveCommand}" Header="Remove" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:atc="https://github.com/atc-net/atc-wpf/tree/main/schemas"
xmlns:atcValueConverters="https://github.com/atc-net/atc-wpf/tree/main/schemas/value-converters"
xmlns:componentProvider="clr-namespace:Atc.Installer.Wpf.ComponentProvider"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Expand All @@ -11,11 +12,16 @@
d:DesignWidth="400"
mc:Ignorable="d">

<UserControl.Resources>
<atcValueConverters:BoolToVisibilityCollapsedValueConverter x:Key="BoolToVisibilityCollapsedValueConverter" />
</UserControl.Resources>

<GroupBox
Padding="10"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
Header="Component actions">
Header="Component actions"
Visibility="{Binding Path=DisableInstallationActions, Converter={StaticResource BoolToVisibilityCollapsedValueConverter}}">
<atc:UniformSpacingPanel Orientation="Vertical" Spacing="10">
<Button Command="{Binding Path=ServiceStopCommand}" Content="Stop" />
<Button Command="{Binding Path=ServiceStartCommand}" Content="Start" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public ComponentProviderViewModel(
InstallationDirectory = installationDirectory;
ProjectName = projectName;
Name = applicationOption.Name;
DisableInstallationActions = applicationOption.DisableInstallationActions;

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

public DirectoryInfo InstallationDirectory { get; }

public bool DisableInstallationActions { get; }

public string ProjectName { get; }

public bool ShowOnlyBaseSettings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,39 @@ protected void WorkOnAnalyzeAndUpdateStatesForVersion()
}
}

protected bool IsDotNetBlazorWebAssembly()
{
if (UnpackedZipFolderPath is null &&
InstalledMainFilePath is null)
{
return false;
}

if (UnpackedZipFolderPath is not null)
{
var path = Path.Combine(UnpackedZipFolderPath, "wwwroot", "_framework");
return Directory.Exists(path);
}

if (InstalledMainFilePath is not null)
{
var tmpInstalledMainFilePath = InstalledMainFilePath.GetValueAsString();
if (tmpInstalledMainFilePath.Contains("_framework", StringComparison.Ordinal))
{
return Directory.Exists(tmpInstalledMainFilePath);
}

var path = Path.Combine(
tmpInstalledMainFilePath,
"wwwroot",
"_framework");

return Directory.Exists(path);
}

return false;
}

public (string Value, IList<string> TemplateLocations) ResolveValueAndTemplateLocations(
string value)
{
Expand Down Expand Up @@ -875,39 +908,6 @@ private string GetInstallationFolderPathAsTemplateValue()
return instFolderPath;
}

private bool IsDotNetBlazorWebAssembly()
{
if (UnpackedZipFolderPath is null &&
InstalledMainFilePath is null)
{
return false;
}

if (UnpackedZipFolderPath is not null)
{
var path = Path.Combine(UnpackedZipFolderPath, "wwwroot", "_framework");
return Directory.Exists(path);
}

if (InstalledMainFilePath is not null)
{
var tmpInstalledMainFilePath = InstalledMainFilePath.GetValueAsString();
if (tmpInstalledMainFilePath.Contains("_framework", StringComparison.Ordinal))
{
return Directory.Exists(tmpInstalledMainFilePath);
}

var path = Path.Combine(
tmpInstalledMainFilePath,
"wwwroot",
"_framework");

return Directory.Exists(path);
}

return false;
}

private string AdjustInstalledMainFilePathIfNeededAndGetInstallationMainPath()
{
if (UnpackedZipFolderPath is null ||
Expand All @@ -922,11 +922,21 @@ private string AdjustInstalledMainFilePathIfNeededAndGetInstallationMainPath()
if (!tmpInstalledMainFilePath.Contains("_framework", StringComparison.Ordinal))
{
var fileInfo = new FileInfo(tmpInstalledMainFilePath);
InstalledMainFilePath.Value = Path.Combine(
fileInfo.Directory!.FullName,
"wwwroot",
"_framework",
fileInfo.Name);

InstalledMainFilePath.Value = HostingFramework switch
{
HostingFrameworkType.DotNet7 => Path.Combine(
fileInfo.Directory!.FullName,
"wwwroot",
"_framework",
fileInfo.Name),
HostingFrameworkType.DotNet8 => Path.Combine(
fileInfo.Directory!.FullName,
"wwwroot",
"_framework",
fileInfo.Name.Replace(".dll", ".wasm", StringComparison.OrdinalIgnoreCase)),
_ => InstalledMainFilePath.Value,
};

return Path.Combine(
UnpackedZipFolderPath,
Expand Down Expand Up @@ -1097,7 +1107,8 @@ private void WorkOnAnalyzeAndUpdateStatesForNodeJsVersion()
private string? GetInstallationMainFilePath()
{
var installationMainPath = AdjustInstalledMainFilePathIfNeededAndGetInstallationMainPath();
var installationMainFile = installationMainPath.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)
var installationMainFile = installationMainPath.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) ||
installationMainPath.EndsWith(".wasm", StringComparison.OrdinalIgnoreCase)
? installationMainPath
: Path.Combine(installationMainPath, $"{Name}.exe");

Expand Down

0 comments on commit d1ec770

Please sign in to comment.