Skip to content

Commit 3d7a637

Browse files
committed
ci: Fix build
1 parent f5408ee commit 3d7a637

File tree

5 files changed

+87
-27
lines changed

5 files changed

+87
-27
lines changed

src/Uno.UI.RemoteControl.DevServer.Tests/AppLaunch/RealAppLaunchIntegrationTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public async Task WhenRealAppBuiltAndRunWithDevServer_RealConnectionEstablished(
1818
{
1919
// PRE-ARRANGE: Create a real Uno solution file (will contain desktop project)
2020
var solution = SolutionHelper!;
21-
await solution.CreateSolutionFileAsync();
21+
await solution.CreateSolutionFileAsync(copyGlobalJson: false, platforms: "desktop");
2222

2323
var filePath = Path.Combine(Path.GetTempPath(), GetTestTelemetryFileName("applaunch_app_success"));
2424
await using var helper = CreateTelemetryHelperWithExactPath(filePath, solutionPath: solution.SolutionFile, enableIdeChannel: false);
@@ -122,10 +122,11 @@ private async Task<string> BuildAppProjectAsync(SolutionHelper solution, int dev
122122

123123
// Build the project with devserver configuration so the generators create the right ServerEndpointAttribute
124124
// Using MSBuild properties directly to override any .csproj.user or Directory.Build.props values
125+
// Explicitly targeting net9.0-desktop to avoid any multi-targeting issues with .NET 10 SDK
125126
var buildInfo = new ProcessStartInfo
126127
{
127128
FileName = "dotnet",
128-
Arguments = $"build \"{appProject}\" --configuration Debug --verbosity minimal -p:UnoRemoteControlHost=localhost -p:UnoRemoteControlPort={devServerPort}",
129+
Arguments = $"build \"{appProject}\" --configuration Debug --verbosity minimal --framework net9.0-desktop -p:UnoRemoteControlHost=localhost -p:UnoRemoteControlPort={devServerPort}",
129130
RedirectStandardOutput = true,
130131
RedirectStandardError = true,
131132
UseShellExecute = false,

src/Uno.UI.RemoteControl.DevServer.Tests/Helpers/SolutionHelper.cs

Lines changed: 71 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@ namespace Uno.UI.RemoteControl.DevServer.Tests.Helpers;
88

99
public class SolutionHelper : IDisposable
1010
{
11+
private readonly TestContext _testContext;
1112
private readonly string _solutionFileName;
1213
private readonly string _tempFolder;
1314

1415
public string TempFolder => _tempFolder;
1516
public string SolutionFile => Path.Combine(_tempFolder, _solutionFileName + ".sln");
1617

17-
private bool isDisposed;
18+
private bool _isDisposed;
1819

19-
public SolutionHelper(string solutionFileName = "MyApp")
20+
public SolutionHelper(TestContext testContext, string solutionFileName = "MyApp")
2021
{
22+
_testContext = testContext;
2123
_solutionFileName = solutionFileName;
2224
_tempFolder = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
2325

@@ -27,17 +29,24 @@ public SolutionHelper(string solutionFileName = "MyApp")
2729
}
2830
}
2931

30-
public async Task CreateSolutionFileAsync()
32+
public async Task CreateSolutionFileAsync(
33+
bool copyGlobalJson = false,
34+
string platforms = "wasm,desktop")
3135
{
32-
if (isDisposed)
36+
if (_isDisposed)
3337
{
3438
throw new ObjectDisposedException(nameof(SolutionHelper));
3539
}
3640

41+
await ShowDotnetVersionAsync();
42+
43+
var platformArgs = string.Join(" ", platforms.Split(',').Select(p => $"-platforms \"{p.Trim()}\""));
44+
var arguments = $"new unoapp -n {_solutionFileName} -o {_tempFolder} -preset \"recommended\" {platformArgs}";
45+
3746
var startInfo = new ProcessStartInfo
3847
{
3948
FileName = "dotnet",
40-
Arguments = $"new unoapp -n {_solutionFileName} -o {_tempFolder} -preset \"recommended\" -platforms \"wasm\" -platforms \"desktop\"",
49+
Arguments = arguments,
4150
RedirectStandardOutput = true,
4251
RedirectStandardError = true,
4352
UseShellExecute = false,
@@ -48,7 +57,45 @@ public async Task CreateSolutionFileAsync()
4857
var (exitCode, output) = await ProcessUtil.RunProcessAsync(startInfo);
4958
if (exitCode != 0)
5059
{
51-
throw new InvalidOperationException($"dotnet new unoapp failed with exit code {exitCode} / {output}");
60+
throw new InvalidOperationException($"dotnet new unoapp failed with exit code {exitCode} / {output}.\n>dotnet {arguments}");
61+
}
62+
63+
// Optionally copy the global.json from the Uno repo to the temp folder to ensure we use the correct SDK version
64+
// This is critical for CI environments where .NET 10 prerelease might be installed
65+
if (copyGlobalJson)
66+
{
67+
CopyGlobalJsonToTempFolder();
68+
}
69+
}
70+
71+
private void CopyGlobalJsonToTempFolder()
72+
{
73+
// Find the global.json in the Uno repo (walking up from the current assembly location)
74+
var assemblyLocation = Path.GetDirectoryName(typeof(SolutionHelper).Assembly.Location)!;
75+
var currentDir = assemblyLocation;
76+
string? globalJsonPath = null;
77+
78+
// Walk up the directory tree to find global.json
79+
while (currentDir != null)
80+
{
81+
var candidatePath = Path.Combine(currentDir, "global.json");
82+
if (File.Exists(candidatePath))
83+
{
84+
globalJsonPath = candidatePath;
85+
break;
86+
}
87+
currentDir = Path.GetDirectoryName(currentDir);
88+
}
89+
90+
if (globalJsonPath != null)
91+
{
92+
var targetPath = Path.Combine(_tempFolder, "global.json");
93+
File.Copy(globalJsonPath, targetPath, overwrite: true);
94+
Console.WriteLine($"[DEBUG_LOG] Copied global.json from {globalJsonPath} to {targetPath}");
95+
}
96+
else
97+
{
98+
Console.WriteLine("[DEBUG_LOG] Warning: Could not find global.json in parent directories");
5299
}
53100
}
54101

@@ -129,9 +176,26 @@ public void EnsureUnoTemplatesInstalled()
129176
}
130177
}
131178

179+
private async Task ShowDotnetVersionAsync()
180+
{
181+
var startInfo = new ProcessStartInfo
182+
{
183+
FileName = "dotnet",
184+
Arguments = "--info",
185+
RedirectStandardOutput = true,
186+
RedirectStandardError = true,
187+
UseShellExecute = false,
188+
CreateNoWindow = true,
189+
WorkingDirectory = _tempFolder,
190+
};
191+
192+
var (exitCode, output) = await ProcessUtil.RunProcessAsync(startInfo);
193+
_testContext.WriteLine($"dotnet --info output:\n{output}");
194+
}
195+
132196
public void Dispose()
133197
{
134-
isDisposed = true;
198+
_isDisposed = true;
135199

136200
// Force delete temp folder
137201
Directory.Delete(_tempFolder, true);

src/Uno.UI.RemoteControl.DevServer.Tests/Telemetry/TelemetryTestBase.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ private CancellationToken GetTimeoutToken()
3838
[TestInitialize]
3939
public void TestInitialize()
4040
{
41-
SolutionHelper = new SolutionHelper();
41+
SolutionHelper = new SolutionHelper(TestContext!);
4242
SolutionHelper.EnsureUnoTemplatesInstalled();
4343
}
4444

@@ -65,16 +65,6 @@ protected static void GlobalClassInitialize<T>(TestContext context) where T : cl
6565
InitializeLogger<T>();
6666
}
6767

68-
private static void InitializeLogger(Type type)
69-
{
70-
var loggerFactory = LoggerFactory.Create(builder =>
71-
{
72-
builder.AddConsole();
73-
builder.AddDebug();
74-
});
75-
Logger = loggerFactory.CreateLogger(type);
76-
}
77-
7868
/// <summary>
7969
/// Creates a DevServerTestHelper with telemetry redirection to a temporary file.
8070
/// </summary>

src/Uno.UI.RemoteControl.Messaging/IDEChannel/AppLaunchRegisterIdeMessage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ namespace Uno.UI.RemoteControl.Messaging.IdeChannel;
33

44
/// <summary>
55
/// Message sent by the IDE to indicate that a target application has just been launched.
6-
/// The dev-server will correlate this registration with a later runtime connection (AppIdentityMessage) using the MVID.
6+
/// The dev-server will correlate this registration with a later runtime connection (`AppLaunchMessage` with `Step = Connected`) using the MVID, Platform and IsDebug.
77
/// </summary>
88
/// <param name="Mvid">The MVID (Module Version ID) of the head application assembly.</param>
99
/// <param name="Platform">The target platform (case-sensitive, e.g. "Wasm", "Android").</param>

src/Uno.UI.RemoteControl.Server/AppLaunch/ApplicationLaunchMonitor.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
- You tell it that an app was launched, then you report when a matching app connects. It matches them 1:1 in launch order and handles timeouts.
66
- When a launched application fails to connect, it is reported as a timeout thru the OnTimeout callback.
77
- It is thread-safe / Disposable.
8-
- It used the MVID as the key. This is the _Module Version ID_ of the app (head) assembly, which is unique per build. More info: https://learn.microsoft.com/en-us/dotnet/api/system.reflection.module.moduleversionid
8+
- It uses a composite key: MVID + Platform + IsDebug. The MVID is the _Module Version ID_ of the app (head) assembly, which is unique per build. More info: https://learn.microsoft.com/en-us/dotnet/api/system.reflection.module.moduleversionid
99

1010
## How to use
1111
### 1) Create the monitor (optionally with callbacks and a custom timeout):
@@ -54,13 +54,18 @@ When integrated in the dev-server, the monitor emits telemetry events (prefix `u
5454

5555
`latencyMs` is the elapsed time between registration and connection, measured internally. `timeoutSeconds` equals the configured timeout.
5656

57-
## IDE / Runtime Messages
58-
To enable correlation end-to-end, two messages flow through the system:
57+
## Integration points (IDE, WebSocket, HTTP)
58+
The dev-server can receive registration and connection events through multiple channels:
5959

60-
1. IDE → DevServer: `AppLaunchRegisterIdeMessage` (scope: `AppLaunch`) carrying MVID, Platform, IsDebug. Triggers `RegisterLaunch`.
61-
2. Runtime → DevServer: `AppIdentityMessage` (scope: `RemoteControlServer`) carrying MVID, Platform, IsDebug, automatically sent after WebSocket connection. Triggers `ReportConnection`.
60+
- IDE → DevServer: `AppLaunchRegisterIdeMessage` (scope: `AppLaunch`) carrying MVID, Platform, IsDebug. Triggers `RegisterLaunch`.
61+
- Runtime → DevServer over WebSocket (scope: `DevServerChannel`): `AppLaunchMessage` with `Step = Launched`. Triggers `RegisterLaunch`.
62+
- HTTP GET → DevServer: `GET /applaunch/{mvid}?platform={platform}&isDebug={true|false}`. Triggers `RegisterLaunch`.
6263

63-
If no matching `AppIdentityMessage` arrives before timeout, a timeout event is emitted.
64+
Connections are reported by the runtime after establishing the WebSocket connection:
65+
66+
- Runtime → DevServer over WebSocket (scope: `DevServerChannel`): `AppLaunchMessage` with `Step = Connected`. Triggers `ReportConnection`.
67+
68+
If no matching `Connected` message arrives before timeout, a timeout event is emitted.
6469

6570
### Testing / Time control
6671

0 commit comments

Comments
 (0)