Skip to content

Commit 4d738c8

Browse files
Katya Sokolovapremun
andauthored
Throw error when calling ios commands on Windows or Linux (#412)
* Throw error when calling ios commands on Windows or Linux * Update src/Microsoft.DotNet.XHarness.CLI/Commands/XHarnessHelpCommand.cs Co-authored-by: Přemek Vysoký <premek.vysoky@microsoft.com> Co-authored-by: Přemek Vysoký <premek.vysoky@microsoft.com>
1 parent c7b9297 commit 4d738c8

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

src/Microsoft.DotNet.XHarness.CLI/Commands/XHarnessHelpCommand.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System;
66
using System.Collections.Generic;
77
using System.Linq;
8+
using System.Runtime.InteropServices;
89
using Microsoft.DotNet.XHarness.CLI.Android;
910
using Microsoft.DotNet.XHarness.CLI.Commands.iOS;
1011
using Microsoft.DotNet.XHarness.CLI.Commands.Wasm;
@@ -39,7 +40,15 @@ public override int Invoke(IEnumerable<string> arguments)
3940
PrintCommandHelp(new AndroidCommandSet(), subCommand);
4041
break;
4142
case "ios":
42-
PrintCommandHelp(new iOSCommandSet(), subCommand);
43+
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
44+
{
45+
PrintCommandHelp(new iOSCommandSet(), subCommand);
46+
}
47+
else
48+
{
49+
Console.WriteLine($"Command '{command}' could be run on OSX only.");
50+
}
51+
4352
break;
4453
case "wasm":
4554
PrintCommandHelp(new WasmCommandSet(), subCommand);

src/Microsoft.DotNet.XHarness.CLI/Program.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
using System;
66
using System.Linq;
7+
using System.Runtime.InteropServices;
78
using Microsoft.DotNet.XHarness.CLI.Android;
89
using Microsoft.DotNet.XHarness.CLI.Commands;
910
using Microsoft.DotNet.XHarness.CLI.Commands.iOS;
@@ -23,7 +24,6 @@ public static int Main(string[] args)
2324
var commands = new CommandSet("xharness")
2425
{
2526
// Add per-platform CommandSets - If adding a new supported set, that goes here.
26-
new iOSCommandSet(),
2727
new AndroidCommandSet(),
2828
new WasmCommandSet(),
2929

@@ -32,6 +32,12 @@ public static int Main(string[] args)
3232
new XHarnessVersionCommand(),
3333
};
3434

35+
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
36+
{
37+
commands.Add(new iOSCommandSet());
38+
}
39+
40+
3541
// Mono.Options wouldn't allow "--" and CommandSet parser will temporarily rename it
3642
int result = commands.Run(args.Select(a => a == "--" ? XHarnessCommand.VerbatimArgumentPlaceholder : a));
3743
Console.WriteLine($"XHarness exit code: {result}");
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"profiles": {
3-
"XHarness": {
4-
"commandName": "Project",
5-
"commandLineArgs": "ios state"
6-
}
2+
"profiles": {
3+
"XHarness": {
4+
"commandName": "Project",
5+
"commandLineArgs": "help"
76
}
8-
}
7+
}
8+
}

0 commit comments

Comments
 (0)