From fe794a78cf66daef3d6e5cc11328d04cfea34e7d Mon Sep 17 00:00:00 2001 From: Dominique Louis Date: Fri, 22 Sep 2023 22:57:30 +0100 Subject: [PATCH] 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)