diff --git a/Source/v2/Meadow.Cli/Commands/Current/App/AppDeployCommand.cs b/Source/v2/Meadow.Cli/Commands/Current/App/AppDeployCommand.cs index e10f0d9c..fe3f06a2 100644 --- a/Source/v2/Meadow.Cli/Commands/Current/App/AppDeployCommand.cs +++ b/Source/v2/Meadow.Cli/Commands/Current/App/AppDeployCommand.cs @@ -87,7 +87,7 @@ private FileInfo GetMeadowAppFile(string path) return file; } - private async Task DeployApplication(IMeadowConnection connection, string osVersion, string path, CancellationToken GetAvailableBuiltConfigurations) + private async Task DeployApplication(IMeadowConnection connection, string osVersion, string path, CancellationToken cancellationToken) { connection.FileWriteProgress += OnFileWriteProgress; @@ -103,7 +103,7 @@ private async Task DeployApplication(IMeadowConnection connection, string Logger?.LogInformation($"Deploying app from {file.DirectoryName}..."); - await AppManager.DeployApplication(_packageManager, connection, osVersion, file.DirectoryName!, true, false, Logger, GetAvailableBuiltConfigurations); + await AppManager.DeployApplication(_packageManager, connection, osVersion, file.DirectoryName!, true, false, Logger, cancellationToken); connection.FileWriteProgress -= OnFileWriteProgress; diff --git a/Source/v2/Meadow.Cli/Commands/Current/App/AppRunCommand.cs b/Source/v2/Meadow.Cli/Commands/Current/App/AppRunCommand.cs index 72f4e9ca..d168e423 100644 --- a/Source/v2/Meadow.Cli/Commands/Current/App/AppRunCommand.cs +++ b/Source/v2/Meadow.Cli/Commands/Current/App/AppRunCommand.cs @@ -75,7 +75,7 @@ protected override async ValueTask ExecuteCommand() throw new CommandException(Strings.AppTrimFailed, CommandExitCode.GeneralError); } - if (!await DeployApplication(connection, path, CancellationToken)) + if (!await DeployApplication(connection, path, Configuration, CancellationToken)) { throw new CommandException(Strings.AppDeployFailed, CommandExitCode.GeneralError); } @@ -94,7 +94,7 @@ protected override async ValueTask ExecuteCommand() Logger?.LogInformation("Listen cancelled..."); } - private async Task DeployApplication(IMeadowConnection connection, string path, CancellationToken cancellationToken) + private async Task DeployApplication(IMeadowConnection connection, string path, string configuration, CancellationToken cancellationToken) { connection.FileWriteProgress += OnFileWriteProgress; @@ -113,7 +113,14 @@ private async Task DeployApplication(IMeadowConnection connection, string return false; } - var file = candidates.OrderByDescending(c => c.LastWriteTime).First(); + //get the file that matches the configuration + var file = candidates.FirstOrDefault(c => c.DirectoryName.Contains(configuration, StringComparison.OrdinalIgnoreCase)); + + if (file == null) + { + Logger?.LogError($"Cannot find a compiled application for configuration '{configuration}'"); + return false; + } Logger?.LogInformation($"Deploying app from {file.DirectoryName}...");