Forge
csharpdeeb25a2
1namespace CascadeIDE.Features.Agent.Environment;
2
3/// <summary>Разрешает путь к <c>CascadeIDE.BuildVerifyWorker.dll</c> для out-of-proc verify.</summary>
4public static class BuildVerifyWorkerAssemblyLocator
5{
6 public const string DefaultDllName = "CascadeIDE.BuildVerifyWorker.dll";
7
8 public static bool TryResolve(string? configuredPath, out string dllPath)
9 {
10 if (TryExistingFile(configuredPath, out dllPath))
11 return true;
12
13 var nextToApp = Path.Combine(AppContext.BaseDirectory, DefaultDllName);
14 if (TryExistingFile(nextToApp, out dllPath))
15 return true;
16
17 var repoTools = TryFindRepoToolsDll();
18 if (repoTools is not null && TryExistingFile(repoTools, out dllPath))
19 return true;
20
21 dllPath = nextToApp;
22 return false;
23 }
24
25 private static string? TryFindRepoToolsDll()
26 {
27 var dir = new DirectoryInfo(AppContext.BaseDirectory);
28 while (dir is not null)
29 {
30 if (File.Exists(Path.Combine(dir.FullName, "CascadeIDE.sln")))
31 {
32 return Path.Combine(
33 dir.FullName,
34 "tools",
35 "CascadeIDE.BuildVerifyWorker",
36 "bin",
37 "Debug",
38 "net10.0",
39 DefaultDllName);
40 }
41
42 dir = dir.Parent;
43 }
44
45 return null;
46 }
47
48 private static bool TryExistingFile(string? path, out string fullPath)
49 {
50 fullPath = "";
51 if (string.IsNullOrWhiteSpace(path))
52 return false;
53
54 try
55 {
56 fullPath = Path.GetFullPath(path.Trim());
57 return File.Exists(fullPath);
58 }
59 catch
60 {
61 return false;
62 }
63 }
64}
65
View only · write via MCP/CIDE