Added support for CLI-less execution, Switched licenses to PDF in MSI, Bumped version to 3.0.0/3.0.0.0

Update Program.cs, ListComPort.wxs, and 4 more files...
This commit is contained in:
2022-11-03 16:19:33 +01:00
parent 141eb0cf5d
commit b278c4cc73
6 changed files with 52 additions and 17 deletions
+24 -3
View File
@@ -4,7 +4,7 @@ using NibblePoker.Library.ComPortWatcher;
namespace NibblePoker.Application.ListComPort; namespace NibblePoker.Application.ListComPort;
internal static class Program { internal static class Program {
private const string Version = "3.0.0-indev"; private const string Version = "3.0.0";
private static readonly Verb RootVerb = new Verb(""); private static readonly Verb RootVerb = new Verb("");
@@ -32,6 +32,15 @@ internal static class Program {
private static int _exitCode = ErrorCodes.NoError; private static int _exitCode = ErrorCodes.NoError;
/// <summary>
/// Checks if the program is the only owner of its console.
/// This check is used to detect if the program was run from the exe/lnk or via a console.
/// </summary>
/// <returns><c>True</c> if the process is the console's sole owner, <c>False</c> otherwise</returns>
private static bool IsProgramRunDirectly() {
return GetConsoleProcessList(new int[2], 2) <= 1;
}
private static int Main(string[] args) { private static int Main(string[] args) {
try { try {
ArgumentsParser.ParseArguments(RootVerb.RegisterOption(OptionShowAll).RegisterOption(OptionShowDevice) ArgumentsParser.ParseArguments(RootVerb.RegisterOption(OptionShowAll).RegisterOption(OptionShowDevice)
@@ -52,6 +61,7 @@ internal static class Program {
Console.WriteLine("\nRemarks:"); Console.WriteLine("\nRemarks:");
Console.WriteLine(" * If '-d' or '-f' is used, the raw name will not be shown unless '-n' is used."); Console.WriteLine(" * If '-d' or '-f' is used, the raw name will not be shown unless '-n' is used.");
Console.WriteLine(" * If '-D', '-t' or '-p' are used, the special separator between the raw and friendly name and the square brackets are not shown."); Console.WriteLine(" * If '-D', '-t' or '-p' are used, the special separator between the raw and friendly name and the square brackets are not shown.");
Console.WriteLine(" * If the program is raw without going through a console, the options '-n' and '-f' will be used.");
Console.WriteLine(" * By default, the ports are sorted in the order they are provided by the registry, which is often chronological."); Console.WriteLine(" * By default, the ports are sorted in the order they are provided by the registry, which is often chronological.");
Console.WriteLine(" * The 'raw name' refers to a port name. (e.g.: COM1, COM2, ...)"); Console.WriteLine(" * The 'raw name' refers to a port name. (e.g.: COM1, COM2, ...)");
Console.WriteLine(" * The 'device name' refers to a port device path. (e.g.: \\Device\\Serial1, ...)"); Console.WriteLine(" * The 'device name' refers to a port device path. (e.g.: \\Device\\Serial1, ...)");
@@ -90,12 +100,12 @@ internal static class Program {
_shouldPrintDeviceNames = true; _shouldPrintDeviceNames = true;
} }
if(OptionShowFriendly.WasUsed()) { if(OptionShowFriendly.WasUsed() || IsProgramRunDirectly()) {
_shouldPrintRawNames = false; _shouldPrintRawNames = false;
_shouldPrintFriendlyNames = true; _shouldPrintFriendlyNames = true;
} }
if(OptionShowNameRaw.WasUsed()) { if(OptionShowNameRaw.WasUsed() || IsProgramRunDirectly()) {
_shouldPrintRawNames = true; _shouldPrintRawNames = true;
} }
@@ -178,6 +188,17 @@ internal static class Program {
_exitCode = ErrorCodes.NoComPorts; _exitCode = ErrorCodes.NoComPorts;
} }
// Allows the program to be ran from a shortcut without closing the console instantly.
if(IsProgramRunDirectly()) {
Console.Write("\nPress any key to continue...");
Console.ReadKey();
}
return _exitCode; return _exitCode;
} }
// Imports "GetConsoleProcessList(...)" in order to know if the program was ran via a shortcut or CLI.
// See: https://learn.microsoft.com/en-us/windows/console/getconsoleprocesslist
[System.Runtime.InteropServices.DllImport("kernel32.dll")]
private static extern int GetConsoleProcessList(int[] buffer, int size);
} }
@@ -7,7 +7,7 @@
<!-- <!--
See: https://wixtoolset.org/documentation/manual/v3/xsd/wix/product.html See: https://wixtoolset.org/documentation/manual/v3/xsd/wix/product.html
--> -->
<Product Id="*" Name="$(var.ProductName)" Language="1033" Version="1.0.0.0" <Product Id="*" Name="$(var.ProductName)" Language="1033" Version="3.0.0.0"
Manufacturer="$(var.ProductManufacturer)" UpgradeCode="$(var.ProductUpgradeCode)"> Manufacturer="$(var.ProductManufacturer)" UpgradeCode="$(var.ProductUpgradeCode)">
<!-- <!--
@@ -83,12 +83,12 @@
<File KeyPath="yes" Source="$(var.FilePathExecutable)" Name="lscom.exe" /> <File KeyPath="yes" Source="$(var.FilePathExecutable)" Name="lscom.exe" />
</Component> </Component>
<Component Id="Licenses" Guid="5aa34a6f-2b5c-4544-8979-a20d6c1d3f3c" Directory="LICENSESFOLDER" Feature="FeatureLicenses" Win64="$(var.Win64)"> <Component Id="Licenses" Guid="5aa34a6f-2b5c-4544-8979-a20d6c1d3f3c" Directory="LICENSESFOLDER" Feature="FeatureLicenses" Win64="$(var.Win64)">
<File Source="Licenses\License_DotNetCore.rtf" Name="License_DotNetCore.rtf" /> <File Source="Licenses\License_DotNetCore.pdf" Name="License_DotNetCore.pdf" />
<File Source="Licenses\License_Microsoft_DotNet.rtf" Name="License_Microsoft_DotNet.rtf" /> <File Source="Licenses\License_Microsoft_DotNet.pdf" Name="License_Microsoft_DotNet.pdf" />
<File Source="Licenses\License_Microsoft_VisualStudio.rtf" Name="License_Microsoft_VisualStudio.rtf" /> <File Source="Licenses\License_Microsoft_VisualStudio.pdf" Name="License_Microsoft_VisualStudio.pdf" />
<File Source="Licenses\License_NibblePoker.rtf" Name="License_NibblePoker.rtf" /> <File Source="Licenses\License_NibblePoker.pdf" Name="License_NibblePoker.pdf" />
<File Source="Licenses\License_WindowsSDK.rtf" Name="License_WindowsSDK.rtf" /> <File Source="Licenses\License_WindowsSDK.pdf" Name="License_WindowsSDK.pdf" />
<File Source="Licenses\PrivacyNotice_Microsoft_2022-09.rtf" Name="PrivacyNotice_Microsoft_2022-09.rtf" /> <File Source="Licenses\PrivacyNotice_Microsoft_2022-09.pdf" Name="PrivacyNotice_Microsoft_2022-09.pdf" />
</Component> </Component>
<Component Id="Registry" Guid="73b5468a-97b3-4469-a95d-70330ed229e6" Directory="INSTALLFOLDER" Feature="FeatureRegistryPath" Win64="$(var.Win64)"> <Component Id="Registry" Guid="73b5468a-97b3-4469-a95d-70330ed229e6" Directory="INSTALLFOLDER" Feature="FeatureRegistryPath" Win64="$(var.Win64)">
<Environment Id="UpdatePath" Name="PATH" Part="last" Action="set" Permanent="yes" System="yes" Value="[INSTALLFOLDER]" /> <Environment Id="UpdatePath" Name="PATH" Part="last" Action="set" Permanent="yes" System="yes" Value="[INSTALLFOLDER]" />
@@ -2,8 +2,8 @@
<Include> <Include>
<!-- Shared variables --> <!-- Shared variables -->
<?define ProductManufacturer = "Herwin Bozet" ?> <?define ProductManufacturer = "Herwin Bozet" ?>
<?define PackageDescription = "Installer for &quot;lscom.exe&quot;." ?> <?define PackageDescription = "ListComPort / lscom" ?> <!-- Also reffered to as 'Subject' ! -->
<?define PackageComments = "Insert a comment here !" ?> <?define PackageComments = "This installer database contains the logic and data required to install ListComPort." ?>
<!-- TODO: Add contact, support and help fields ! --> <!-- TODO: Add contact, support and help fields ! -->
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<WixLocalization Culture="en-us" xmlns="http://schemas.microsoft.com/wix/2006/localization">
<!--
Custom string for the license agreement.
-->
<String Id="LicenseAgreementDlgLicenseAcceptedCheckBox">I accept the terms in these License Agreements and Privacy Statement</String>
</WixLocalization>
+2 -2
View File
@@ -12,7 +12,7 @@ echo Executing "candle.exe" for x64...
"C:\Program Files (x86)\WiX Toolset v3.14\bin\candle.exe" -nologo "ListComPort.wxs" -out "ListComPort_x64.wixobj" -ext WixUIExtension "C:\Program Files (x86)\WiX Toolset v3.14\bin\candle.exe" -nologo "ListComPort.wxs" -out "ListComPort_x64.wixobj" -ext WixUIExtension
echo Executing "light.exe" for x64... echo Executing "light.exe" for x64...
"C:\Program Files (x86)\WiX Toolset v3.14\bin\light.exe" "ListComPort_x64.wixobj" -out "ListComPort_x64.msi" -ext WixUIExtension -cultures:en-us "C:\Program Files (x86)\WiX Toolset v3.14\bin\light.exe" "ListComPort_x64.wixobj" -loc en-us.wxl -out "ListComPort_x64.msi" -ext WixUIExtension -cultures:en-us
set WixTargetPlatform=x86 set WixTargetPlatform=x86
@@ -20,7 +20,7 @@ echo Executing "candle.exe" for x86...
"C:\Program Files (x86)\WiX Toolset v3.14\bin\candle.exe" -nologo "ListComPort.wxs" -out "ListComPort_x86.wixobj" -ext WixUIExtension "C:\Program Files (x86)\WiX Toolset v3.14\bin\candle.exe" -nologo "ListComPort.wxs" -out "ListComPort_x86.wixobj" -ext WixUIExtension
echo Executing "light.exe" for x86... echo Executing "light.exe" for x86...
"C:\Program Files (x86)\WiX Toolset v3.14\bin\light.exe" "ListComPort_x86.wixobj" -out "ListComPort_x86.msi" -ext WixUIExtension -cultures:en-us "C:\Program Files (x86)\WiX Toolset v3.14\bin\light.exe" "ListComPort_x86.wixobj" -loc en-us.wxl -out "ListComPort_x86.msi" -ext WixUIExtension -cultures:en-us
del *.wixobj del *.wixobj
del *.wixpdb del *.wixpdb
+10 -3
View File
@@ -20,7 +20,8 @@ The latest releases can be found here: "*[Release page](https://github.com/azias
* Switched from *PureBasic* to *.NET 6.0*. * Switched from *PureBasic* to *.NET 6.0*.
* Improved **a lot** of the program's logic. * Improved **a lot** of the program's logic.
* Added the `-h`/`--short-help`. * Added the `-h`/`--short-help`.
* Added support for Windows ARM & ARM64 * Added support for Windows ARM & ARM64.
* Support for running without a console. (See [remarks](#remarks) #3)
## Usage ## Usage
``` ```
@@ -47,6 +48,7 @@ Launch arguments:
## Remarks ## Remarks
* If '-d' or '-f' is used, the raw name will not be shown unless '-n' is used. * If '-d' or '-f' is used, the raw name will not be shown unless '-n' is used.
* If '-D', '-t' or '-p' are used, the special separator between the raw and friendly name and the square brackets are not shown. * If '-D', '-t' or '-p' are used, the special separator between the raw and friendly name and the square brackets are not shown.
* If the program is raw without going through a console, the options '-n' and '-f' will be used
* By default, the ports are sorted in the order they are provided by the registry, which is often chronological. * By default, the ports are sorted in the order they are provided by the registry, which is often chronological.
* The 'raw name' refers to a port name. (e.g.: COM1, COM2, ...) * The 'raw name' refers to a port name. (e.g.: COM1, COM2, ...)
* The 'device name' refers to a port device path. (e.g.: \Device\Serial1, ...) * The 'device name' refers to a port device path. (e.g.: \Device\Serial1, ...)
@@ -91,9 +93,14 @@ You can simply clone the repository with the following command:
git clone https://github.com/aziascreations/DotNet-ListComPort.git git clone https://github.com/aziascreations/DotNet-ListComPort.git
``` ```
Once this is done, you can compile it with the [compile.bat](compile.bat) script file. Once this is done, you can compile it with the [make.bat](make.bat) script file.
Please note that you may need to have to edit your `PATH` or the aforementioned script
so that 7-Zip and Wix Toolset v3.14 can be used by it.
Finally, you should be able to find the executables in the "[Builds](Builds/)" folder,
and the distributable packages in the "[Packages](Packages/)" folder.
Finally, you should be able to find the executables in the "[Builds](Builds/)" folder.
## License ## License
This project and all the libraries it uses are licensed under the [MIT](LICENSE) license. This project and all the libraries it uses are licensed under the [MIT](LICENSE) license.