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

Dominique v2 mods #193

Open
wants to merge 10 commits into
base: adrian-CLIv2-updates
Choose a base branch
from
2 changes: 1 addition & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
with:
repository: WildernessLabs/Meadow.CLI
path: Meadow.CLI
ref: dominique-V2022ToV2
ref: dominique-TestDebugging

- name: Checkout Meadow.Contracts side-by-side
uses: actions/checkout@v4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.0.0.4")]
[assembly: AssemblyFileVersion("2.0.0.4")]
[assembly: AssemblyVersion("2.0.0.14")]
[assembly: AssemblyFileVersion("2.0.0.14")]
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="System.IO.Ports">
<Version>8.0.0</Version>
<Version>8.*</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="VS_Meadow_Extension.2022.d5eb772d-2173-4795-b60b-67929a9bf12d" Version="2.0.0.9" Language="en-US" Publisher="Wilderness Labs" />
<Identity Id="VS_Meadow_Extension.2022.d5eb772d-2173-4795-b60b-67929a9bf12d" Version="2.0.0.14" Language="en-US" Publisher="Wilderness Labs" />
<DisplayName>VS 2022 Tools for Meadow</DisplayName>
<Description xml:space="preserve">Tools for developing Meadow applications</Description>
<Icon>wildernesslabs_icon.png</Icon>
Expand Down
2 changes: 1 addition & 1 deletion VS_Meadow_Extension/VS_Meadow_Extension.Shared/Globals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Meadow
{
public static class Globals
{
public const string AssemblyVersion = "2.0.0.9";
public const string AssemblyVersion = "2.0.0.14";

public const string MeadowCapability = "Meadow";

Expand Down
51 changes: 0 additions & 51 deletions VS_Meadow_Extension/VS_Meadow_Extension.Shared/MeadowConnection.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Microsoft.VisualStudio.ProjectSystem;
using Meadow.CLI;
using Meadow.CLI.Commands.DeviceManagement;
using Microsoft.VisualStudio.ProjectSystem;
using Microsoft.VisualStudio.ProjectSystem.Debug;
using Microsoft.VisualStudio.ProjectSystem.VS.Debug;
using Microsoft.VisualStudio.Shell;
Expand Down Expand Up @@ -52,7 +54,8 @@ public MeadowDebuggerLaunchProvider(ConfiguredProject configuredProject)

public async Task<IReadOnlyList<IDebugLaunchSettings>> QueryDebugTargetsAsync(DebugLaunchOptions launchOptions, ILaunchProfile profile)
{
var connection = MeadowConnection.GetCurrentConnection();
var route = new SettingsManager().GetSetting(SettingsManager.PublicSettings.Route);
var connection = await MeadowConnectionManager.GetConnectionForRoute(route);

if (!launchOptions.HasFlag(DebugLaunchOptions.NoDebug)
&& await IsProjectAMeadowApp()
Expand Down
111 changes: 59 additions & 52 deletions VS_Meadow_Extension/VS_Meadow_Extension.Shared/MeadowDeployProvider.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using Meadow.CLI;
using Meadow.CLI.Commands.DeviceManagement;
using Meadow.Package;
using Meadow.Software;
using Microsoft.VisualStudio.ProjectSystem;
using Microsoft.VisualStudio.ProjectSystem.Build;
using Microsoft.VisualStudio.Shell;
using System;
using System.ComponentModel.Composition;
using System.IO;
Expand Down Expand Up @@ -48,82 +50,87 @@ public MeadowDeployProvider(ConfiguredProject configuredProject)

public async Task DeployAsync(CancellationToken cancellationToken, TextWriter textWriter)
{
if (await IsProjectAMeadowApp() == false)
if (cancellationToken.IsCancellationRequested || !await IsProjectAMeadowApp())
{
return;
}

Globals.DebugOrDeployInProgress = true;
await Task.Run(async () =>
{
Globals.DebugOrDeployInProgress = true;

await outputLogger?.ConnectTextWriter(textWriter);
await outputLogger.ShowBuildOutputPane();
await outputLogger?.ConnectTextWriter(textWriter);
await outputLogger.ShowBuildOutputPane();

outputLogger.Log("Preparing to deploy Meadow application...");
outputLogger.Log("Preparing to deploy Meadow application...");

var filename = configuredProject.UnconfiguredProject.FullPath;
var filename = configuredProject.UnconfiguredProject.FullPath;

var projFileContent = File.ReadAllText(filename);
var projFileContent = File.ReadAllText(filename);

if (projFileContent.Contains(MeadowSDKVersion) == false)
{
Globals.DebugOrDeployInProgress = false;
outputLogger?.Log("Deploy failed - not a Meadow project");
return;
}

var outputPath = await GetOutputPathAsync(filename);
if (projFileContent.Contains(MeadowSDKVersion) == false)
{
Globals.DebugOrDeployInProgress = false;
outputLogger?.Log("Deploy failed - not a Meadow project");
return;
}

if (string.IsNullOrEmpty(outputPath))
{
Globals.DebugOrDeployInProgress = false;
outputLogger?.Log("Deploy failed - could not locate Meadow app");
return;
}
var outputPath = await GetOutputPathAsync(filename);

if (connection != null)
{
connection.FileWriteProgress -= MeadowConnection_DeploymentProgress;
connection.DeviceMessageReceived -= MeadowConnection_DeviceMessageReceived;
}
if (string.IsNullOrEmpty(outputPath))
{
Globals.DebugOrDeployInProgress = false;
outputLogger?.Log("Deploy failed - could not locate Meadow app");
return;
}

connection = MeadowConnection.GetCurrentConnection();
if (connection != null)
{
connection.FileWriteProgress -= MeadowConnection_DeploymentProgress;
connection.DeviceMessageReceived -= MeadowConnection_DeviceMessageReceived;
}

connection.FileWriteProgress += MeadowConnection_DeploymentProgress;
connection.DeviceMessageReceived += MeadowConnection_DeviceMessageReceived;
var route = new SettingsManager().GetSetting(SettingsManager.PublicSettings.Route);
connection = await MeadowConnectionManager.GetConnectionForRoute(route);

try
{
await connection.WaitForMeadowAttach();
connection.FileWriteProgress += MeadowConnection_DeploymentProgress;
connection.DeviceMessageReceived += MeadowConnection_DeviceMessageReceived;

if (await connection.IsRuntimeEnabled() == true)
try
{
await connection.RuntimeDisable();
}
await connection.WaitForMeadowAttach();

var deviceInfo = await connection.GetDeviceInfo();
if (await connection.IsRuntimeEnabled() == true)
{
await connection.RuntimeDisable();
}

string osVersion = deviceInfo.OsVersion;
var deviceInfo = await connection.GetDeviceInfo();

var fileManager = new FileManager(null);
await fileManager.Refresh();
string osVersion = deviceInfo.OsVersion;

bool includePdbs = configuredProject?.ProjectConfiguration?.Dimensions["Configuration"].Contains("Debug") ?? false;
var fileManager = new FileManager(null);
await fileManager.Refresh();

var packageManager = new PackageManager(fileManager);
bool includePdbs = configuredProject?.ProjectConfiguration?.Dimensions["Configuration"].Contains("Debug") ?? false;

outputLogger.Log("Trimming application binaries...");
var packageManager = new PackageManager(fileManager);

await packageManager.TrimApplication(new FileInfo(Path.Combine(outputPath, "App.dll")), osVersion, includePdbs, cancellationToken: cancellationToken);
outputLogger.Log("Trimming application binaries...");
await packageManager.TrimApplication(new FileInfo(Path.Combine(outputPath, "App.dll")), osVersion, includePdbs, cancellationToken: cancellationToken);

await Task.Run(async () => await AppManager.DeployApplication(packageManager, connection, osVersion, outputPath, includePdbs, false, outputLogger, cancellationToken));
CartBlanche marked this conversation as resolved.
Show resolved Hide resolved
outputLogger.Log("Deploying application...");
await AppManager.DeployApplication(packageManager, connection, osVersion, outputPath, includePdbs, false, outputLogger, cancellationToken);

await connection.RuntimeEnable();
await connection.RuntimeEnable();

await outputLogger.ShowBuildOutputPane();
}
finally
{
}
await outputLogger.ShowBuildOutputPane();
}
finally
{
connection.FileWriteProgress -= MeadowConnection_DeploymentProgress;
}
});
}

private async Task<string> GetOutputPathAsync(string filename)
Expand All @@ -143,9 +150,9 @@ private async Task<string> GetOutputPathAsync(string filename)
return outputPath;
}

private static void MeadowConnection_DeviceMessageReceived(object sender, (string message, string source) e)
private static async void MeadowConnection_DeviceMessageReceived(object sender, (string message, string source) e)
{
_ = outputLogger.ReportDeviceMessage(e.message);
await outputLogger.ReportDeviceMessage(e.message);
}

private static async void MeadowConnection_DeploymentProgress(object sender, (string fileName, long completed, long total) e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,23 @@ internal async Task ResetProgressBar()
internal async Task ReportFileProgress(string fileName, uint percentage)
{
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

statusBar?.Progress(ref progressBarCookie, 1, $"Transferring: {fileName}", percentage, TOTAL_PROGRESS);
}

internal async Task ReportDownloadProgress(string osVersion, long byteReceived)
{
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

statusBar?.SetText($"Downloading OsVersion: {osVersion}; Bytes Received {byteReceived}");
}

internal async Task ReportDeviceMessage(string message)
{
try
{
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

//check and see if the message ends with a newline, if not add one
if (!message.EndsWith("\n"))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)Extensions.cs">
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)MeadowConnection.cs">
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)MeadowSoftDebuggerSession.cs">
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)MeadowDebugLaunchSettings.cs">
Expand Down