summaryrefslogtreecommitdiff
path: root/tests/projects/csharp/console_with_runtime_json
diff options
context:
space:
mode:
Diffstat (limited to 'tests/projects/csharp/console_with_runtime_json')
-rw-r--r--tests/projects/csharp/console_with_runtime_json/.gitignore7
-rw-r--r--tests/projects/csharp/console_with_runtime_json/src/Program.cs15
-rw-r--r--tests/projects/csharp/console_with_runtime_json/src/runtime.json7
-rw-r--r--tests/projects/csharp/console_with_runtime_json/test.lua13
-rw-r--r--tests/projects/csharp/console_with_runtime_json/xmake.lua7
5 files changed, 49 insertions, 0 deletions
diff --git a/tests/projects/csharp/console_with_runtime_json/.gitignore b/tests/projects/csharp/console_with_runtime_json/.gitignore
new file mode 100644
index 000000000..53e577525
--- /dev/null
+++ b/tests/projects/csharp/console_with_runtime_json/.gitignore
@@ -0,0 +1,7 @@
+.xmake/
+build/
+bin/
+obj/
+vsxmake*/
+.vs/
+
diff --git a/tests/projects/csharp/console_with_runtime_json/src/Program.cs b/tests/projects/csharp/console_with_runtime_json/src/Program.cs
new file mode 100644
index 000000000..fd836a339
--- /dev/null
+++ b/tests/projects/csharp/console_with_runtime_json/src/Program.cs
@@ -0,0 +1,15 @@
+using System.Text.Json;
+
+var runtimeFile = Path.Combine(Directory.GetCurrentDirectory(), "runtime.json");
+if (!File.Exists(runtimeFile)) {
+ Console.WriteLine("runtime.json missing");
+ return;
+}
+
+var json = File.ReadAllText(runtimeFile);
+using var doc = JsonDocument.Parse(json);
+var runtime = doc.RootElement.TryGetProperty("runtime", out var value)
+ ? value.GetString()
+ : "unknown";
+
+Console.WriteLine($"runtime={runtime}");
diff --git a/tests/projects/csharp/console_with_runtime_json/src/runtime.json b/tests/projects/csharp/console_with_runtime_json/src/runtime.json
new file mode 100644
index 000000000..15bec810d
--- /dev/null
+++ b/tests/projects/csharp/console_with_runtime_json/src/runtime.json
@@ -0,0 +1,7 @@
+{
+ "runtime": "xmake",
+ "featureFlags": {
+ "sample": true
+ }
+}
+
diff --git a/tests/projects/csharp/console_with_runtime_json/test.lua b/tests/projects/csharp/console_with_runtime_json/test.lua
new file mode 100644
index 000000000..d909316b7
--- /dev/null
+++ b/tests/projects/csharp/console_with_runtime_json/test.lua
@@ -0,0 +1,13 @@
+import("detect.sdks.find_dotnet")
+
+function test_build(t)
+ if is_subhost("msys") then
+ return t:skip("csharp not supported on msys")
+ end
+ local dotnet = find_dotnet()
+ if dotnet and dotnet.sdkver then
+ t:build()
+ else
+ return t:skip("dotnet sdk not found")
+ end
+end
diff --git a/tests/projects/csharp/console_with_runtime_json/xmake.lua b/tests/projects/csharp/console_with_runtime_json/xmake.lua
new file mode 100644
index 000000000..979f74307
--- /dev/null
+++ b/tests/projects/csharp/console_with_runtime_json/xmake.lua
@@ -0,0 +1,7 @@
+add_rules("mode.debug", "mode.release")
+
+target("app")
+ set_kind("binary")
+ add_rules("csharp")
+ add_files("src/Program.cs")
+ set_rundir("src")