feat: add Launcher Next .NET 8 foundation
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using Microsoft.Win32;
|
||||
using Launcher.Next.Core;
|
||||
namespace Launcher.Next.Autodesk;
|
||||
public interface IRegistryReader { object? GetValue(string path, string name); }
|
||||
public sealed class WindowsRegistryReader : IRegistryReader { public object? GetValue(string path, string name) => Registry.LocalMachine.OpenSubKey(path)?.GetValue(name); }
|
||||
public sealed class PlantProductDiscovery(IRegistryReader registry) : IProductDiscovery
|
||||
{
|
||||
public ProductInstallation? DiscoverPlant3D(int year)
|
||||
{
|
||||
var install = registry.GetValue($@"SOFTWARE\Autodesk\AutoCAD\R25.1\ACAD-xxxx:409", "InstallDir") as string;
|
||||
if (string.IsNullOrWhiteSpace(install)) return null; var exe = Path.Combine(install, "acad.exe");
|
||||
return File.Exists(exe) ? new(exe, year.ToString(), "x64", []) : null;
|
||||
}
|
||||
}
|
||||
public sealed class StartupScriptBuilder : IStartupScriptBuilder
|
||||
{
|
||||
public string BuildNetloadScript(string root, string entry)
|
||||
{ var full = Path.GetFullPath(Path.Combine(root, entry)); if (!full.StartsWith(Path.GetFullPath(root) + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase) || !File.Exists(full)) throw new InvalidOperationException("UNTRUSTED_ENTRY_PATH"); return $"(command \"._netload\" \"{full.Replace("\\", "\\\\").Replace("\"", "\\\"")}\")\n"; }
|
||||
}
|
||||
public sealed class DryRunAutodeskProcessLauncher : IAutodeskProcessLauncher
|
||||
{
|
||||
public PreparedLaunch Prepare(LaunchRequest r)
|
||||
{
|
||||
if (!r.DryRun) throw new InvalidOperationException("PROCESS_START_DISABLED_IN_FOUNDATION");
|
||||
var startInfo = new System.Diagnostics.ProcessStartInfo
|
||||
{
|
||||
FileName = r.Product.ExecutablePath,
|
||||
WorkingDirectory = Path.GetDirectoryName(r.Product.ExecutablePath)!,
|
||||
UseShellExecute = false
|
||||
};
|
||||
startInfo.ArgumentList.Add("/product"); startInfo.ArgumentList.Add("PLNT3D");
|
||||
startInfo.ArgumentList.Add("/p"); startInfo.ArgumentList.Add(r.Profile);
|
||||
startInfo.ArgumentList.Add("/b"); startInfo.ArgumentList.Add(r.StartupScriptPath);
|
||||
return new(startInfo.FileName, startInfo.ArgumentList.ToArray(), startInfo.WorkingDirectory, false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user