Skip to content

Commit

Permalink
fix: Make sure to force rebuild if dev-server is being closed
Browse files Browse the repository at this point in the history
  • Loading branch information
dr1rrb committed Aug 6, 2024
1 parent c8ebb9d commit 03dd444
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions src/Uno.UI.RemoteControl.VS/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,10 @@ DTE2 dte2

_ = _debuggerObserver.ObserveProfilesAsync();

_ = _globalPropertiesChanged();

TelemetryHelper.DataModelTelemetrySession.AddSessionChannel(new TelemetryEventListener(this));
}

private async Task<Dictionary<string, string>> OnProvideGlobalPropertiesAsync()
private Task<Dictionary<string, string>> OnProvideGlobalPropertiesAsync()
{
Dictionary<string, string> properties = new()
{
Expand All @@ -129,9 +127,7 @@ private async Task<Dictionary<string, string>> OnProvideGlobalPropertiesAsync()
properties.Add(UnoRemoteControlConfigCookieProperty, _remoteControlConfigCookie);
}

await Task.Yield();

return properties;
return Task.FromResult(properties);
}

[MemberNotNull(
Expand Down Expand Up @@ -285,8 +281,8 @@ private async Task EnsureServerAsync()

if (_process is { HasExited: false })
{
_debugAction?.Invoke($"Server already running");
return; // Dev-server is already running.
_debugAction?.Invoke("Server already running");
return;
}

await _processGate.WaitAsync();
Expand Down Expand Up @@ -346,6 +342,8 @@ private async Task EnsureServerAsync()
_ideChannelClient.ForceHotReloadRequested += OnForceHotReloadRequestedAsync;
_ideChannelClient.ConnectToHost();

// Set the port to the projects
// This LEGACY as port should be set through the global properties (cf. OnProvideGlobalPropertiesAsync)
var portString = _remoteControlServerPort.ToString(CultureInfo.InvariantCulture);
foreach (var p in await _dte.GetProjectsAsync())
{
Expand Down Expand Up @@ -386,10 +384,30 @@ async Task Restart()
{
if (_closing || _ct.IsCancellationRequested)
{
if (_remoteControlConfigCookie is not null)
{
File.WriteAllText(_remoteControlConfigCookie, "--closed--"); // Make sure VS will re-build on next start
}

_debugAction?.Invoke($"Remote Control server exited ({_process?.ExitCode}) and won't be restarted as solution is closing.");
return;
}

_debugAction?.Invoke($"Remote Control server exited ({_process?.ExitCode}). It will restart in 5sec.");

await Task.Delay(5000, _ct.Token);

if (_closing || _ct.IsCancellationRequested)
{
if (_remoteControlConfigCookie is not null)
{
File.WriteAllText(_remoteControlConfigCookie, "--closed--"); // Make sure VS will re-build on next start
}

_debugAction?.Invoke($"Remote Control server will not be restarted as solution is closing.");
return;
}

await EnsureServerAsync();
}
}
Expand Down

0 comments on commit 03dd444

Please sign in to comment.