Skip to content

Commit

Permalink
fix: Adjust startup project on forced reload
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Apr 10, 2024
1 parent cb9bc66 commit d86fbdc
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/Uno.UI.RemoteControl.VS/EntryPoint.ActiveProfileSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ previousTargetFrameworkIdentifier is WasmTargetFrameworkIdentifier or DesktopTar
&& await _dte.GetStartupProjectsAsync() is { Length: > 0 } startupProjects
)
{
var startupProjectUniqueName = startupProjects[0].UniqueName;

var sw = Stopwatch.StartNew();

// Wait for VS to write down the active target, so that on reload the selected target
Expand Down Expand Up @@ -217,6 +219,33 @@ previousTargetFrameworkIdentifier is WasmTargetFrameworkIdentifier or DesktopTar

// Reload project
solution4.ReloadProject(ref projectGuid);

var sw2 = Stopwatch.StartNew();

while (sw2.Elapsed < TimeSpan.FromSeconds(5))
{
// Reset the startup project, as it VS will move it to the next available
// project in the solution on unload.
if (_dte.Solution.SolutionBuild is SolutionBuild2 val)
{
_debugAction?.Invoke($"Setting startup project to {startupProjectUniqueName}");
val.StartupProjects = startupProjectUniqueName;
}

await Task.Delay(50);

if (await _dte.GetStartupProjectsAsync() is { Length: > 0 } newStartupProjects
&& newStartupProjects[0].UniqueName == startupProjectUniqueName)
{
_debugAction?.Invoke($"Startup project changed successfully");
break;
}
else
{
_debugAction?.Invoke($"Startup project was not changed, retrying...");
await Task.Delay(1000);
}
}
}
}
}
Expand Down

0 comments on commit d86fbdc

Please sign in to comment.