Skip to content

Commit

Permalink
Merge pull request #104 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 0038403 + a9fc2fc commit 5508a66
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: VSCode Extension
env:
IDE_TOOLS_RELEASE_VERSION: 1.9.4
IDE_TOOLS_RELEASE_VERSION: 1.9.6

on:
push:
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ This is the extension for VSCode that enables Meadow apps to be build, debugged

## Release Notes

### 1.9.6

- Add extra check to re-enable the runtime, if it isn't enabled after deployment.

### 1.9.4

- Fix for VSCode on Windows so that debugging works again.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "meadow",
"displayName": "VSCode Tools For Meadow",
"version": "1.9.4",
"version": "1.9.6",
"publisher": "WildernessLabs",
"description": "Build, Debug and Deploy Meadow applications",
"icon": "meadow.png",
Expand Down
54 changes: 36 additions & 18 deletions src/csharp/Meadow/MeadowDeployer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,38 @@ public async void Dispose()
try
{
if (meadow != null)
{
await meadow.MonoDisable(true, CancelToken);
} catch { }

try { meadow?.Dispose(); }
finally { meadow = null; }
meadow.Dispose();
}
}
catch
{

}
finally
{
meadow = null;
}
}
public async Task<DebuggingServer> Deploy(string folder, int debugPort = -1)
{
if (meadow == null)
var isDebugging = debugPort > 1000;

try
{
var m = await MeadowDeviceManager.GetMeadowForSerialPort(Serial, logger: Logger);
if (m == null)
throw new InvalidOperationException("Meadow device not found");
if (meadow == null)
{
var m = await MeadowDeviceManager.GetMeadowForSerialPort(Serial, logger: Logger);
if (m == null)
throw new InvalidOperationException("Meadow device not found");

meadow = new MeadowDeviceHelper(m, Logger);
}
meadow = new MeadowDeviceHelper(m, Logger);
}

var appPathDll = Path.Combine(folder, "App.dll");
var appPathDll = Path.Combine(folder, "App.dll");

// TODO not working reliably enough for RC1, will investigate further // if (meadow.DeviceAndAppVersionsMatch(appPathDll))
{
//wrap this is a try/catch so it doesn't crash if the developer is offline
try
{
Expand All @@ -65,15 +76,22 @@ public async Task<DebuggingServer> Deploy(string folder, int debugPort = -1)
Logger.LogInformation($"OS download failed, make sure you have an active internet connection.{Environment.NewLine}{e.Message}");
}

var isDebugging = debugPort > 1000;
await meadow.DeployApp(appPathDll, isDebugging, CancelToken);

// Debugger only returns when session is done
if (isDebugging)
return await meadow.StartDebuggingSession(debugPort, CancelToken);
}
finally
{
var running = await meadow.GetMonoRunState(CancelToken);
if (!running)
{
await meadow?.MonoEnable(true, CancelToken);
}
}

// Debugger only returns when session is done
if (isDebugging)
return await meadow.StartDebuggingSession(debugPort, CancelToken);

return null;
}
}
}
}

0 comments on commit 5508a66

Please sign in to comment.