35 lines
1.1 KiB
C#
35 lines
1.1 KiB
C#
namespace Backend;
|
|
|
|
public sealed class LanderConfig
|
|
{
|
|
public string CliPath { get; set; } = "publish/GameCli/GameCli";
|
|
public string ModelPath { get; set; } = "models/ppo_lander.onnx";
|
|
}
|
|
|
|
/// <summary>
|
|
/// Walks up from <see cref="AppContext.BaseDirectory"/> to find the repo root
|
|
/// (marker file: <c>GameCli.sln</c>) and resolves the configured paths against it.
|
|
/// </summary>
|
|
public static class PathResolver
|
|
{
|
|
public static string RepoRoot()
|
|
{
|
|
var dir = AppContext.BaseDirectory;
|
|
while (dir is not null)
|
|
{
|
|
if (File.Exists(Path.Combine(dir, "GameCli.sln"))) return dir;
|
|
var parent = Directory.GetParent(dir);
|
|
if (parent is null) break;
|
|
dir = parent.FullName;
|
|
}
|
|
throw new InvalidOperationException(
|
|
"could not locate repo root (no GameCli.sln found in any ancestor)");
|
|
}
|
|
|
|
public static string Resolve(string relativeOrAbsolute)
|
|
{
|
|
if (Path.IsPathRooted(relativeOrAbsolute)) return relativeOrAbsolute;
|
|
return Path.GetFullPath(Path.Combine(RepoRoot(), relativeOrAbsolute));
|
|
}
|
|
}
|