summaryrefslogtreecommitdiff
path: root/tests/projects/csharp/console_with_runtime_json/src/Program.cs
blob: 2c9b0783b2d291a54b0e03b21d828a13183dc96a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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}");