Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extra check after Deploy to enable runtime if it's not enabled. #89

Merged
merged 2 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading