summaryrefslogtreecommitdiff
path: root/tests/projects/csharp/console_with_runtime_json/src/Program.cs
blob: 690faf8736b2d96e5233eea1cf2c307aad5e4a7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
using System.Text.Json;

var runtimeFile = Path.Combine(AppContext.BaseDirectory, "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}");