Add publish script
This commit is contained in:
@@ -4,7 +4,10 @@ namespace Sharp7.Monitor;
|
|||||||
|
|
||||||
public static class CustomStyles
|
public static class CustomStyles
|
||||||
{
|
{
|
||||||
public static Style Error { get; } = new Style(foreground: Color.Red);
|
public static Style Default { get; } = new(background:Color.Black);
|
||||||
public static Style Note { get; } = new(foreground: Color.DarkSlateGray1);
|
|
||||||
public static Style? Hex { get; } = new(foreground: Color.Blue);
|
public static Style Error { get; } = Default.Foreground(Color.Red);
|
||||||
}
|
public static Style Hex { get; } = Default.Foreground(Color.Blue);
|
||||||
|
public static Style Note { get; } = Default.Foreground(Color.DarkSlateGray1);
|
||||||
|
public static Style TableBorder { get; } = Default.Foreground(Color.DarkGreen);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using System.Text;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using Spectre.Console;
|
using System.Text;
|
||||||
using Spectre.Console.Cli;
|
using Spectre.Console.Cli;
|
||||||
|
|
||||||
namespace Sharp7.Monitor;
|
namespace Sharp7.Monitor;
|
||||||
@@ -8,11 +8,15 @@ internal class Program
|
|||||||
{
|
{
|
||||||
private static readonly CancellationTokenSource cts = new();
|
private static readonly CancellationTokenSource cts = new();
|
||||||
|
|
||||||
|
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ReadPlcCommand))]
|
||||||
|
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ReadPlcCommand.Settings))]
|
||||||
|
[DynamicDependency(DynamicallyAccessedMemberTypes.All, "Spectre.Console.Cli.ExplainCommand", "Spectre.Console.Cli")]
|
||||||
|
[DynamicDependency(DynamicallyAccessedMemberTypes.All, "Spectre.Console.Cli.VersionCommand", "Spectre.Console.Cli")]
|
||||||
|
[DynamicDependency(DynamicallyAccessedMemberTypes.All, "Spectre.Console.Cli.XmlDocCommand", "Spectre.Console.Cli")]
|
||||||
public static async Task<int> Main(string[] args)
|
public static async Task<int> Main(string[] args)
|
||||||
{
|
{
|
||||||
Console.InputEncoding = Console.OutputEncoding = Encoding.UTF8;
|
Console.InputEncoding = Console.OutputEncoding = Encoding.UTF8;
|
||||||
|
|
||||||
|
|
||||||
Console.CancelKeyPress += OnCancelKeyPress;
|
Console.CancelKeyPress += OnCancelKeyPress;
|
||||||
AppDomain.CurrentDomain.ProcessExit += OnProcessExit;
|
AppDomain.CurrentDomain.ProcessExit += OnProcessExit;
|
||||||
|
|
||||||
@@ -25,22 +29,17 @@ internal class Program
|
|||||||
|
|
||||||
app.Configure(config => { config.SetApplicationName("s7mon.exe"); });
|
app.Configure(config => { config.SetApplicationName("s7mon.exe"); });
|
||||||
|
|
||||||
await app.RunAsync(args);
|
return await app.RunAsync(args);
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException)
|
catch (OperationCanceledException)
|
||||||
{
|
{
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
AppDomain.CurrentDomain.ProcessExit -= OnProcessExit;
|
AppDomain.CurrentDomain.ProcessExit -= OnProcessExit;
|
||||||
Console.CancelKeyPress -= OnCancelKeyPress;
|
Console.CancelKeyPress -= OnCancelKeyPress;
|
||||||
}
|
}
|
||||||
|
|
||||||
AnsiConsole.WriteLine();
|
|
||||||
AnsiConsole.MarkupLine("[lightgoldenrod2_1]THANK YOU FOR PARTICIPATING IN THIS ENRICHMENT CENTER ACTIVITY![/]");
|
|
||||||
AnsiConsole.WriteLine();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void OnCancelKeyPress(object? sender, ConsoleCancelEventArgs e)
|
private static void OnCancelKeyPress(object? sender, ConsoleCancelEventArgs e)
|
||||||
@@ -62,4 +61,4 @@ internal class Program
|
|||||||
|
|
||||||
cts.Cancel();
|
cts.Cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,10 @@ internal sealed class ReadPlcCommand : AsyncCommand<ReadPlcCommand.Settings>
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AnsiConsole.WriteLine();
|
||||||
|
AnsiConsole.MarkupLine("[lightgoldenrod2_1]THANK YOU FOR PARTICIPATING IN THIS ENRICHMENT CENTER ACTIVITY![/]");
|
||||||
|
AnsiConsole.WriteLine();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,10 +46,10 @@ internal sealed class ReadPlcCommand : AsyncCommand<ReadPlcCommand.Settings>
|
|||||||
long => FormatNo(),
|
long => FormatNo(),
|
||||||
ulong => FormatNo(),
|
ulong => FormatNo(),
|
||||||
|
|
||||||
_ => new Text(value.ToString() ?? "")
|
_ => new Text(value.ToString() ?? "", CustomStyles.Default)
|
||||||
};
|
};
|
||||||
|
|
||||||
Markup FormatNo() => new($"[blue]0x{value:X2}[/] {value}");
|
Markup FormatNo() => new($"[blue]0x{value:X2}[/] {value}", CustomStyles.Default);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task RunProgram(Settings settings, CancellationToken token)
|
private static async Task RunProgram(Settings settings, CancellationToken token)
|
||||||
@@ -84,14 +88,14 @@ internal sealed class ReadPlcCommand : AsyncCommand<ReadPlcCommand.Settings>
|
|||||||
var table = new Table
|
var table = new Table
|
||||||
{
|
{
|
||||||
Border = TableBorder.Rounded,
|
Border = TableBorder.Rounded,
|
||||||
BorderStyle = new Style(foreground: Color.DarkGreen)
|
BorderStyle = CustomStyles.TableBorder,
|
||||||
};
|
};
|
||||||
|
|
||||||
table.AddColumn("Variable");
|
table.AddColumn(new TableColumn(new Text("Variable", CustomStyles.Default)));
|
||||||
table.AddColumn("Value");
|
table.AddColumn(new TableColumn(new Text( "Value", CustomStyles.Default)));
|
||||||
|
|
||||||
foreach (var record in variableContainer.VariableRecords)
|
foreach (var record in variableContainer.VariableRecords)
|
||||||
table.AddRow(record.Address, "[gray]init[/]");
|
table.AddRow(new Text( record.Address, CustomStyles.Default), new Text("init", CustomStyles.Note));
|
||||||
|
|
||||||
await AnsiConsole.Live(table)
|
await AnsiConsole.Live(table)
|
||||||
.StartAsync(async ctx =>
|
.StartAsync(async ctx =>
|
||||||
@@ -144,4 +148,4 @@ internal sealed class ReadPlcCommand : AsyncCommand<ReadPlcCommand.Settings>
|
|||||||
return ValidationResult.Success();
|
return ValidationResult.Success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,15 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
|
<AssemblyName>s7mon</AssemblyName>
|
||||||
|
|
||||||
|
<PublishSingleFile>true</PublishSingleFile>
|
||||||
|
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AssemblyName>s7mon</AssemblyName>
|
|
||||||
|
<InvariantGlobalization>true</InvariantGlobalization>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
4
publish.ps1
Normal file
4
publish.ps1
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
dotnet publish .\Sharp7.Monitor\Sharp7.Monitor.csproj -c Release --output publish\non-sc --no-self-contained
|
||||||
|
|
||||||
|
dotnet publish .\Sharp7.Monitor\Sharp7.Monitor.csproj -c Release --output publish\sc -p:PublishTrimmed=true -p:EnableCompressionInSingleFile=true --self-contained
|
||||||
Reference in New Issue
Block a user