Skip to content

Commit

Permalink
Merge pull request #89 from WildernessLabs/dominique-Fix585
Browse files Browse the repository at this point in the history
Add extra check after Deploy to enable runtime if it's not enabled.
  • Loading branch information
CartBlanche authored Apr 11, 2024
2 parents abd6263 + 4508154 commit 72ee55a
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: VS4Mac Extension
env:
IDE_TOOLS_RELEASE_VERSION: 1.9.4
IDE_TOOLS_RELEASE_VERSION: 1.9.6
MEADOW_OS_VERSION: 2.0.0.0
VS_MAC_2022_VERSION: 17.6

Expand Down
64 changes: 38 additions & 26 deletions VS4Mac_Meadow_Extension/MeadowExecutionCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
using Meadow.CLI.Core.DeviceManagement;
using Meadow.CLI.Core.Devices;
using Meadow.CLI.Core.Internals.MeadowCommunication.ReceiveClasses;
using Microsoft.Extensions.Logging;

namespace Meadow.Sdks.IdeExtensions.Vs4Mac
{
public class MeadowExecutionCommand : ProcessExecutionCommand
{
public MeadowExecutionCommand() : base()
public MeadowExecutionCommand() : base()
{
logger = new OutputLogger();
}
Expand All @@ -28,46 +29,57 @@ public MeadowExecutionCommand() : base()

public FilePath OutputDirectory { get; set; }

OutputLogger logger;
ILogger logger;
MeadowDeviceHelper meadow = null;
DebuggingServer meadowDebugServer = null;

public async Task DeployApp(int debugPort, CancellationToken cancellationToken)
{
DeploymentTargetsManager.StopPollingForDevices();

cleanedup = false;
meadow?.Dispose();

var target = this.Target as MeadowDeviceExecutionTarget;
var device = await MeadowDeviceManager.GetMeadowForSerialPort(target.Port, logger: logger)
.ConfigureAwait(false);
var configuration = IdeApp.Workspace.ActiveConfiguration;

meadow = new MeadowDeviceHelper(device, device.Logger);
bool isDebugging = configuration is SolutionConfigurationSelector isScs
&& isScs?.Id == "Debug"
&& debugPort > 1000;

//wrap this is a try/catch so it doesn't crash if the developer is offline
try
{
string osVersion = await meadow.GetOSVersion(TimeSpan.FromSeconds(30), cancellationToken);
DeploymentTargetsManager.StopPollingForDevices();

await new DownloadManager(logger).DownloadOsBinaries(osVersion);
}
catch
{
Console.WriteLine("OS download failed, make sure you have an active internet connection");
}
cleanedup = false;
meadow?.Dispose();

var fileNameExe = System.IO.Path.Combine(OutputDirectory, "App.dll");
var target = this.Target as MeadowDeviceExecutionTarget;
var device = await MeadowDeviceManager.GetMeadowForSerialPort(target.Port, logger: logger)
.ConfigureAwait(false);

var configuration = IdeApp.Workspace.ActiveConfiguration;
meadow = new MeadowDeviceHelper(device, device.Logger);

bool includePdbs = configuration is SolutionConfigurationSelector isScs
&& isScs?.Id == "Debug"
&& debugPort > 1000;
//wrap this is a try/catch so it doesn't crash if the developer is offline
try
{
string osVersion = await meadow.GetOSVersion(TimeSpan.FromSeconds(30), cancellationToken);

await new DownloadManager(logger).DownloadOsBinaries(osVersion);
}
catch (Exception e)
{
logger.LogError($"OS download failed, make sure you have an active internet connection.{Environment.NewLine}Error:{e.Message}");
}

await meadow.DeployApp(fileNameExe, includePdbs, cancellationToken);
var fileNameExe = System.IO.Path.Combine(OutputDirectory, "App.dll");

await meadow.DeployApp(fileNameExe, isDebugging, cancellationToken);
}
finally
{
var running = await meadow.GetMonoRunState(cancellationToken);
if (!running)
{
await meadow?.MonoEnable(true, cancellationToken);
}
}

if (includePdbs)
if (isDebugging)
{
meadowDebugServer = await meadow.StartDebuggingSession(debugPort, cancellationToken);
}
Expand Down
2 changes: 1 addition & 1 deletion VS4Mac_Meadow_Extension/Properties/AddinInfo.2022.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[assembly: Addin(
"Meadow.2022",
Namespace = "WildernessLabs.Sdks",
Version = "1.9.4"
Version = "1.9.6"
)]

[assembly: AddinName("Meadow for VS2022")]
Expand Down
2 changes: 1 addition & 1 deletion VS4Mac_Meadow_Extension/Properties/AddinInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[assembly: Addin(
"Meadow",
Namespace = "WildernessLabs.Sdks",
Version = "1.9.4"
Version = "1.9.6"
)]

[assembly: AddinName("Meadow")]
Expand Down

0 comments on commit 72ee55a

Please sign in to comment.