From fe794a78cf66daef3d6e5cc11328d04cfea34e7d Mon Sep 17 00:00:00 2001 From: Dominique Louis Date: Fri, 22 Sep 2023 22:57:30 +0100 Subject: [PATCH 1/2] Don't rename App.dll to App.exe. (#349) * Don't rename App.dll to App.exe, so only App.dll is used. --- .../Devices/MeadowLocalDevice.FileManager.cs | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/Meadow.CLI.Core/Devices/MeadowLocalDevice.FileManager.cs b/Meadow.CLI.Core/Devices/MeadowLocalDevice.FileManager.cs index 03378fbf..a64ef0b9 100644 --- a/Meadow.CLI.Core/Devices/MeadowLocalDevice.FileManager.cs +++ b/Meadow.CLI.Core/Devices/MeadowLocalDevice.FileManager.cs @@ -577,40 +577,40 @@ public async Task DeployApp(string applicationFilePath, return; } - await DeleteTemporaryFiles(cancellationToken); - var fi = new FileInfo(applicationFilePath); + var directoryName = fi.DirectoryName ?? string.Empty; + var meadowDll = Path.Combine(directoryName, "Meadow.dll"); + + if (!File.Exists(meadowDll)) + { + Logger.LogError($"{meadowDll} not found."); + return; + } + + var fileName = fi.Name; + var fileNamePdb = Path.Combine(directoryName, "App.pdb"); + + await DeleteTemporaryFiles(cancellationToken); var deviceFiles = await GetFilesAndCrcs( DefaultTimeout, cancellationToken: cancellationToken); - //rename App.dll to App.exe - var fileNameDll = Path.Combine(fi.DirectoryName, "App.dll"); - var fileNameExe = Path.Combine(fi.DirectoryName, "App.exe"); - var fileNamePdb = Path.Combine(fi.DirectoryName, "App.pdb"); - - if (File.Exists(fileNameDll)) - { - if (File.Exists(fileNameExe)) - { - File.Delete(fileNameExe); - } - File.Copy(fileNameDll, fileNameExe); - } - foreach (var f in deviceFiles) { Logger.LogInformation($"Found {f.FileName} (CRC: {f.Crc})" + Environment.NewLine); } - var binaries = Directory.EnumerateFiles(fi.DirectoryName, "*.*", SearchOption.TopDirectoryOnly) + var binaries = Directory.EnumerateFiles(directoryName, "*.*", SearchOption.TopDirectoryOnly) .Where(s => new FileInfo(s).Extension != ".dll") .Where(s => new FileInfo(s).Extension != ".pdb"); // .Where(s => extensions.Contains(new FileInfo(s).Extension)); var files = new Dictionary(); + // Add the App.dll + await AddFile(Path.Combine(directoryName, fileName), false); + if (includePdbs) { await AddFile(fileNamePdb, false); @@ -647,12 +647,12 @@ async Task AddFile(string file, bool includePdbs) } } - var dependencies = AssemblyManager.GetDependencies(fi.Name, fi.DirectoryName, osVersion) + var dependencies = AssemblyManager.GetDependencies(fileName, directoryName, osVersion) .Where(x => x.Contains("App.") == false) // .Where(x => dllLinkIngoreList.Any(f => x.Contains(f)) == false) .ToList(); - var trimmedDependencies = await AssemblyManager.TrimDependencies(fi.Name, fi.DirectoryName, dependencies, noLink, Logger, includePdbs: includePdbs, verbose: verbose); + var trimmedDependencies = await AssemblyManager.TrimDependencies(fileName, directoryName, dependencies, noLink, Logger, includePdbs: includePdbs, verbose: verbose); //add local files (this includes App.exe) foreach (var file in binaries) @@ -760,7 +760,7 @@ await DeployApp(applicationFilePath, } else { - Logger.LogInformation($"{Environment.NewLine}{fi.Name} deploy complete!{Environment.NewLine}"); + Logger.LogInformation($"{Environment.NewLine}{fileName} deploy complete!{Environment.NewLine}"); } } catch (Exception ex) From 71fe7649aacd630bac1dbc87cdc260f63cf44742 Mon Sep 17 00:00:00 2001 From: Dominique Louis Date: Mon, 25 Sep 2023 09:21:06 +0100 Subject: [PATCH 2/2] Do some decent version comparisons. (#351) * Fix 350, by doing some decent version comparisons. * Only accept --verbose to change loglevel. * Bump version to 1.3.4 --- .github/workflows/dotnet.yml | 6 +++--- Meadow.CLI.Core/Constants.cs | 2 +- Meadow.CLI.Core/Internals/Dfu/DfuUtils.cs | 15 +++++++-------- Meadow.CLI.Core/Managers/DownloadManager.cs | 2 +- Meadow.CLI.Core/Meadow.CLI.Core.6.0.0.csproj | 2 +- Meadow.CLI.Core/Meadow.CLI.Core.Classic.csproj | 2 +- Meadow.CLI.Core/Meadow.CLI.Core.VS2019.csproj | 2 +- Meadow.CLI.Core/Meadow.CLI.Core.csproj | 2 +- Meadow.CLI/Meadow.CLI.Classic.csproj | 2 +- Meadow.CLI/Meadow.CLI.csproj | 2 +- Meadow.CLI/Program.cs | 9 ++------- 11 files changed, 20 insertions(+), 26 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 33b7b870..20e01a35 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -1,8 +1,8 @@ name: Meadow.CLI env: - CLI_RELEASE_VERSION: 1.3.0.0 - IDE_TOOLS_RELEASE_VERSION: 1.3.0 - MEADOW_OS_VERSION: 1.3.0.0 + CLI_RELEASE_VERSION: 1.3.4.0 + IDE_TOOLS_RELEASE_VERSION: 1.3.4 + MEADOW_OS_VERSION: 1.3.4.0 VS_MAC_2019_VERSION: 8.10 VS_MAC_2022_VERSION: 17.5 diff --git a/Meadow.CLI.Core/Constants.cs b/Meadow.CLI.Core/Constants.cs index 05ebe39c..e73b68c9 100644 --- a/Meadow.CLI.Core/Constants.cs +++ b/Meadow.CLI.Core/Constants.cs @@ -7,7 +7,7 @@ namespace Meadow.CLI.Core { public static class Constants { - public const string CLI_VERSION = "1.3.0.0"; + public const string CLI_VERSION = "1.3.4.0"; public const ushort HCOM_PROTOCOL_PREVIOUS_VERSION_NUMBER = 0x0006; public const ushort HCOM_PROTOCOL_CURRENT_VERSION_NUMBER = 0x0007; // Used for transmission public const string WILDERNESS_LABS_USB_VID = "2E6A"; diff --git a/Meadow.CLI.Core/Internals/Dfu/DfuUtils.cs b/Meadow.CLI.Core/Internals/Dfu/DfuUtils.cs index f34b60f1..a044e052 100644 --- a/Meadow.CLI.Core/Internals/Dfu/DfuUtils.cs +++ b/Meadow.CLI.Core/Internals/Dfu/DfuUtils.cs @@ -221,10 +221,10 @@ public static async Task FlashFile(string fileName, IUsbDevice? device = n LastSerialNumber = GetDeviceSerial(device); - var dfuUtilVersion = GetDfuUtilVersion(); + var dfuUtilVersion = new System.Version(GetDfuUtilVersion()); logger.LogDebug("Detected OS: {os}", RuntimeInformation.OSDescription); - if (string.IsNullOrEmpty(dfuUtilVersion)) + if (dfuUtilVersion == null) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { @@ -236,24 +236,23 @@ public static async Task FlashFile(string fileName, IUsbDevice? device = n } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { - logger.LogError("dfu-util not found - install using package manager, for example: `apt install dfu-util`"); + logger.LogError("dfu-util not found - install using package manager, for example: `apt install dfu-util` or the equivalent for your Linux distribution"); } return false; } - else if (dfuUtilVersion != "0.10") + else if (dfuUtilVersion.CompareTo(new System.Version("0.11")) < 0) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - logger.LogError("dfu-util update required. To install, run in administrator mode: meadow install dfu-util"); + logger.LogError("dfu-util update required. To update, run in administrator mode: `meadow install dfu-util`"); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { - logger.LogError("dfu-util update required. To install, run: brew upgrade dfu-util"); + logger.LogError("dfu-util update required. To update, run: `brew upgrade dfu-util`"); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { - if (dfuUtilVersion != "0.9") - return false; + logger.LogError("dfu-util update required. To update , run: `apt upgrade dfu-util` or the equivalent for your Linux distribution"); } else { diff --git a/Meadow.CLI.Core/Managers/DownloadManager.cs b/Meadow.CLI.Core/Managers/DownloadManager.cs index cd461436..12b87399 100644 --- a/Meadow.CLI.Core/Managers/DownloadManager.cs +++ b/Meadow.CLI.Core/Managers/DownloadManager.cs @@ -206,7 +206,7 @@ public async Task InstallDfuUtil(bool is64Bit = true, Directory.CreateDirectory(WildernessLabsTemp); - const string downloadUrl = "https://s3-us-west-2.amazonaws.com/downloads.wildernesslabs.co/public/dfu-util-0.10-binaries.zip"; + const string downloadUrl = "https://s3-us-west-2.amazonaws.com/downloads.wildernesslabs.co/public/dfu-util-0.11-binaries.zip"; var downloadFileName = downloadUrl.Substring(downloadUrl.LastIndexOf("/", StringComparison.Ordinal) + 1); var response = await Client.GetAsync(downloadUrl, HttpCompletionOption.ResponseHeadersRead, cancellationToken); diff --git a/Meadow.CLI.Core/Meadow.CLI.Core.6.0.0.csproj b/Meadow.CLI.Core/Meadow.CLI.Core.6.0.0.csproj index 127418eb..4dda5118 100644 --- a/Meadow.CLI.Core/Meadow.CLI.Core.6.0.0.csproj +++ b/Meadow.CLI.Core/Meadow.CLI.Core.6.0.0.csproj @@ -11,7 +11,7 @@ preview enable True - 1.3.0.0 + 1.3.4.0 diff --git a/Meadow.CLI.Core/Meadow.CLI.Core.Classic.csproj b/Meadow.CLI.Core/Meadow.CLI.Core.Classic.csproj index ddef270a..0153ff5b 100644 --- a/Meadow.CLI.Core/Meadow.CLI.Core.Classic.csproj +++ b/Meadow.CLI.Core/Meadow.CLI.Core.Classic.csproj @@ -11,7 +11,7 @@ preview enable True - 1.3.0.0 + 1.3.4.0 diff --git a/Meadow.CLI.Core/Meadow.CLI.Core.VS2019.csproj b/Meadow.CLI.Core/Meadow.CLI.Core.VS2019.csproj index a69b2d56..713335ee 100644 --- a/Meadow.CLI.Core/Meadow.CLI.Core.VS2019.csproj +++ b/Meadow.CLI.Core/Meadow.CLI.Core.VS2019.csproj @@ -11,7 +11,7 @@ preview enable True - 1.3.0.0 + 1.3.4.0 diff --git a/Meadow.CLI.Core/Meadow.CLI.Core.csproj b/Meadow.CLI.Core/Meadow.CLI.Core.csproj index 31d043ff..c398f76c 100644 --- a/Meadow.CLI.Core/Meadow.CLI.Core.csproj +++ b/Meadow.CLI.Core/Meadow.CLI.Core.csproj @@ -11,7 +11,7 @@ preview enable True - 1.3.0.0 + 1.3.4.0 diff --git a/Meadow.CLI/Meadow.CLI.Classic.csproj b/Meadow.CLI/Meadow.CLI.Classic.csproj index eba00955..5249513f 100644 --- a/Meadow.CLI/Meadow.CLI.Classic.csproj +++ b/Meadow.CLI/Meadow.CLI.Classic.csproj @@ -10,7 +10,7 @@ Peter Moody, Adrian Stevens, Brian Kim, Pete Garafano, Dominique Louis Wilderness Labs, Inc true - 1.3.0.0 + 1.3.4.0 AnyCPU http://developer.wildernesslabs.co/Meadow/Meadow.Foundation/ icon.png diff --git a/Meadow.CLI/Meadow.CLI.csproj b/Meadow.CLI/Meadow.CLI.csproj index be3142d6..89a10bee 100644 --- a/Meadow.CLI/Meadow.CLI.csproj +++ b/Meadow.CLI/Meadow.CLI.csproj @@ -10,7 +10,7 @@ Peter Moody, Adrian Stevens, Brian Kim, Pete Garafano, Dominique Louis Wilderness Labs, Inc true - 1.3.0.0 + 1.3.4.0 AnyCPU http://developer.wildernesslabs.co/Meadow/Meadow.Foundation/ icon.png diff --git a/Meadow.CLI/Program.cs b/Meadow.CLI/Program.cs index 47c54e58..b0250e21 100644 --- a/Meadow.CLI/Program.cs +++ b/Meadow.CLI/Program.cs @@ -26,14 +26,9 @@ public static async Task Main(string[] args) .Build(); var logLevel = LogEventLevel.Information; - var logModifier = args.FirstOrDefault(a => a.Equals("-m")) - ?.Count(x => x == 'm') ?? 0; - logLevel -= logModifier; - if (logLevel < 0) - { - logLevel = 0; - } + if (args.Contains("--verbose")) + logLevel = LogEventLevel.Verbose; var outputTemplate = logLevel == LogEventLevel.Verbose ? "[{Timestamp:HH:mm:ss.fff} {Level:u3}] {Message:lj}{NewLine}{Exception}"