BuildTool: Tidy up and improve performance
This commit is contained in:
+137
-199
@@ -35,49 +35,28 @@ namespace CustomBuildTool
|
|||||||
Console.InputEncoding = Encoding.UTF8;
|
Console.InputEncoding = Encoding.UTF8;
|
||||||
Console.OutputEncoding = Encoding.UTF8;
|
Console.OutputEncoding = Encoding.UTF8;
|
||||||
|
|
||||||
try
|
if (!Utils.SetCurrentDirectoryParent("SystemInformer.sln"))
|
||||||
{
|
|
||||||
DirectoryInfo info = new DirectoryInfo(".");
|
|
||||||
|
|
||||||
while (info.Parent != null && info.Parent.Parent != null)
|
|
||||||
{
|
|
||||||
info = info.Parent;
|
|
||||||
|
|
||||||
if (File.Exists($"{info.FullName}\\SystemInformer.sln"))
|
|
||||||
{
|
|
||||||
Directory.SetCurrentDirectory(info.FullName);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Program.PrintColorMessage($"Unable to find project root directory: {ex}", ConsoleColor.Red);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!File.Exists("SystemInformer.sln"))
|
|
||||||
{
|
{
|
||||||
Program.PrintColorMessage("Unable to find project solution.", ConsoleColor.Red);
|
Program.PrintColorMessage("Unable to find project solution.", ConsoleColor.Red);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Build.TimeStart = DateTime.Now;
|
Build.TimeStart = DateTime.UtcNow;
|
||||||
Build.BuildWorkingFolder = Environment.CurrentDirectory;
|
Build.BuildWorkingFolder = Environment.CurrentDirectory;
|
||||||
Build.BuildOutputFolder = Utils.GetOutputDirectoryPath();
|
Build.BuildOutputFolder = Utils.GetOutputDirectoryPath();
|
||||||
|
|
||||||
if (Win32.GetEnvironmentVariable("SYSTEM_BUILD", out string build_definition))
|
if (Win32.GetEnvironmentVariableSpan("SYSTEM_BUILD", out ReadOnlySpan<char> build_definition))
|
||||||
{
|
{
|
||||||
if (string.Equals(build_definition, "canary", StringComparison.OrdinalIgnoreCase))
|
if (MemoryExtensions.Equals(build_definition, "canary", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
Build.BuildCanary = true;
|
Build.BuildCanary = true;
|
||||||
Program.PrintColorMessage("[CANARY BUILD]", ConsoleColor.Cyan);
|
Program.PrintColorMessage("[CANARY BUILD]", ConsoleColor.Cyan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Win32.GetEnvironmentVariable("SYSTEM_DEBUG", out string build_debug))
|
if (Win32.GetEnvironmentVariableSpan("SYSTEM_DEBUG", out ReadOnlySpan<char> build_debug))
|
||||||
{
|
{
|
||||||
if (string.Equals(build_debug, "true", StringComparison.OrdinalIgnoreCase))
|
if (MemoryExtensions.Equals(build_debug, "true", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
Build.BuildToolsDebug = true;
|
Build.BuildToolsDebug = true;
|
||||||
Program.PrintColorMessage("[DEBUG BUILD]", ConsoleColor.Cyan);
|
Program.PrintColorMessage("[DEBUG BUILD]", ConsoleColor.Cyan);
|
||||||
@@ -151,11 +130,11 @@ namespace CustomBuildTool
|
|||||||
foreach (string folder in project_folders)
|
foreach (string folder in project_folders)
|
||||||
{
|
{
|
||||||
string path = Path.GetFullPath(folder);
|
string path = Path.GetFullPath(folder);
|
||||||
string name = Path.GetFileName(path);
|
var name = Path.GetFileName(path.AsSpan());
|
||||||
|
|
||||||
if (
|
if (
|
||||||
string.Equals(name, ".vs", StringComparison.OrdinalIgnoreCase) ||
|
name.Equals(".vs", StringComparison.OrdinalIgnoreCase) ||
|
||||||
string.Equals(name, "obj", StringComparison.OrdinalIgnoreCase)
|
name.Equals("obj", StringComparison.OrdinalIgnoreCase)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (Directory.Exists(path))
|
if (Directory.Exists(path))
|
||||||
@@ -186,7 +165,7 @@ namespace CustomBuildTool
|
|||||||
foreach (string file in res_files)
|
foreach (string file in res_files)
|
||||||
{
|
{
|
||||||
string path = Path.GetFullPath(file);
|
string path = Path.GetFullPath(file);
|
||||||
string name = Path.GetFileName(path);
|
var name = Path.GetFileName(path.AsSpan());
|
||||||
|
|
||||||
if (name.EndsWith(".aps", StringComparison.OrdinalIgnoreCase))
|
if (name.EndsWith(".aps", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
@@ -252,8 +231,8 @@ namespace CustomBuildTool
|
|||||||
if (instance != null)
|
if (instance != null)
|
||||||
{
|
{
|
||||||
Program.PrintColorMessage("WindowsSDK: ", ConsoleColor.DarkGray, false);
|
Program.PrintColorMessage("WindowsSDK: ", ConsoleColor.DarkGray, false);
|
||||||
Program.PrintColorMessage(Utils.GetWindowsSdkVersion(), ConsoleColor.Green);
|
//Program.PrintColorMessage(Utils.GetWindowsSdkVersion(), ConsoleColor.Green);
|
||||||
//Program.PrintColorMessage(Utils.GetWindowsSdkVersion() + " (" + instance.GetWindowsSdkFullVersion() + ")", ConsoleColor.Green, true);
|
Program.PrintColorMessage(Utils.GetWindowsSdkVersion() + " (" + instance.GetWindowsSdkFullVersion() + ")", ConsoleColor.Green, true);
|
||||||
Program.PrintColorMessage("VisualStudio: ", ConsoleColor.DarkGray, false);
|
Program.PrintColorMessage("VisualStudio: ", ConsoleColor.DarkGray, false);
|
||||||
Program.PrintColorMessage(instance.Name, ConsoleColor.Green);
|
Program.PrintColorMessage(instance.Name, ConsoleColor.Green);
|
||||||
//Program.PrintColorMessage(Utils.GetVisualStudioVersion(), ConsoleColor.Green, true);
|
//Program.PrintColorMessage(Utils.GetVisualStudioVersion(), ConsoleColor.Green, true);
|
||||||
@@ -283,12 +262,12 @@ namespace CustomBuildTool
|
|||||||
|
|
||||||
public static string BuildTimeStamp()
|
public static string BuildTimeStamp()
|
||||||
{
|
{
|
||||||
return $"[{DateTime.Now - TimeStart:mm\\:ss}] ";
|
return $"[{DateTime.UtcNow - TimeStart:mm\\:ss}] ";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ShowBuildStats()
|
public static void ShowBuildStats()
|
||||||
{
|
{
|
||||||
TimeSpan buildTime = DateTime.Now - TimeStart;
|
TimeSpan buildTime = (DateTime.UtcNow - TimeStart);
|
||||||
|
|
||||||
Program.PrintColorMessage($"{Environment.NewLine}Build Time: ", ConsoleColor.DarkGray, false);
|
Program.PrintColorMessage($"{Environment.NewLine}Build Time: ", ConsoleColor.DarkGray, false);
|
||||||
Program.PrintColorMessage(buildTime.Minutes.ToString(), ConsoleColor.Green, false);
|
Program.PrintColorMessage(buildTime.Minutes.ToString(), ConsoleColor.Green, false);
|
||||||
@@ -319,93 +298,35 @@ namespace CustomBuildTool
|
|||||||
|
|
||||||
public static bool CopyWow64Files(BuildFlags Flags)
|
public static bool CopyWow64Files(BuildFlags Flags)
|
||||||
{
|
{
|
||||||
if (Flags.HasFlag(BuildFlags.BuildDebug))
|
string[] Build_Wow64_Files =
|
||||||
|
[
|
||||||
|
"SystemInformer.exe",
|
||||||
|
"SystemInformer.pdb",
|
||||||
|
"SystemInformer.sig",
|
||||||
|
"plugins\\DotNetTools.dll",
|
||||||
|
"plugins\\DotNetTools.pdb",
|
||||||
|
"plugins\\DotNetTools.sig",
|
||||||
|
"plugins\\ExtendedTools.dll",
|
||||||
|
"plugins\\ExtendedTools.pdb",
|
||||||
|
"plugins\\ExtendedTools.sig",
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach (string file in Build_Wow64_Files)
|
||||||
{
|
{
|
||||||
if (Flags.HasFlag(BuildFlags.Build64bit))
|
if (Flags.HasFlag(BuildFlags.BuildDebug))
|
||||||
{
|
{
|
||||||
if (Directory.Exists("bin\\Debug64"))
|
if (Flags.HasFlag(BuildFlags.Build64bit))
|
||||||
{
|
Win32.CopyIfNewer($"bin\\Debug32\\{file}", $"bin\\Debug64\\x86\\{file}");
|
||||||
//Win32.CreateDirectory("bin\\Debug64\\x86");
|
if (Flags.HasFlag(BuildFlags.BuildArm64bit))
|
||||||
Win32.CreateDirectory("bin\\Debug64\\x86\\plugins"); // recursive
|
Win32.CopyIfNewer($"bin\\Debug32\\{file}", $"bin\\DebugARM64\\x86\\{file}");
|
||||||
|
|
||||||
Win32.CopyIfNewer("bin\\Debug32\\SystemInformer.exe", "bin\\Debug64\\x86\\SystemInformer.exe");
|
|
||||||
Win32.CopyIfNewer("bin\\Debug32\\SystemInformer.pdb", "bin\\Debug64\\x86\\SystemInformer.pdb");
|
|
||||||
Win32.CopyIfNewer("bin\\Debug32\\SystemInformer.sig", "bin\\Debug64\\x86\\SystemInformer.sig");
|
|
||||||
|
|
||||||
Win32.CopyIfNewer("bin\\Debug32\\plugins\\DotNetTools.dll", "bin\\Debug64\\x86\\plugins\\DotNetTools.dll");
|
|
||||||
Win32.CopyIfNewer("bin\\Debug32\\plugins\\DotNetTools.pdb", "bin\\Debug64\\x86\\plugins\\DotNetTools.pdb");
|
|
||||||
Win32.CopyIfNewer("bin\\Debug32\\plugins\\DotNetTools.sig", "bin\\Debug64\\x86\\plugins\\DotNetTools.sig");
|
|
||||||
|
|
||||||
Win32.CopyIfNewer("bin\\Debug32\\plugins\\ExtendedTools.dll", "bin\\Debug64\\x86\\plugins\\ExtendedTools.dll");
|
|
||||||
Win32.CopyIfNewer("bin\\Debug32\\plugins\\ExtendedTools.pdb", "bin\\Debug64\\x86\\plugins\\ExtendedTools.pdb");
|
|
||||||
Win32.CopyIfNewer("bin\\Debug32\\plugins\\ExtendedTools.sig", "bin\\Debug64\\x86\\plugins\\ExtendedTools.sig");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Flags.HasFlag(BuildFlags.BuildArm64bit))
|
if (Flags.HasFlag(BuildFlags.BuildRelease))
|
||||||
{
|
{
|
||||||
if (Directory.Exists("bin\\DebugARM64"))
|
if (Flags.HasFlag(BuildFlags.Build64bit))
|
||||||
{
|
Win32.CopyIfNewer($"bin\\Release32\\{file}", $"bin\\Release64\\x86\\{file}");
|
||||||
//Win32.CreateDirectory("bin\\DebugARM64\\x86");
|
if (Flags.HasFlag(BuildFlags.BuildArm64bit))
|
||||||
Win32.CreateDirectory("bin\\DebugARM64\\x86\\plugins"); // recursive
|
Win32.CopyIfNewer($"bin\\Release32\\{file}", $"bin\\ReleaseARM64\\x86\\{file}");
|
||||||
|
|
||||||
Win32.CopyIfNewer("bin\\Debug32\\SystemInformer.exe", "bin\\DebugARM64\\x86\\SystemInformer.exe");
|
|
||||||
Win32.CopyIfNewer("bin\\Debug32\\SystemInformer.pdb", "bin\\DebugARM64\\x86\\SystemInformer.pdb");
|
|
||||||
Win32.CopyIfNewer("bin\\Debug32\\SystemInformer.sig", "bin\\DebugARM64\\x86\\SystemInformer.sig");
|
|
||||||
|
|
||||||
Win32.CopyIfNewer("bin\\Debug32\\plugins\\DotNetTools.dll", "bin\\DebugARM64\\x86\\plugins\\DotNetTools.dll");
|
|
||||||
Win32.CopyIfNewer("bin\\Debug32\\plugins\\DotNetTools.pdb", "bin\\DebugARM64\\x86\\plugins\\DotNetTools.pdb");
|
|
||||||
Win32.CopyIfNewer("bin\\Debug32\\plugins\\DotNetTools.sig", "bin\\DebugARM64\\x86\\plugins\\DotNetTools.sig");
|
|
||||||
|
|
||||||
Win32.CopyIfNewer("bin\\Debug32\\plugins\\ExtendedTools.dll", "bin\\DebugARM64\\x86\\plugins\\ExtendedTools.dll");
|
|
||||||
Win32.CopyIfNewer("bin\\Debug32\\plugins\\ExtendedTools.pdb", "bin\\DebugARM64\\x86\\plugins\\ExtendedTools.pdb");
|
|
||||||
Win32.CopyIfNewer("bin\\Debug32\\plugins\\ExtendedTools.sig", "bin\\DebugARM64\\x86\\plugins\\ExtendedTools.sig");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Flags.HasFlag(BuildFlags.BuildRelease))
|
|
||||||
{
|
|
||||||
if (Flags.HasFlag(BuildFlags.Build64bit))
|
|
||||||
{
|
|
||||||
if (Directory.Exists("bin\\Release64"))
|
|
||||||
{
|
|
||||||
//Win32.CreateDirectory("bin\\Release64\\x86");
|
|
||||||
Win32.CreateDirectory("bin\\Release64\\x86\\plugins"); // recursive
|
|
||||||
|
|
||||||
Win32.CopyIfNewer("bin\\Release32\\SystemInformer.exe", "bin\\Release64\\x86\\SystemInformer.exe");
|
|
||||||
Win32.CopyIfNewer("bin\\Release32\\SystemInformer.pdb", "bin\\Release64\\x86\\SystemInformer.pdb");
|
|
||||||
Win32.CopyIfNewer("bin\\Release32\\SystemInformer.sig", "bin\\Release64\\x86\\SystemInformer.sig");
|
|
||||||
|
|
||||||
Win32.CopyIfNewer("bin\\Release32\\plugins\\DotNetTools.dll", "bin\\Release64\\x86\\plugins\\DotNetTools.dll");
|
|
||||||
Win32.CopyIfNewer("bin\\Release32\\plugins\\DotNetTools.pdb", "bin\\Release64\\x86\\plugins\\DotNetTools.pdb");
|
|
||||||
Win32.CopyIfNewer("bin\\Release32\\plugins\\DotNetTools.sig", "bin\\Release64\\x86\\plugins\\DotNetTools.sig");
|
|
||||||
|
|
||||||
Win32.CopyIfNewer("bin\\Release32\\plugins\\ExtendedTools.dll", "bin\\Release64\\x86\\plugins\\ExtendedTools.dll");
|
|
||||||
Win32.CopyIfNewer("bin\\Release32\\plugins\\ExtendedTools.pdb", "bin\\Release64\\x86\\plugins\\ExtendedTools.pdb");
|
|
||||||
Win32.CopyIfNewer("bin\\Release32\\plugins\\ExtendedTools.sig", "bin\\Release64\\x86\\plugins\\ExtendedTools.sig");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Flags.HasFlag(BuildFlags.BuildArm64bit))
|
|
||||||
{
|
|
||||||
if (Directory.Exists("bin\\ReleaseARM64"))
|
|
||||||
{
|
|
||||||
//Win32.CreateDirectory("bin\\ReleaseARM64\\x86");
|
|
||||||
Win32.CreateDirectory("bin\\ReleaseARM64\\x86\\plugins"); // recursive
|
|
||||||
|
|
||||||
Win32.CopyIfNewer("bin\\Release32\\SystemInformer.exe", "bin\\ReleaseARM64\\x86\\SystemInformer.exe");
|
|
||||||
Win32.CopyIfNewer("bin\\Release32\\SystemInformer.pdb", "bin\\ReleaseARM64\\x86\\SystemInformer.pdb");
|
|
||||||
Win32.CopyIfNewer("bin\\Release32\\SystemInformer.sig", "bin\\ReleaseARM64\\x86\\SystemInformer.sig");
|
|
||||||
|
|
||||||
Win32.CopyIfNewer("bin\\Release32\\plugins\\DotNetTools.dll", "bin\\ReleaseARM64\\x86\\plugins\\DotNetTools.dll");
|
|
||||||
Win32.CopyIfNewer("bin\\Release32\\plugins\\DotNetTools.pdb", "bin\\ReleaseARM64\\x86\\plugins\\DotNetTools.pdb");
|
|
||||||
Win32.CopyIfNewer("bin\\Release32\\plugins\\DotNetTools.sig", "bin\\ReleaseARM64\\x86\\plugins\\DotNetTools.sig");
|
|
||||||
|
|
||||||
Win32.CopyIfNewer("bin\\Release32\\plugins\\ExtendedTools.dll", "bin\\ReleaseARM64\\x86\\plugins\\ExtendedTools.dll");
|
|
||||||
Win32.CopyIfNewer("bin\\Release32\\plugins\\ExtendedTools.pdb", "bin\\ReleaseARM64\\x86\\plugins\\ExtendedTools.pdb");
|
|
||||||
Win32.CopyIfNewer("bin\\Release32\\plugins\\ExtendedTools.sig", "bin\\ReleaseARM64\\x86\\plugins\\ExtendedTools.sig");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -414,7 +335,7 @@ namespace CustomBuildTool
|
|||||||
|
|
||||||
public static bool CopyResourceFiles(BuildFlags Flags)
|
public static bool CopyResourceFiles(BuildFlags Flags)
|
||||||
{
|
{
|
||||||
var Build_Resource_Files = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
|
var Build_Resource_Files = new Dictionary<string, string>(4, StringComparer.OrdinalIgnoreCase)
|
||||||
{
|
{
|
||||||
{ "SystemInformer.png", "icon.png" },
|
{ "SystemInformer.png", "icon.png" },
|
||||||
{ "CapsList.txt", "CapsList.txt" },
|
{ "CapsList.txt", "CapsList.txt" },
|
||||||
@@ -448,6 +369,46 @@ namespace CustomBuildTool
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool CopyDebugEngineFiles(BuildFlags Flags)
|
||||||
|
{
|
||||||
|
var Build_DebugCore_Files = new string[]
|
||||||
|
{
|
||||||
|
"dbgcore.dll",
|
||||||
|
"dbghelp.dll",
|
||||||
|
"symsrv.dll"
|
||||||
|
};
|
||||||
|
|
||||||
|
string windowsSdkPath = Path.GetFullPath(Path.Join([Utils.GetWindowsSdkPath(), "..\\Debuggers\\"]));
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(windowsSdkPath))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
foreach (var file in Build_DebugCore_Files)
|
||||||
|
{
|
||||||
|
if (Flags.HasFlag(BuildFlags.BuildDebug))
|
||||||
|
{
|
||||||
|
if (Flags.HasFlag(BuildFlags.Build32bit))
|
||||||
|
Win32.CopyIfNewer($"{windowsSdkPath}\\x86\\{file}", $"bin\\Debug32\\{file}");
|
||||||
|
if (Flags.HasFlag(BuildFlags.Build64bit))
|
||||||
|
Win32.CopyIfNewer($"{windowsSdkPath}\\x64\\{file}", $"bin\\Debug64\\{file}");
|
||||||
|
if (Flags.HasFlag(BuildFlags.BuildArm64bit))
|
||||||
|
Win32.CopyIfNewer($"{windowsSdkPath}\\arm64\\{file}", $"bin\\DebugARM64\\{file}");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Flags.HasFlag(BuildFlags.BuildRelease))
|
||||||
|
{
|
||||||
|
if (Flags.HasFlag(BuildFlags.Build32bit))
|
||||||
|
Win32.CopyIfNewer($"{windowsSdkPath}\\x86\\{file}", $"bin\\Release32\\{file}");
|
||||||
|
if (Flags.HasFlag(BuildFlags.Build64bit))
|
||||||
|
Win32.CopyIfNewer($"{windowsSdkPath}\\x64\\{file}", $"bin\\Release64\\{file}");
|
||||||
|
if (Flags.HasFlag(BuildFlags.BuildArm64bit))
|
||||||
|
Win32.CopyIfNewer($"{windowsSdkPath}\\arm64\\{file}", $"bin\\ReleaseARM64\\{file}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public static bool BuildPublicHeaderFiles()
|
public static bool BuildPublicHeaderFiles()
|
||||||
{
|
{
|
||||||
Program.PrintColorMessage(BuildTimeStamp(), ConsoleColor.DarkGray, false);
|
Program.PrintColorMessage(BuildTimeStamp(), ConsoleColor.DarkGray, false);
|
||||||
@@ -497,55 +458,21 @@ namespace CustomBuildTool
|
|||||||
if (Flags.HasFlag(BuildFlags.BuildDebug))
|
if (Flags.HasFlag(BuildFlags.BuildDebug))
|
||||||
{
|
{
|
||||||
if (Flags.HasFlag(BuildFlags.Build32bit))
|
if (Flags.HasFlag(BuildFlags.Build32bit))
|
||||||
{
|
Win32.CopyVersionIfNewer($"KSystemInformer\\bin-signed\\i386\\{file}", $"bin\\Debug32\\{file}");
|
||||||
if (Directory.Exists("KSystemInformer\\bin-signed\\i386"))
|
|
||||||
{
|
|
||||||
Win32.CopyVersionIfNewer($"KSystemInformer\\bin-signed\\i386\\{file}", $"bin\\Debug32\\{file}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Flags.HasFlag(BuildFlags.Build64bit))
|
if (Flags.HasFlag(BuildFlags.Build64bit))
|
||||||
{
|
Win32.CopyVersionIfNewer($"KSystemInformer\\bin-signed\\amd64\\{file}", $"bin\\Debug64\\{file}");
|
||||||
if (Directory.Exists("KSystemInformer\\bin-signed\\amd64"))
|
|
||||||
{
|
|
||||||
Win32.CopyVersionIfNewer($"KSystemInformer\\bin-signed\\amd64\\{file}", $"bin\\Debug64\\{file}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Flags.HasFlag(BuildFlags.BuildArm64bit))
|
if (Flags.HasFlag(BuildFlags.BuildArm64bit))
|
||||||
{
|
Win32.CopyVersionIfNewer($"KSystemInformer\\bin-signed\\arm64\\{file}", $"bin\\DebugARM64\\{file}");
|
||||||
if (Directory.Exists("KSystemInformer\\bin-signed\\arm64"))
|
|
||||||
{
|
|
||||||
Win32.CopyVersionIfNewer($"KSystemInformer\\bin-signed\\arm64\\{file}", $"bin\\DebugARM64\\{file}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Flags.HasFlag(BuildFlags.BuildRelease))
|
if (Flags.HasFlag(BuildFlags.BuildRelease))
|
||||||
{
|
{
|
||||||
if (Flags.HasFlag(BuildFlags.Build32bit))
|
if (Flags.HasFlag(BuildFlags.Build32bit))
|
||||||
{
|
Win32.CopyVersionIfNewer($"KSystemInformer\\bin-signed\\i386\\{file}", $"bin\\Release32\\{file}");
|
||||||
if (Directory.Exists("KSystemInformer\\bin-signed\\i386"))
|
|
||||||
{
|
|
||||||
Win32.CopyVersionIfNewer($"KSystemInformer\\bin-signed\\i386\\{file}", $"bin\\Release32\\{file}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Flags.HasFlag(BuildFlags.Build64bit))
|
if (Flags.HasFlag(BuildFlags.Build64bit))
|
||||||
{
|
Win32.CopyVersionIfNewer($"KSystemInformer\\bin-signed\\amd64\\{file}", $"bin\\Release64\\{file}");
|
||||||
if (Directory.Exists("KSystemInformer\\bin-signed\\amd64"))
|
|
||||||
{
|
|
||||||
Win32.CopyVersionIfNewer($"KSystemInformer\\bin-signed\\amd64\\{file}", $"bin\\Release64\\{file}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Flags.HasFlag(BuildFlags.BuildArm64bit))
|
if (Flags.HasFlag(BuildFlags.BuildArm64bit))
|
||||||
{
|
Win32.CopyVersionIfNewer($"KSystemInformer\\bin-signed\\arm64\\{file}", $"bin\\ReleaseARM64\\{file}");
|
||||||
if (Directory.Exists("KSystemInformer\\bin-signed\\arm64"))
|
|
||||||
{
|
|
||||||
Win32.CopyVersionIfNewer($"KSystemInformer\\bin-signed\\arm64\\{file}", $"bin\\ReleaseARM64\\{file}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -700,18 +627,34 @@ namespace CustomBuildTool
|
|||||||
// Build the SDK
|
// Build the SDK
|
||||||
HeaderGen.Execute();
|
HeaderGen.Execute();
|
||||||
|
|
||||||
// Copy the resource header
|
// Copy the SDK headers
|
||||||
Win32.CopyIfNewer("SystemInformer\\sdk\\phapppub.h", "sdk\\include\\phapppub.h");
|
Win32.CopyIfNewer("SystemInformer\\sdk\\phapppub.h", "sdk\\include\\phapppub.h");
|
||||||
Win32.CopyIfNewer("SystemInformer\\sdk\\phdk.h", "sdk\\include\\phdk.h");
|
Win32.CopyIfNewer("SystemInformer\\sdk\\phdk.h", "sdk\\include\\phdk.h");
|
||||||
Win32.CopyIfNewer("SystemInformer\\resource.h", "sdk\\include\\phappresource.h");
|
//Win32.CopyIfNewer("SystemInformer\\resource.h", "sdk\\include\\phappresource.h");
|
||||||
|
|
||||||
// Append resource headers with SDK exports
|
// Copy the resource header and prefix types with PHAPP
|
||||||
string phappContent = Utils.ReadAllText("sdk\\include\\phappresource.h");
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(phappContent))
|
|
||||||
{
|
{
|
||||||
phappContent = phappContent.Replace("#define ID", "#define PHAPP_ID", StringComparison.OrdinalIgnoreCase);
|
FileInfo sourceFile = new FileInfo("SystemInformer\\resource.h");
|
||||||
Utils.WriteAllText("sdk\\include\\phappresource.h", phappContent);
|
FileInfo destinationFile = new FileInfo("sdk\\include\\phappresource.h");
|
||||||
|
|
||||||
|
if (
|
||||||
|
sourceFile.CreationTimeUtc > destinationFile.CreationTimeUtc ||
|
||||||
|
sourceFile.LastWriteTimeUtc > destinationFile.LastWriteTimeUtc
|
||||||
|
)
|
||||||
|
{
|
||||||
|
string resourceContent = Utils.ReadAllText("SystemInformer\\resource.h");
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(resourceContent))
|
||||||
|
{
|
||||||
|
// Update resource headers with SDK definition
|
||||||
|
string sdkContent = resourceContent.Replace("#define ID", "#define PHAPP_ID", StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
Utils.WriteAllText("sdk\\include\\phappresource.h", sdkContent);
|
||||||
|
|
||||||
|
destinationFile.CreationTimeUtc = sourceFile.CreationTimeUtc;
|
||||||
|
destinationFile.LastWriteTimeUtc = sourceFile.LastWriteTimeUtc;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -1024,16 +967,17 @@ namespace CustomBuildTool
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!HaveArm64BuildTools)
|
|
||||||
{
|
|
||||||
Program.PrintColorMessage("[SKIPPED] ARM64 build tools not installed.", ConsoleColor.Yellow, true, Flags);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Flags.HasFlag(BuildFlags.BuildArm64bit))
|
if (Flags.HasFlag(BuildFlags.BuildArm64bit))
|
||||||
{
|
{
|
||||||
if (!MsbuildCommand(Solution, "ARM64", Flags, Channel))
|
if (HaveArm64BuildTools)
|
||||||
return false;
|
{
|
||||||
|
if (!MsbuildCommand(Solution, "ARM64", Flags, Channel))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Program.PrintColorMessage("[SKIPPED] ARM64 build tools not installed.", ConsoleColor.Yellow, true, Flags);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -1173,31 +1117,25 @@ namespace CustomBuildTool
|
|||||||
if (buildPostString.LongLength == 0)
|
if (buildPostString.LongLength == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
using (HttpClientHandler httpClientHandler = new HttpClientHandler())
|
using HttpClientHandler httpClientHandler = new HttpClientHandler();
|
||||||
|
httpClientHandler.AutomaticDecompression = DecompressionMethods.All;
|
||||||
|
httpClientHandler.SslProtocols = SslProtocols.Tls12 | SslProtocols.Tls13;
|
||||||
|
|
||||||
|
using HttpClient httpClient = new HttpClient(httpClientHandler);
|
||||||
|
httpClient.DefaultRequestHeaders.Add("X-ApiKey", buildPostSfApiKey);
|
||||||
|
httpClient.DefaultVersionPolicy = HttpVersionPolicy.RequestVersionOrHigher;
|
||||||
|
httpClient.DefaultRequestVersion = HttpVersion.Version20;
|
||||||
|
|
||||||
|
using ByteArrayContent httpContent = new ByteArrayContent(buildPostString);
|
||||||
|
httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
|
||||||
|
|
||||||
|
var httpTask = httpClient.PostAsync(buildPostSfUrl, httpContent);
|
||||||
|
httpTask.Wait();
|
||||||
|
|
||||||
|
if (!httpTask.Result.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
httpClientHandler.AutomaticDecompression = DecompressionMethods.All;
|
Program.PrintColorMessage($"[UpdateBuildWebService-SF] {httpTask.Result}", ConsoleColor.Red);
|
||||||
httpClientHandler.SslProtocols = SslProtocols.Tls12 | SslProtocols.Tls13;
|
return false;
|
||||||
|
|
||||||
using (HttpClient httpClient = new HttpClient(httpClientHandler))
|
|
||||||
{
|
|
||||||
httpClient.DefaultRequestHeaders.Add("X-ApiKey", buildPostSfApiKey);
|
|
||||||
httpClient.DefaultVersionPolicy = HttpVersionPolicy.RequestVersionOrHigher;
|
|
||||||
httpClient.DefaultRequestVersion = HttpVersion.Version20;
|
|
||||||
|
|
||||||
using (ByteArrayContent httpContent = new ByteArrayContent(buildPostString))
|
|
||||||
{
|
|
||||||
httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
|
|
||||||
|
|
||||||
var httpTask = httpClient.PostAsync(buildPostSfUrl, httpContent);
|
|
||||||
httpTask.Wait();
|
|
||||||
|
|
||||||
if (!httpTask.Result.IsSuccessStatusCode)
|
|
||||||
{
|
|
||||||
Program.PrintColorMessage($"[UpdateBuildWebService-SF] {httpTask.Result}", ConsoleColor.Red);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace CustomBuildTool
|
|||||||
{
|
{
|
||||||
public static class BuildConfig
|
public static class BuildConfig
|
||||||
{
|
{
|
||||||
public static readonly SortedDictionary<string, int> Build_Channels = new SortedDictionary<string, int>()
|
public static readonly SortedDictionary<string, int> Build_Channels = new SortedDictionary<string, int>(StringComparer.OrdinalIgnoreCase)
|
||||||
{
|
{
|
||||||
{ "release", 0 }, // PhReleaseChannel
|
{ "release", 0 }, // PhReleaseChannel
|
||||||
//{ "preview", 1 }, // PhPreviewChannel
|
//{ "preview", 1 }, // PhPreviewChannel
|
||||||
@@ -21,8 +21,8 @@ namespace CustomBuildTool
|
|||||||
//{ "developer", 3 }, // PhDeveloperChannel
|
//{ "developer", 3 }, // PhDeveloperChannel
|
||||||
};
|
};
|
||||||
|
|
||||||
public static readonly BuildFile[] Build_Release_Files =
|
public static readonly ImmutableArray<BuildFile> Build_Release_Files =
|
||||||
{
|
[
|
||||||
new BuildFile("\\systeminformer-build-release-setup.exe", true),
|
new BuildFile("\\systeminformer-build-release-setup.exe", true),
|
||||||
new BuildFile("\\systeminformer-build-release-bin.zip", true),
|
new BuildFile("\\systeminformer-build-release-bin.zip", true),
|
||||||
//new BuildFile("\\systeminformer-build-preview-setup.exe", true),
|
//new BuildFile("\\systeminformer-build-preview-setup.exe", true),
|
||||||
@@ -35,10 +35,10 @@ namespace CustomBuildTool
|
|||||||
new BuildFile("\\systeminformer-build-sdk.zip", false),
|
new BuildFile("\\systeminformer-build-sdk.zip", false),
|
||||||
new BuildFile("\\systeminformer-build-pdb.zip", true),
|
new BuildFile("\\systeminformer-build-pdb.zip", true),
|
||||||
//new BuildFile("\\systeminformer-build-checksums.txt", false),
|
//new BuildFile("\\systeminformer-build-checksums.txt", false),
|
||||||
};
|
];
|
||||||
|
|
||||||
public static readonly string[] Build_Sdk_Directories =
|
public static readonly ImmutableArray<string> Build_Sdk_Directories =
|
||||||
{
|
[
|
||||||
"sdk",
|
"sdk",
|
||||||
"sdk\\include",
|
"sdk\\include",
|
||||||
"sdk\\dbg\\amd64",
|
"sdk\\dbg\\amd64",
|
||||||
@@ -49,12 +49,11 @@ namespace CustomBuildTool
|
|||||||
"sdk\\lib\\arm64",
|
"sdk\\lib\\arm64",
|
||||||
//"sdk\\samples\\SamplePlugin",
|
//"sdk\\samples\\SamplePlugin",
|
||||||
//"sdk\\samples\\SamplePlugin\\bin\\Release32"
|
//"sdk\\samples\\SamplePlugin\\bin\\Release32"
|
||||||
};
|
];
|
||||||
|
|
||||||
public static readonly string[] Build_Phnt_Headers =
|
public static readonly ImmutableArray<string> Build_Phnt_Headers =
|
||||||
{
|
[
|
||||||
"ntbcd.h",
|
"ntbcd.h",
|
||||||
"ntd3dkmt.h",
|
|
||||||
"ntdbg.h",
|
"ntdbg.h",
|
||||||
"ntexapi.h",
|
"ntexapi.h",
|
||||||
"ntgdi.h",
|
"ntgdi.h",
|
||||||
@@ -88,10 +87,10 @@ namespace CustomBuildTool
|
|||||||
"phnt_windows.h",
|
"phnt_windows.h",
|
||||||
"subprocesstag.h",
|
"subprocesstag.h",
|
||||||
"winsta.h"
|
"winsta.h"
|
||||||
};
|
];
|
||||||
|
|
||||||
public static readonly string[] Build_Phlib_Headers =
|
public static readonly ImmutableArray<string> Build_Phlib_Headers =
|
||||||
{
|
[
|
||||||
"appresolver.h",
|
"appresolver.h",
|
||||||
"circbuf.h",
|
"circbuf.h",
|
||||||
"circbuf_h.h",
|
"circbuf_h.h",
|
||||||
@@ -134,14 +133,14 @@ namespace CustomBuildTool
|
|||||||
"treenew.h",
|
"treenew.h",
|
||||||
"verify.h",
|
"verify.h",
|
||||||
"workqueue.h"
|
"workqueue.h"
|
||||||
};
|
];
|
||||||
|
|
||||||
public static readonly string[] Build_Kphlib_Headers =
|
public static readonly ImmutableArray<string> Build_Kphlib_Headers =
|
||||||
{
|
[
|
||||||
"kphapi.h",
|
"kphapi.h",
|
||||||
"kphmsg.h",
|
"kphmsg.h",
|
||||||
"kphmsgdefs.h",
|
"kphmsgdefs.h"
|
||||||
};
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly struct BuildFile
|
public readonly struct BuildFile
|
||||||
@@ -159,5 +158,10 @@ namespace CustomBuildTool
|
|||||||
{
|
{
|
||||||
return this.FileName;
|
return this.FileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return this.FileName.GetHashCode();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<CodePage>65001</CodePage>
|
<CodePage>65001</CodePage>
|
||||||
<ProjectGuid>{CD644DF2-A658-4CBC-9497-CA5DD13CFEC3}</ProjectGuid>
|
<ProjectGuid>{CD644DF2-A658-4CBC-9497-CA5DD13CFEC3}</ProjectGuid>
|
||||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
<!--<TrimmerSingleWarn>false</TrimmerSingleWarn>-->
|
<TrimmerSingleWarn>false</TrimmerSingleWarn>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
@@ -23,9 +23,7 @@
|
|||||||
<EventSourceSupport>false</EventSourceSupport>
|
<EventSourceSupport>false</EventSourceSupport>
|
||||||
<HttpActivityPropagationSupport>false</HttpActivityPropagationSupport>
|
<HttpActivityPropagationSupport>false</HttpActivityPropagationSupport>
|
||||||
<InvariantGlobalization>true</InvariantGlobalization>
|
<InvariantGlobalization>true</InvariantGlobalization>
|
||||||
<MetadataUpdaterSupport>false</MetadataUpdaterSupport>
|
|
||||||
<IlcOptimizationPreference>Size</IlcOptimizationPreference>
|
<IlcOptimizationPreference>Size</IlcOptimizationPreference>
|
||||||
<IlcGenerateStackTraceData>false</IlcGenerateStackTraceData>
|
|
||||||
<UseSystemResourceKeys>true</UseSystemResourceKeys>
|
<UseSystemResourceKeys>true</UseSystemResourceKeys>
|
||||||
<PublishAot>True</PublishAot>
|
<PublishAot>True</PublishAot>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
@@ -44,23 +42,33 @@
|
|||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
<Optimize>False</Optimize>
|
<Optimize>False</Optimize>
|
||||||
|
<MetadataUpdaterSupport>UpdateAndReset</MetadataUpdaterSupport>
|
||||||
|
<IlcGenerateStackTraceData>true</IlcGenerateStackTraceData>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
||||||
<Optimize>False</Optimize>
|
<Optimize>False</Optimize>
|
||||||
|
<MetadataUpdaterSupport>UpdateAndReset</MetadataUpdaterSupport>
|
||||||
|
<IlcGenerateStackTraceData>true</IlcGenerateStackTraceData>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<Optimize>True</Optimize>
|
<Optimize>True</Optimize>
|
||||||
|
<MetadataUpdaterSupport>false</MetadataUpdaterSupport>
|
||||||
|
<IlcGenerateStackTraceData>false</IlcGenerateStackTraceData>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
|
||||||
<Optimize>True</Optimize>
|
<Optimize>True</Optimize>
|
||||||
|
<MetadataUpdaterSupport>false</MetadataUpdaterSupport>
|
||||||
|
<IlcGenerateStackTraceData>false</IlcGenerateStackTraceData>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="app.manifest" />
|
<None Include="app.manifest" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Using Include="System.Buffers" />
|
<Using Include="System.Buffers" />
|
||||||
|
<Using Include="System.Collections.Immutable" />
|
||||||
<Using Include="System.Diagnostics" />
|
<Using Include="System.Diagnostics" />
|
||||||
|
<Using Include="System.Globalization" />
|
||||||
<Using Include="System.IO.Compression" />
|
<Using Include="System.IO.Compression" />
|
||||||
<Using Include="System.Net" />
|
<Using Include="System.Net" />
|
||||||
<Using Include="System.Net.Http.Headers" />
|
<Using Include="System.Net.Http.Headers" />
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ typedef struct _KPH_DYNDATA
|
|||||||
Utils.WriteAllText(sourceFile, GenerateSource(BytesToString(config)));
|
Utils.WriteAllText(sourceFile, GenerateSource(BytesToString(config)));
|
||||||
Program.PrintColorMessage($"Dynamic source -> {sourceFile}", ConsoleColor.Cyan);
|
Program.PrintColorMessage($"Dynamic source -> {sourceFile}", ConsoleColor.Cyan);
|
||||||
|
|
||||||
if (OutDir.Length == 0)
|
if (string.IsNullOrWhiteSpace(OutDir))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
string configFile = $"{OutDir}\\ksidyn.bin";
|
string configFile = $"{OutDir}\\ksidyn.bin";
|
||||||
@@ -287,27 +287,34 @@ typedef struct _KPH_DYNDATA
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
var xml = new XmlDocument();
|
var xml = new XmlDocument();
|
||||||
xml.Load(ManifestFile);
|
|
||||||
var dyn = xml.SelectSingleNode("/dyn");
|
|
||||||
var configs = new List<DynConfig>(10);
|
var configs = new List<DynConfig>(10);
|
||||||
var configNames = new List<string>(10);
|
var configNames = new List<string>(10);
|
||||||
|
var dynConfigType = typeof(DynConfig);
|
||||||
|
|
||||||
foreach (XmlNode data in dyn.SelectNodes("data"))
|
xml.Load(ManifestFile);
|
||||||
|
|
||||||
|
var dyn = xml.SelectSingleNode("/dyn");
|
||||||
|
var dataNodes = dyn?.SelectNodes("data");
|
||||||
|
|
||||||
|
foreach (XmlNode data in dataNodes)
|
||||||
{
|
{
|
||||||
var config = new DynConfig();
|
var config = new DynConfig();
|
||||||
var configName = data.Attributes.GetNamedItem("name").Value;
|
var configName = data.Attributes?.GetNamedItem("name")?.Value;
|
||||||
|
var fieldNodes = data.SelectNodes("field");
|
||||||
|
|
||||||
//Program.PrintColorMessage(configName, ConsoleColor.Cyan);
|
Program.PrintColorMessage(configName, ConsoleColor.Cyan);
|
||||||
|
|
||||||
foreach (XmlNode field in data.SelectNodes("field"))
|
foreach (XmlNode field in fieldNodes)
|
||||||
{
|
{
|
||||||
var value = field.Attributes.GetNamedItem("value").Value;
|
var attributes = field.Attributes;
|
||||||
var name = field.Attributes.GetNamedItem("name").Value;
|
var value = attributes?.GetNamedItem("value")?.Value;
|
||||||
var member = typeof(DynConfig).GetField(name);
|
var name = attributes?.GetNamedItem("name")?.Value;
|
||||||
|
var member = dynConfigType.GetField(name);
|
||||||
|
|
||||||
if (value.StartsWith("0x", StringComparison.OrdinalIgnoreCase))
|
if (value.StartsWith("0x", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
value = Convert.ToUInt64(value, 16).ToString();
|
var hex = value.AsSpan(2, value.Length - 2); // Remove "0x" prefix
|
||||||
|
value = ulong.Parse(hex, NumberStyles.HexNumber, CultureInfo.InvariantCulture).ToString(); // Convert.ToUInt64(value, 16);
|
||||||
}
|
}
|
||||||
else if (value.Equals("-1", StringComparison.OrdinalIgnoreCase) && member.FieldType == typeof(ushort))
|
else if (value.Equals("-1", StringComparison.OrdinalIgnoreCase) && member.FieldType == typeof(ushort))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ namespace CustomBuildTool
|
|||||||
ReleaseTag = Version,
|
ReleaseTag = Version,
|
||||||
Name = Version,
|
Name = Version,
|
||||||
Draft = true,
|
Draft = true,
|
||||||
Prerelease = true
|
GenerateReleaseNotes = true,
|
||||||
|
//Prerelease = true
|
||||||
};
|
};
|
||||||
|
|
||||||
byte[] buildPostString = JsonSerializer.SerializeToUtf8Bytes(buildUpdateRequest, GithubReleasesRequestContext.Default.GithubReleasesRequest);
|
byte[] buildPostString = JsonSerializer.SerializeToUtf8Bytes(buildUpdateRequest, GithubReleasesRequestContext.Default.GithubReleasesRequest);
|
||||||
@@ -205,12 +206,12 @@ namespace CustomBuildTool
|
|||||||
var buildUpdateRequest = new GithubReleasesRequest
|
var buildUpdateRequest = new GithubReleasesRequest
|
||||||
{
|
{
|
||||||
Draft = false,
|
Draft = false,
|
||||||
Prerelease = true
|
//Prerelease = true
|
||||||
};
|
};
|
||||||
|
|
||||||
byte[] buildPostString = JsonSerializer.SerializeToUtf8Bytes(buildUpdateRequest, GithubReleasesRequestContext.Default.GithubReleasesRequest);
|
byte[] buildPostString = JsonSerializer.SerializeToUtf8Bytes(buildUpdateRequest, GithubReleasesRequestContext.Default.GithubReleasesRequest);
|
||||||
|
|
||||||
if (buildPostString == null || buildPostString.LongLength == 0)
|
if (buildPostString.LongLength == 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
using (HttpClientHandler httpClientHandler = new HttpClientHandler())
|
using (HttpClientHandler httpClientHandler = new HttpClientHandler())
|
||||||
|
|||||||
@@ -15,14 +15,14 @@ namespace CustomBuildTool
|
|||||||
public static class HeaderGen
|
public static class HeaderGen
|
||||||
{
|
{
|
||||||
private static readonly string Header = "#ifndef _PH_PHAPPPUB_H\r\n#define _PH_PHAPPPUB_H\r\n\r\n// This file was automatically generated. Do not edit.\r\n\r\n#ifdef __cplusplus\r\nextern \"C\" {\r\n#endif\r\n";
|
private static readonly string Header = "#ifndef _PH_PHAPPPUB_H\r\n#define _PH_PHAPPPUB_H\r\n\r\n// This file was automatically generated. Do not edit.\r\n\r\n#ifdef __cplusplus\r\nextern \"C\" {\r\n#endif\r\n";
|
||||||
private static readonly string Footer = "\r\n#ifdef __cplusplus\r\n}\r\n#endif\r\n\r\n#endif\r\n";
|
private const string Footer = "\r\n#ifdef __cplusplus\r\n}\r\n#endif\r\n\r\n#endif\r\n";
|
||||||
|
|
||||||
private static readonly string BaseDirectory = "SystemInformer\\include";
|
private const string BaseDirectory = "SystemInformer\\include";
|
||||||
private static readonly string OutputFile = "..\\sdk\\phapppub.h";
|
private const string OutputFile = "..\\sdk\\phapppub.h";
|
||||||
|
|
||||||
private static readonly string[] Modes = new[] { "phapppub" };
|
private static readonly string[] Modes = ["phapppub"];
|
||||||
private static readonly string[] Files = new[]
|
private static readonly string[] Files =
|
||||||
{
|
[
|
||||||
"phapp.h",
|
"phapp.h",
|
||||||
"appsup.h",
|
"appsup.h",
|
||||||
"phfwddef.h",
|
"phfwddef.h",
|
||||||
@@ -54,7 +54,7 @@ namespace CustomBuildTool
|
|||||||
"sysinfo.h",
|
"sysinfo.h",
|
||||||
"procgrp.h",
|
"procgrp.h",
|
||||||
"miniinfo.h"
|
"miniinfo.h"
|
||||||
};
|
];
|
||||||
|
|
||||||
private static List<HeaderFile> OrderHeaderFiles(List<HeaderFile> headerFiles)
|
private static List<HeaderFile> OrderHeaderFiles(List<HeaderFile> headerFiles)
|
||||||
{
|
{
|
||||||
@@ -135,38 +135,43 @@ namespace CustomBuildTool
|
|||||||
|
|
||||||
foreach (string name in Files)
|
foreach (string name in Files)
|
||||||
{
|
{
|
||||||
string file = BaseDirectory + Path.DirectorySeparatorChar + name;
|
string file = Path.Join([BaseDirectory, name]);
|
||||||
List<string> lines = File.ReadAllLines(file).ToList();
|
List<string> lines = File.ReadAllLines(file).ToList();
|
||||||
|
|
||||||
headerFiles.Add(name, new HeaderFile
|
headerFiles.Add(name, new HeaderFile(name, lines));
|
||||||
{
|
|
||||||
Name = name,
|
|
||||||
Lines = lines
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (HeaderFile h in headerFiles.Values)
|
foreach (HeaderFile h in headerFiles.Values)
|
||||||
{
|
{
|
||||||
ILookup<bool, Tuple<string, HeaderFile>> partitions = h.Lines.Select(s =>
|
List<KeyValuePair<string, HeaderFile>> partitions = new List<KeyValuePair<string, HeaderFile>>();
|
||||||
|
List<string> dependencies = new List<string>();
|
||||||
|
|
||||||
|
foreach (string line in h.Lines)
|
||||||
{
|
{
|
||||||
string trimmed = s.Trim();
|
string trimmed = line.Trim();
|
||||||
|
|
||||||
if (trimmed.StartsWith("#include <", StringComparison.OrdinalIgnoreCase) && trimmed.EndsWith(">", StringComparison.OrdinalIgnoreCase))
|
if (trimmed.StartsWith("#include <", StringComparison.OrdinalIgnoreCase) && trimmed.EndsWith(">", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
if (headerFiles.TryGetValue(trimmed.Remove(trimmed.Length - 1).Remove(0, "#include <".Length), out HeaderFile d))
|
string dependencyName = trimmed.AsSpan().Slice("#include <".Length, trimmed.Length - 1 - "#include <".Length).ToString();
|
||||||
return Tuple.Create(s, d);
|
|
||||||
|
if (headerFiles.TryGetValue(dependencyName, out HeaderFile dependency))
|
||||||
|
{
|
||||||
|
partitions.Add(new KeyValuePair<string, HeaderFile>(line, dependency));
|
||||||
|
dependencies.Add(dependencyName);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return Tuple.Create<string, HeaderFile>(s, null);
|
{
|
||||||
|
partitions.Add(new KeyValuePair<string, HeaderFile>(line, null));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Tuple.Create<string, HeaderFile>(s, null);
|
else
|
||||||
})
|
{
|
||||||
.ToLookup(p => p.Item2 != null);
|
partitions.Add(new KeyValuePair<string, HeaderFile>(line, null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
h.Lines = partitions[false].Select(p => p.Item1).ToList();
|
h.Lines = partitions.Where(p => p.Value == null).Select(p => p.Key).ToList();
|
||||||
h.Dependencies = partitions[true].Select(p => p.Item2).Distinct().ToList();
|
h.Dependencies = dependencies.Select(dependencyName => headerFiles[dependencyName]).Distinct().ToList();
|
||||||
|
|
||||||
//foreach (var d in h.Dependencies)
|
|
||||||
//Console.WriteLine("Dependency: " + h.Name + " -> " + d.Name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate the ordering.
|
// Generate the ordering.
|
||||||
@@ -187,10 +192,12 @@ namespace CustomBuildTool
|
|||||||
|
|
||||||
// Process each header file and remove irrelevant content.
|
// Process each header file and remove irrelevant content.
|
||||||
foreach (HeaderFile h in orderedHeaderFiles)
|
foreach (HeaderFile h in orderedHeaderFiles)
|
||||||
|
{
|
||||||
h.Lines = ProcessHeaderLines(h.Lines);
|
h.Lines = ProcessHeaderLines(h.Lines);
|
||||||
|
}
|
||||||
|
|
||||||
// Write out the result.
|
// Write out the result.
|
||||||
using (StreamWriter sw = new StreamWriter(BaseDirectory + Path.DirectorySeparatorChar + OutputFile))
|
using (StreamWriter sw = new StreamWriter(Path.Join([BaseDirectory, OutputFile]), false, Utils.UTF8NoBOM))
|
||||||
{
|
{
|
||||||
// Header
|
// Header
|
||||||
sw.Write(Header);
|
sw.Write(Header);
|
||||||
@@ -206,7 +213,9 @@ namespace CustomBuildTool
|
|||||||
sw.WriteLine();
|
sw.WriteLine();
|
||||||
|
|
||||||
foreach (string line in h.Lines)
|
foreach (string line in h.Lines)
|
||||||
|
{
|
||||||
sw.WriteLine(line);
|
sw.WriteLine(line);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Footer
|
// Footer
|
||||||
@@ -217,10 +226,16 @@ namespace CustomBuildTool
|
|||||||
|
|
||||||
public class HeaderFile : IEquatable<HeaderFile>
|
public class HeaderFile : IEquatable<HeaderFile>
|
||||||
{
|
{
|
||||||
public string Name;
|
public readonly string Name;
|
||||||
public List<string> Lines;
|
public List<string> Lines;
|
||||||
public List<HeaderFile> Dependencies;
|
public List<HeaderFile> Dependencies;
|
||||||
|
|
||||||
|
public HeaderFile(string Name, List<string> Lines)
|
||||||
|
{
|
||||||
|
this.Name = Name;
|
||||||
|
this.Lines = Lines;
|
||||||
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return this.Name;
|
return this.Name;
|
||||||
@@ -239,12 +254,12 @@ namespace CustomBuildTool
|
|||||||
if (obj is not HeaderFile file)
|
if (obj is not HeaderFile file)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return this.Name.Equals(file.Name, StringComparison.OrdinalIgnoreCase);
|
return string.Equals(this.Name, file.Name, StringComparison.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Equals(HeaderFile other)
|
public bool Equals(HeaderFile other)
|
||||||
{
|
{
|
||||||
return other != null && this.Name.Equals(other.Name, StringComparison.OrdinalIgnoreCase);
|
return other != null && string.Equals(this.Name, other.Name, StringComparison.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,14 +29,14 @@ namespace CustomBuildTool
|
|||||||
}
|
}
|
||||||
else if (ProgramArgs.ContainsKey("-encrypt"))
|
else if (ProgramArgs.ContainsKey("-encrypt"))
|
||||||
{
|
{
|
||||||
if (!Verify.EncryptFile(ProgramArgs["-input"], ProgramArgs["-output"], ProgramArgs["-secret"]))
|
if (!Verify.EncryptFile(ProgramArgs["-input"], ProgramArgs["-output"], ProgramArgs["-secret"], ProgramArgs["-salt"]))
|
||||||
{
|
{
|
||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ProgramArgs.ContainsKey("-decrypt"))
|
else if (ProgramArgs.ContainsKey("-decrypt"))
|
||||||
{
|
{
|
||||||
if (!Verify.DecryptFile(ProgramArgs["-input"], ProgramArgs["-output"], ProgramArgs["-secret"]))
|
if (!Verify.DecryptFile(ProgramArgs["-input"], ProgramArgs["-output"], ProgramArgs["-secret"], ProgramArgs["-salt"]))
|
||||||
{
|
{
|
||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
}
|
}
|
||||||
@@ -57,9 +57,9 @@ namespace CustomBuildTool
|
|||||||
}
|
}
|
||||||
else if (ProgramArgs.ContainsKey("-sdk"))
|
else if (ProgramArgs.ContainsKey("-sdk"))
|
||||||
{
|
{
|
||||||
Build.SetupBuildEnvironment(false);
|
var flags = BuildFlags.BuildVerbose;
|
||||||
|
|
||||||
BuildFlags flags = BuildFlags.BuildVerbose;
|
Build.SetupBuildEnvironment(false);
|
||||||
|
|
||||||
if (ProgramArgs.ContainsKey("-Debug"))
|
if (ProgramArgs.ContainsKey("-Debug"))
|
||||||
{
|
{
|
||||||
@@ -124,17 +124,15 @@ namespace CustomBuildTool
|
|||||||
}
|
}
|
||||||
else if (ProgramArgs.ContainsKey("-bin"))
|
else if (ProgramArgs.ContainsKey("-bin"))
|
||||||
{
|
{
|
||||||
BuildFlags flags =
|
|
||||||
BuildFlags.Build32bit | BuildFlags.Build64bit | BuildFlags.BuildArm64bit |
|
|
||||||
BuildFlags.BuildVerbose | BuildFlags.BuildApi;
|
|
||||||
|
|
||||||
Build.SetupBuildEnvironment(false);
|
Build.SetupBuildEnvironment(false);
|
||||||
|
|
||||||
if (!Build.BuildSolution("SystemInformer.sln", flags))
|
if (!Build.BuildSolution("SystemInformer.sln", BuildFlags.Release))
|
||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
if (!Build.BuildSolution("plugins\\Plugins.sln", flags))
|
if (!Build.BuildSolution("plugins\\Plugins.sln", BuildFlags.Release))
|
||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
|
|
||||||
|
if (!Build.CopyDebugEngineFiles(BuildFlags.Release))
|
||||||
|
Environment.Exit(1);
|
||||||
if (!Build.CopyTextFiles(true))
|
if (!Build.CopyTextFiles(true))
|
||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
|
|
||||||
@@ -149,25 +147,21 @@ namespace CustomBuildTool
|
|||||||
}
|
}
|
||||||
else if (ProgramArgs.ContainsKey("-debug"))
|
else if (ProgramArgs.ContainsKey("-debug"))
|
||||||
{
|
{
|
||||||
BuildFlags flags =
|
|
||||||
BuildFlags.Build32bit | BuildFlags.Build64bit | BuildFlags.BuildArm64bit |
|
|
||||||
BuildFlags.BuildVerbose | BuildFlags.BuildApi;
|
|
||||||
|
|
||||||
Build.SetupBuildEnvironment(true);
|
Build.SetupBuildEnvironment(true);
|
||||||
|
|
||||||
if (!Build.BuildSolution("SystemInformer.sln", flags))
|
if (!Build.BuildSolution("SystemInformer.sln", BuildFlags.Debug))
|
||||||
return;
|
return;
|
||||||
if (!Build.BuildSolution("plugins\\Plugins.sln", flags))
|
if (!Build.BuildSolution("plugins\\Plugins.sln", BuildFlags.Debug))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!Build.CopyDebugEngineFiles(BuildFlags.Debug))
|
||||||
|
Environment.Exit(1);
|
||||||
|
|
||||||
Build.ShowBuildStats();
|
Build.ShowBuildStats();
|
||||||
}
|
}
|
||||||
else if (ProgramArgs.ContainsKey("-pipeline-build"))
|
else if (ProgramArgs.ContainsKey("-pipeline-build"))
|
||||||
{
|
{
|
||||||
BuildFlags flags =
|
BuildFlags flags = BuildFlags.Release;
|
||||||
BuildFlags.Build32bit | BuildFlags.Build64bit | BuildFlags.BuildArm64bit |
|
|
||||||
BuildFlags.BuildRelease | BuildFlags.BuildVerbose |
|
|
||||||
BuildFlags.BuildApi;
|
|
||||||
|
|
||||||
if (ProgramArgs.ContainsKey("-msix-build"))
|
if (ProgramArgs.ContainsKey("-msix-build"))
|
||||||
flags |= BuildFlags.BuildMsix;
|
flags |= BuildFlags.BuildMsix;
|
||||||
@@ -178,7 +172,6 @@ namespace CustomBuildTool
|
|||||||
|
|
||||||
if (!Build.BuildSolution("SystemInformer.sln", flags))
|
if (!Build.BuildSolution("SystemInformer.sln", flags))
|
||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
|
|
||||||
if (!Build.BuildSolution("plugins\\Plugins.sln", flags))
|
if (!Build.BuildSolution("plugins\\Plugins.sln", flags))
|
||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
|
|
||||||
@@ -190,6 +183,8 @@ namespace CustomBuildTool
|
|||||||
|
|
||||||
if (!Build.ResignFiles())
|
if (!Build.ResignFiles())
|
||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
|
if (!Build.CopyDebugEngineFiles(BuildFlags.Release))
|
||||||
|
Environment.Exit(1);
|
||||||
if (!Build.CopyTextFiles(true))
|
if (!Build.CopyTextFiles(true))
|
||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
|
|
||||||
@@ -229,10 +224,11 @@ namespace CustomBuildTool
|
|||||||
|
|
||||||
if (!Build.BuildSolution("SystemInformer.sln", flags))
|
if (!Build.BuildSolution("SystemInformer.sln", flags))
|
||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
|
|
||||||
if (!Build.BuildSolution("plugins\\Plugins.sln", flags))
|
if (!Build.BuildSolution("plugins\\Plugins.sln", flags))
|
||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
|
|
||||||
|
if (!Build.CopyDebugEngineFiles(flags))
|
||||||
|
Environment.Exit(1);
|
||||||
if (!Build.CopyWow64Files(flags)) // required after plugin build (dmex)
|
if (!Build.CopyWow64Files(flags)) // required after plugin build (dmex)
|
||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
if (!Build.CopyTextFiles(true))
|
if (!Build.CopyTextFiles(true))
|
||||||
@@ -248,19 +244,21 @@ namespace CustomBuildTool
|
|||||||
{
|
{
|
||||||
BuildFlags flags =
|
BuildFlags flags =
|
||||||
BuildFlags.Build32bit | BuildFlags.Build64bit | BuildFlags.BuildArm64bit |
|
BuildFlags.Build32bit | BuildFlags.Build64bit | BuildFlags.BuildArm64bit |
|
||||||
BuildFlags.BuildVerbose | BuildFlags.BuildApi;
|
BuildFlags.BuildRelease | BuildFlags.BuildVerbose | BuildFlags.BuildApi;
|
||||||
|
|
||||||
Build.SetupBuildEnvironment(true);
|
Build.SetupBuildEnvironment(true);
|
||||||
|
|
||||||
if (!Build.BuildSolution("SystemInformer.sln", flags))
|
if (!Build.BuildSolution("SystemInformer.sln", flags))
|
||||||
return;
|
Environment.Exit(1);
|
||||||
if (!Build.BuildSolution("plugins\\Plugins.sln", flags))
|
if (!Build.BuildSolution("plugins\\Plugins.sln", flags))
|
||||||
return;
|
Environment.Exit(1);
|
||||||
|
|
||||||
|
if (!Build.CopyDebugEngineFiles(flags))
|
||||||
|
Environment.Exit(1);
|
||||||
if (!Build.CopyWow64Files(flags))
|
if (!Build.CopyWow64Files(flags))
|
||||||
return;
|
Environment.Exit(1);
|
||||||
if (!Build.CopyTextFiles(true))
|
if (!Build.CopyTextFiles(true))
|
||||||
return;
|
Environment.Exit(1);
|
||||||
|
|
||||||
foreach (var (channel, _) in BuildConfig.Build_Channels)
|
foreach (var (channel, _) in BuildConfig.Build_Channels)
|
||||||
{
|
{
|
||||||
@@ -291,5 +289,18 @@ namespace CustomBuildTool
|
|||||||
Console.Write(Message);
|
Console.Write(Message);
|
||||||
Console.ResetColor();
|
Console.ResetColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void PrintColorMessage(LogInterpolatedStringHandler builder, ConsoleColor Color, bool Newline = true, BuildFlags Flags = BuildFlags.BuildVerbose)
|
||||||
|
{
|
||||||
|
if ((Flags & BuildFlags.BuildVerbose) != BuildFlags.BuildVerbose)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Console.ForegroundColor = Color;
|
||||||
|
if (Newline)
|
||||||
|
Console.WriteLine(builder.GetFormattedText());
|
||||||
|
else
|
||||||
|
Console.Write(builder.GetFormattedText());
|
||||||
|
Console.ResetColor();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+120
-35
@@ -94,9 +94,40 @@ namespace CustomBuildTool
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool SetCurrentDirectoryParent(string FileName)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
DirectoryInfo info = new DirectoryInfo(".");
|
||||||
|
|
||||||
|
while (info.Parent?.Parent != null)
|
||||||
|
{
|
||||||
|
info = info.Parent;
|
||||||
|
|
||||||
|
if (File.Exists($"{info.FullName}\\{FileName}"))
|
||||||
|
{
|
||||||
|
Directory.SetCurrentDirectory(info.FullName);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Program.PrintColorMessage($"Unable to find directory: {ex}", ConsoleColor.Red);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return File.Exists(FileName);
|
||||||
|
}
|
||||||
|
|
||||||
public static string GetOutputDirectoryPath()
|
public static string GetOutputDirectoryPath()
|
||||||
{
|
{
|
||||||
return $"{Build.BuildWorkingFolder}\\build\\output";
|
return GetPath("\\build\\output");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetPath(string FileName)
|
||||||
|
{
|
||||||
|
return Path.Combine([Build.BuildWorkingFolder, FileName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void CreateOutputDirectory()
|
public static void CreateOutputDirectory()
|
||||||
@@ -121,15 +152,15 @@ namespace CustomBuildTool
|
|||||||
if (string.IsNullOrWhiteSpace(VsWhereFilePath))
|
if (string.IsNullOrWhiteSpace(VsWhereFilePath))
|
||||||
{
|
{
|
||||||
string[] vswherePathArray =
|
string[] vswherePathArray =
|
||||||
{
|
[
|
||||||
"%ProgramFiles%\\Microsoft Visual Studio\\Installer\\vswhere.exe",
|
"%ProgramFiles%\\Microsoft Visual Studio\\Installer\\vswhere.exe",
|
||||||
"%ProgramFiles(x86)%\\Microsoft Visual Studio\\Installer\\vswhere.exe",
|
"%ProgramFiles(x86)%\\Microsoft Visual Studio\\Installer\\vswhere.exe",
|
||||||
"%ProgramW6432%\\Microsoft Visual Studio\\Installer\\vswhere.exe"
|
"%ProgramW6432%\\Microsoft Visual Studio\\Installer\\vswhere.exe"
|
||||||
};
|
];
|
||||||
|
|
||||||
foreach (string path in vswherePathArray)
|
foreach (string path in vswherePathArray)
|
||||||
{
|
{
|
||||||
string file = Environment.ExpandEnvironmentVariables(path);
|
string file = Utils.ExpandFullPath(path);
|
||||||
|
|
||||||
if (File.Exists(file))
|
if (File.Exists(file))
|
||||||
{
|
{
|
||||||
@@ -157,11 +188,11 @@ namespace CustomBuildTool
|
|||||||
if (string.IsNullOrWhiteSpace(MsBuildFilePath))
|
if (string.IsNullOrWhiteSpace(MsBuildFilePath))
|
||||||
{
|
{
|
||||||
string[] MsBuildPathArray =
|
string[] MsBuildPathArray =
|
||||||
{
|
[
|
||||||
"\\MSBuild\\Current\\Bin\\amd64\\MSBuild.exe",
|
"\\MSBuild\\Current\\Bin\\amd64\\MSBuild.exe",
|
||||||
"\\MSBuild\\Current\\Bin\\MSBuild.exe",
|
"\\MSBuild\\Current\\Bin\\MSBuild.exe",
|
||||||
"\\MSBuild\\15.0\\Bin\\MSBuild.exe"
|
"\\MSBuild\\15.0\\Bin\\MSBuild.exe"
|
||||||
};
|
];
|
||||||
|
|
||||||
VisualStudioInstance instance = VisualStudio.GetVisualStudioInstance();
|
VisualStudioInstance instance = VisualStudio.GetVisualStudioInstance();
|
||||||
|
|
||||||
@@ -215,15 +246,15 @@ namespace CustomBuildTool
|
|||||||
if (string.IsNullOrWhiteSpace(GitFilePath))
|
if (string.IsNullOrWhiteSpace(GitFilePath))
|
||||||
{
|
{
|
||||||
string[] GitPathArray =
|
string[] GitPathArray =
|
||||||
{
|
[
|
||||||
"%ProgramFiles%\\Git\\bin\\git.exe",
|
"%ProgramFiles%\\Git\\bin\\git.exe",
|
||||||
"%ProgramFiles(x86)%\\Git\\bin\\git.exe",
|
"%ProgramFiles(x86)%\\Git\\bin\\git.exe",
|
||||||
"%ProgramW6432%\\Git\\bin\\git.exe"
|
"%ProgramW6432%\\Git\\bin\\git.exe"
|
||||||
};
|
];
|
||||||
|
|
||||||
foreach (string path in GitPathArray)
|
foreach (string path in GitPathArray)
|
||||||
{
|
{
|
||||||
string file = Environment.ExpandEnvironmentVariables(path);
|
string file = Utils.ExpandFullPath(path);
|
||||||
|
|
||||||
if (File.Exists(file))
|
if (File.Exists(file))
|
||||||
{
|
{
|
||||||
@@ -284,7 +315,7 @@ namespace CustomBuildTool
|
|||||||
{
|
{
|
||||||
List<KeyValuePair<Version, string>> versionList = new List<KeyValuePair<Version, string>>();
|
List<KeyValuePair<Version, string>> versionList = new List<KeyValuePair<Version, string>>();
|
||||||
string kitsRoot = Win32.GetKeyValue(true, "Software\\Microsoft\\Windows Kits\\Installed Roots", "KitsRoot10", "%ProgramFiles(x86)%\\Windows Kits\\10\\");
|
string kitsRoot = Win32.GetKeyValue(true, "Software\\Microsoft\\Windows Kits\\Installed Roots", "KitsRoot10", "%ProgramFiles(x86)%\\Windows Kits\\10\\");
|
||||||
string kitsPath = Environment.ExpandEnvironmentVariables($"{kitsRoot}\\Include");
|
string kitsPath = Utils.ExpandFullPath(Path.Join([kitsRoot, "\\Include"]));
|
||||||
|
|
||||||
if (Directory.Exists(kitsPath))
|
if (Directory.Exists(kitsPath))
|
||||||
{
|
{
|
||||||
@@ -320,7 +351,7 @@ namespace CustomBuildTool
|
|||||||
{
|
{
|
||||||
List<KeyValuePair<Version, string>> versionList = new List<KeyValuePair<Version, string>>();
|
List<KeyValuePair<Version, string>> versionList = new List<KeyValuePair<Version, string>>();
|
||||||
string kitsRoot = Win32.GetKeyValue(true, "Software\\Microsoft\\Windows Kits\\Installed Roots", "KitsRoot10", "%ProgramFiles(x86)%\\Windows Kits\\10\\");
|
string kitsRoot = Win32.GetKeyValue(true, "Software\\Microsoft\\Windows Kits\\Installed Roots", "KitsRoot10", "%ProgramFiles(x86)%\\Windows Kits\\10\\");
|
||||||
string kitsPath = Environment.ExpandEnvironmentVariables($"{kitsRoot}\\bin");
|
string kitsPath = Utils.ExpandFullPath(Path.Join([kitsRoot, "\\bin"]));
|
||||||
|
|
||||||
if (Directory.Exists(kitsPath))
|
if (Directory.Exists(kitsPath))
|
||||||
{
|
{
|
||||||
@@ -328,7 +359,7 @@ namespace CustomBuildTool
|
|||||||
|
|
||||||
foreach (string path in windowsKitsDirectory)
|
foreach (string path in windowsKitsDirectory)
|
||||||
{
|
{
|
||||||
string name = Path.GetFileName(path);
|
var name = Path.GetFileName(path);
|
||||||
|
|
||||||
if (Version.TryParse(name, out var version))
|
if (Version.TryParse(name, out var version))
|
||||||
{
|
{
|
||||||
@@ -340,7 +371,7 @@ namespace CustomBuildTool
|
|||||||
|
|
||||||
if (versionList.Count > 0)
|
if (versionList.Count > 0)
|
||||||
{
|
{
|
||||||
var result = versionList[versionList.Count - 1];
|
var result = versionList[^1];
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(result.Value))
|
if (!string.IsNullOrWhiteSpace(result.Value))
|
||||||
{
|
{
|
||||||
@@ -354,9 +385,9 @@ namespace CustomBuildTool
|
|||||||
|
|
||||||
public static string GetWindowsSdkVersion()
|
public static string GetWindowsSdkVersion()
|
||||||
{
|
{
|
||||||
List<string> versions = new List<string>();
|
List<KeyValuePair<Version, string>> versionList = new List<KeyValuePair<Version, string>>();
|
||||||
string kitsRoot = Win32.GetKeyValue(true, "Software\\Microsoft\\Windows Kits\\Installed Roots", "KitsRoot10", "%ProgramFiles(x86)%\\Windows Kits\\10\\");
|
string kitsRoot = Win32.GetKeyValue(true, "Software\\Microsoft\\Windows Kits\\Installed Roots", "KitsRoot10", "%ProgramFiles(x86)%\\Windows Kits\\10\\");
|
||||||
string kitsPath = Environment.ExpandEnvironmentVariables($"{kitsRoot}\\bin");
|
string kitsPath = Utils.ExpandFullPath(Path.Join([kitsRoot, "\\bin"]));
|
||||||
|
|
||||||
if (Directory.Exists(kitsPath))
|
if (Directory.Exists(kitsPath))
|
||||||
{
|
{
|
||||||
@@ -364,29 +395,24 @@ namespace CustomBuildTool
|
|||||||
|
|
||||||
foreach (string path in windowsKitsDirectory)
|
foreach (string path in windowsKitsDirectory)
|
||||||
{
|
{
|
||||||
string name = Path.GetFileName(path);
|
var name = Path.GetFileName(path.AsSpan());
|
||||||
|
|
||||||
if (Version.TryParse(name, out _))
|
if (Version.TryParse(name, out var version))
|
||||||
{
|
{
|
||||||
versions.Add(name);
|
versionList.Add(new KeyValuePair<Version, string>(version, path));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
versions.Sort((p1, p2) =>
|
versionList.Sort((first, second) => first.Key.CompareTo(second.Key));
|
||||||
{
|
|
||||||
if (Version.TryParse(p1, out Version v1) && Version.TryParse(p2, out Version v2))
|
|
||||||
return v1.CompareTo(v2);
|
|
||||||
else
|
|
||||||
return 1;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (versions.Count > 0)
|
if (versionList.Count > 0)
|
||||||
{
|
{
|
||||||
string result = versions[^1];
|
var result = versionList[^1];
|
||||||
|
var value = result.Key.ToString();
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(result))
|
if (!string.IsNullOrWhiteSpace(value))
|
||||||
{
|
{
|
||||||
return result;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -409,14 +435,14 @@ namespace CustomBuildTool
|
|||||||
return string.Empty;
|
return string.Empty;
|
||||||
|
|
||||||
DirectoryInfo info = new DirectoryInfo(directory);
|
DirectoryInfo info = new DirectoryInfo(directory);
|
||||||
|
|
||||||
while (info.Parent != null && info.Parent.Parent != null)
|
while (info.Parent != null && info.Parent.Parent != null)
|
||||||
{
|
{
|
||||||
info = info.Parent;
|
info = info.Parent;
|
||||||
|
|
||||||
if (File.Exists($"{info.FullName}\\Common7\\IDE\\devenv.exe"))
|
if (File.Exists(Path.Join([info.FullName, "\\Common7\\IDE\\devenv.exe"])))
|
||||||
{
|
{
|
||||||
FileVersionInfo currentInfo = FileVersionInfo.GetVersionInfo($"{info.FullName}\\Common7\\IDE\\devenv.exe");
|
FileVersionInfo currentInfo = FileVersionInfo.GetVersionInfo(Path.Join([info.FullName, "\\Common7\\IDE\\devenv.exe"]));
|
||||||
return currentInfo.ProductVersion ?? string.Empty;
|
return currentInfo.ProductVersion ?? string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -436,7 +462,7 @@ namespace CustomBuildTool
|
|||||||
if (string.IsNullOrWhiteSpace(windowsSdkPath))
|
if (string.IsNullOrWhiteSpace(windowsSdkPath))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
string makeAppxPath = $"{windowsSdkPath}\\x64\\MakeAppx.exe";
|
string makeAppxPath = Path.Join([windowsSdkPath, "\\x64\\MakeAppx.exe"]);
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(makeAppxPath))
|
if (string.IsNullOrWhiteSpace(makeAppxPath))
|
||||||
return null;
|
return null;
|
||||||
@@ -448,7 +474,7 @@ namespace CustomBuildTool
|
|||||||
if (string.IsNullOrWhiteSpace(sdkRootPath))
|
if (string.IsNullOrWhiteSpace(sdkRootPath))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
makeAppxPath = Environment.ExpandEnvironmentVariables($"{sdkRootPath}\\x64\\MakeAppx.exe");
|
makeAppxPath = Utils.ExpandFullPath(Path.Join([sdkRootPath, "\\x64\\MakeAppx.exe"]));
|
||||||
|
|
||||||
if (!File.Exists(makeAppxPath))
|
if (!File.Exists(makeAppxPath))
|
||||||
return null;
|
return null;
|
||||||
@@ -479,7 +505,7 @@ namespace CustomBuildTool
|
|||||||
if (string.IsNullOrWhiteSpace(windowsSdkPath))
|
if (string.IsNullOrWhiteSpace(windowsSdkPath))
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
|
|
||||||
string signToolPath = $"{windowsSdkPath}\\x64\\SignTool.exe";
|
string signToolPath = Path.Join([windowsSdkPath, "\\x64\\SignTool.exe"]);
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(signToolPath))
|
if (string.IsNullOrWhiteSpace(signToolPath))
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
@@ -618,6 +644,27 @@ namespace CustomBuildTool
|
|||||||
stream.CopyTo(filestream);
|
stream.CopyTo(filestream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsSpanNullOrWhiteSpace(ReadOnlySpan<char> value)
|
||||||
|
{
|
||||||
|
if (value == null)
|
||||||
|
return true;
|
||||||
|
if (value.IsEmpty)
|
||||||
|
return true;
|
||||||
|
if (value.IsWhiteSpace())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string ExpandFullPath(string Name)
|
||||||
|
{
|
||||||
|
string value = Environment.ExpandEnvironmentVariables(Name);
|
||||||
|
|
||||||
|
value = Path.GetFullPath(value);
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BuildUpdateRequest
|
public class BuildUpdateRequest
|
||||||
@@ -770,5 +817,43 @@ namespace CustomBuildTool
|
|||||||
BuildVerbose = 32,
|
BuildVerbose = 32,
|
||||||
BuildApi = 64,
|
BuildApi = 64,
|
||||||
BuildMsix = 128,
|
BuildMsix = 128,
|
||||||
|
|
||||||
|
Debug = Build32bit | Build64bit | BuildArm64bit | BuildDebug | BuildApi | BuildVerbose,
|
||||||
|
Release = Build32bit | Build64bit | BuildArm64bit | BuildRelease | BuildApi | BuildVerbose,
|
||||||
|
All = Build32bit | Build64bit | BuildArm64bit | BuildDebug | BuildRelease | BuildApi | BuildVerbose,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/tutorials/interpolated-string-handler
|
||||||
|
/// </summary>
|
||||||
|
[InterpolatedStringHandler]
|
||||||
|
public readonly ref struct LogInterpolatedStringHandler
|
||||||
|
{
|
||||||
|
public readonly StringBuilder builder;
|
||||||
|
|
||||||
|
public LogInterpolatedStringHandler(int literalLength, int formattedCount)
|
||||||
|
{
|
||||||
|
builder = new StringBuilder(literalLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AppendLiteral(string s)
|
||||||
|
{
|
||||||
|
builder.Append(s.AsSpan());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AppendFormatted<T>(T t)
|
||||||
|
{
|
||||||
|
builder.Append(t?.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AppendFormatted<T>(T t, string format) where T : IFormattable
|
||||||
|
{
|
||||||
|
builder.Append(t?.ToString(format, null));
|
||||||
|
}
|
||||||
|
|
||||||
|
internal string GetFormattedText()
|
||||||
|
{
|
||||||
|
return builder.ToString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,21 +13,21 @@ namespace CustomBuildTool
|
|||||||
{
|
{
|
||||||
public static class Verify
|
public static class Verify
|
||||||
{
|
{
|
||||||
public static readonly SortedDictionary<string, string> KeyName_Vars = new SortedDictionary<string, string>()
|
public static readonly SortedDictionary<string, KeyValuePair<string, string>> KeyName_Vars = new(StringComparer.OrdinalIgnoreCase)
|
||||||
{
|
{
|
||||||
{ "kph", "KPH_BUILD_KEY" },
|
{ "kph", new("KPH_BUILD_KEY", "KPH_BUILD_SALT")},
|
||||||
{ "release", "RELEASE_BUILD_KEY" },
|
{ "release", new("RELEASE_BUILD_KEY", "RELEASE_BUILD_SALT")},
|
||||||
{ "preview", "PREVIEW_BUILD_KEY" },
|
{ "preview", new("PREVIEW_BUILD_KEY", "PREVIEW_BUILD_SALT")},
|
||||||
{ "canary", "CANARY_BUILD_KEY" },
|
{ "canary", new("CANARY_BUILD_KEY", "CANARY_BUILD_SALT")},
|
||||||
{ "developer", "DEVELOPER_BUILD_KEY" },
|
{ "developer", new("DEVELOPER_BUILD_KEY", "DEVELOPER_BUILD_SALT")},
|
||||||
};
|
};
|
||||||
|
|
||||||
public static bool EncryptFile(string FileName, string OutFileName, string Secret)
|
public static bool EncryptFile(string FileName, string OutFileName, string Secret, string Salt)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var fileBytes = Utils.ReadAllBytes(FileName);
|
var fileBytes = Utils.ReadAllBytes(FileName);
|
||||||
var encryptedBytes = Encrypt(fileBytes, Secret);
|
var encryptedBytes = Encrypt(fileBytes, Secret, Salt);
|
||||||
Utils.WriteAllBytes(OutFileName, encryptedBytes);
|
Utils.WriteAllBytes(OutFileName, encryptedBytes);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -39,12 +39,12 @@ namespace CustomBuildTool
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool DecryptFile(string FileName, string OutFileName, string Secret)
|
public static bool DecryptFile(string FileName, string OutFileName, string Secret, string Salt)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var fileBytes = Utils.ReadAllBytes(FileName);
|
var fileBytes = Utils.ReadAllBytes(FileName);
|
||||||
var decryptedBytes = Decrypt(fileBytes, Secret);
|
var decryptedBytes = Decrypt(fileBytes, Secret, Salt);
|
||||||
Utils.WriteAllBytes(OutFileName, decryptedBytes);
|
Utils.WriteAllBytes(OutFileName, decryptedBytes);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -135,7 +135,7 @@ namespace CustomBuildTool
|
|||||||
return !string.IsNullOrWhiteSpace(Signature);
|
return !string.IsNullOrWhiteSpace(Signature);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] Encrypt(byte[] Bytes, string Secret)
|
private static byte[] Encrypt(byte[] Bytes, string Secret, string Salt)
|
||||||
{
|
{
|
||||||
byte[] buffer = ArrayPool<byte>.Shared.Rent(0x1000);
|
byte[] buffer = ArrayPool<byte>.Shared.Rent(0x1000);
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ namespace CustomBuildTool
|
|||||||
{
|
{
|
||||||
using (MemoryStream memoryStream = new MemoryStream(buffer, 0, 0x1000, true, true))
|
using (MemoryStream memoryStream = new MemoryStream(buffer, 0, 0x1000, true, true))
|
||||||
{
|
{
|
||||||
using (var rijndael = GetRijndael(Secret))
|
using (var rijndael = GetRijndael(Secret, Salt))
|
||||||
using (var cryptoEncrypt = rijndael.CreateEncryptor())
|
using (var cryptoEncrypt = rijndael.CreateEncryptor())
|
||||||
using (MemoryStream blobStream = new MemoryStream(Bytes))
|
using (MemoryStream blobStream = new MemoryStream(Bytes))
|
||||||
using (CryptoStream cryptoStream = new CryptoStream(memoryStream, cryptoEncrypt, CryptoStreamMode.Write, true))
|
using (CryptoStream cryptoStream = new CryptoStream(memoryStream, cryptoEncrypt, CryptoStreamMode.Write, true))
|
||||||
@@ -168,7 +168,7 @@ namespace CustomBuildTool
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] Decrypt(byte[] Bytes, string Secret)
|
private static byte[] Decrypt(byte[] Bytes, string Secret, string Salt)
|
||||||
{
|
{
|
||||||
byte[] buffer = ArrayPool<byte>.Shared.Rent(0x1000);
|
byte[] buffer = ArrayPool<byte>.Shared.Rent(0x1000);
|
||||||
|
|
||||||
@@ -176,7 +176,7 @@ namespace CustomBuildTool
|
|||||||
{
|
{
|
||||||
using (MemoryStream memoryStream = new MemoryStream(buffer, 0, 0x1000, true, true))
|
using (MemoryStream memoryStream = new MemoryStream(buffer, 0, 0x1000, true, true))
|
||||||
{
|
{
|
||||||
using (var rijndael = GetRijndael(Secret))
|
using (var rijndael = GetRijndael(Secret, Salt))
|
||||||
using (var cryptoDecrypt = rijndael.CreateDecryptor())
|
using (var cryptoDecrypt = rijndael.CreateDecryptor())
|
||||||
using (MemoryStream blobStream = new MemoryStream(Bytes))
|
using (MemoryStream blobStream = new MemoryStream(Bytes))
|
||||||
using (CryptoStream cryptoStream = new CryptoStream(memoryStream, cryptoDecrypt, CryptoStreamMode.Write, true))
|
using (CryptoStream cryptoStream = new CryptoStream(memoryStream, cryptoDecrypt, CryptoStreamMode.Write, true))
|
||||||
@@ -201,7 +201,7 @@ namespace CustomBuildTool
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Aes GetRijndael(string Secret)
|
private static Aes GetRijndael(string Secret, string Salt)
|
||||||
{
|
{
|
||||||
using (Rfc2898DeriveBytes rfc2898DeriveBytes = new Rfc2898DeriveBytes(
|
using (Rfc2898DeriveBytes rfc2898DeriveBytes = new Rfc2898DeriveBytes(
|
||||||
Secret,
|
Secret,
|
||||||
@@ -234,15 +234,18 @@ namespace CustomBuildTool
|
|||||||
|
|
||||||
private static string GetPath(string FileName)
|
private static string GetPath(string FileName)
|
||||||
{
|
{
|
||||||
return $"{Build.BuildWorkingFolder}\\tools\\CustomSignTool\\Resources\\{FileName}";
|
return Path.Combine([Build.BuildWorkingFolder, "\\tools\\CustomSignTool\\Resources\\", FileName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool GetKeyMaterial(string KeyName, out byte[] KeyMaterial)
|
private static bool GetKeyMaterial(string KeyName, out byte[] KeyMaterial)
|
||||||
{
|
{
|
||||||
if (Win32.GetEnvironmentVariable(KeyName_Vars[KeyName], out string secret))
|
if (
|
||||||
|
Win32.GetEnvironmentVariable(KeyName_Vars[KeyName].Key, out string secret) &&
|
||||||
|
Win32.GetEnvironmentVariable(KeyName_Vars[KeyName].Value, out string salt)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
byte[] bytes = Utils.ReadAllBytes(GetPath($"{KeyName}.s"));
|
byte[] bytes = Utils.ReadAllBytes(GetPath($"{KeyName}.s"));
|
||||||
KeyMaterial = Decrypt(bytes, secret);
|
KeyMaterial = Decrypt(bytes, secret, salt);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (File.Exists(GetPath($"{KeyName}.key")))
|
else if (File.Exists(GetPath($"{KeyName}.key")))
|
||||||
|
|||||||
@@ -240,35 +240,35 @@ namespace CustomBuildTool
|
|||||||
|
|
||||||
// https://learn.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-community
|
// https://learn.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-community
|
||||||
|
|
||||||
this.HasARM64BuildToolsComponents =
|
this.HasARM64BuildToolsComponents = this.Packages.Any(p =>
|
||||||
this.Packages.Any(p => p.Id.Equals("Microsoft.VisualStudio.Component.VC.Tools.ARM64", StringComparison.OrdinalIgnoreCase)) &&
|
{
|
||||||
this.Packages.Any(p => p.Id.Equals("Microsoft.VisualStudio.Component.VC.Runtimes.ARM64.Spectre", StringComparison.OrdinalIgnoreCase));
|
return p.Id.AsSpan().Equals("Microsoft.VisualStudio.Component.VC.Tools.ARM64", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
p.Id.AsSpan().Equals("Microsoft.VisualStudio.Component.VC.Runtimes.ARM64.Spectre", StringComparison.OrdinalIgnoreCase);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//private VisualStudioPackage GetLatestSdkPackage()
|
private VisualStudioPackage GetLatestSdkPackage()
|
||||||
//{
|
{
|
||||||
// var found = this.Packages.FindAll(p =>
|
var found = this.Packages.FindAll(p =>
|
||||||
// {
|
{
|
||||||
// return p.Id.StartsWith("Microsoft.VisualStudio.Component.Windows10SDK", StringComparison.OrdinalIgnoreCase) ||
|
return p.Id.AsSpan().StartsWith("Microsoft.VisualStudio.Component.Windows10SDK", StringComparison.OrdinalIgnoreCase) ||
|
||||||
// p.Id.StartsWith("Microsoft.VisualStudio.Component.Windows11SDK", StringComparison.OrdinalIgnoreCase);
|
p.Id.AsSpan().StartsWith("Microsoft.VisualStudio.Component.Windows11SDK", StringComparison.OrdinalIgnoreCase);
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// if (found == null)
|
if (found.Count == 0)
|
||||||
// return null;
|
return null;
|
||||||
// if (found.Count == 0)
|
|
||||||
// return null;
|
found.Sort((p1, p2) =>
|
||||||
//
|
{
|
||||||
// found.Sort((p1, p2) =>
|
if (Version.TryParse(p1.Version, out Version v1) && Version.TryParse(p2.Version, out Version v2))
|
||||||
// {
|
return v1.CompareTo(v2);
|
||||||
// if (Version.TryParse(p1.Version, out Version v1) && Version.TryParse(p2.Version, out Version v2))
|
else
|
||||||
// return v1.CompareTo(v2);
|
return 1;
|
||||||
// else
|
});
|
||||||
// return 1;
|
|
||||||
// });
|
return found[^1];
|
||||||
//
|
}
|
||||||
// return found[^1];
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//public string GetWindowsSdkVersion()
|
//public string GetWindowsSdkVersion()
|
||||||
//{
|
//{
|
||||||
// List<string> versions = new List<string>();
|
// List<string> versions = new List<string>();
|
||||||
@@ -315,16 +315,13 @@ namespace CustomBuildTool
|
|||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//public string GetWindowsSdkFullVersion()
|
public string GetWindowsSdkFullVersion()
|
||||||
//{
|
{
|
||||||
// VisualStudioPackage package = GetLatestSdkPackage();
|
VisualStudioPackage package = GetLatestSdkPackage();
|
||||||
//
|
|
||||||
// if (package == null)
|
return package == null ? string.Empty : package.Version;
|
||||||
// return string.Empty;
|
}
|
||||||
//
|
|
||||||
// return package.Version;
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//public bool HasRequiredDependency
|
//public bool HasRequiredDependency
|
||||||
//{
|
//{
|
||||||
// get
|
// get
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ namespace CustomBuildTool
|
|||||||
{
|
{
|
||||||
public static class Win32
|
public static class Win32
|
||||||
{
|
{
|
||||||
|
private static readonly char[] PathSeparator = [';'];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates all directories and subdirectories in the specified path unless they already exist.
|
/// Creates all directories and subdirectories in the specified path unless they already exist.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -163,7 +165,7 @@ namespace CustomBuildTool
|
|||||||
|
|
||||||
// System32 directory.
|
// System32 directory.
|
||||||
{
|
{
|
||||||
string where = Path.Combine(Environment.SystemDirectory, FileName);
|
string where = Path.Join([Environment.SystemDirectory, FileName]);
|
||||||
|
|
||||||
if (File.Exists(where))
|
if (File.Exists(where))
|
||||||
return where;
|
return where;
|
||||||
@@ -181,9 +183,9 @@ namespace CustomBuildTool
|
|||||||
{
|
{
|
||||||
if (Win32.GetEnvironmentVariable("PATH", out string values))
|
if (Win32.GetEnvironmentVariable("PATH", out string values))
|
||||||
{
|
{
|
||||||
foreach (string path in values.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
foreach (string path in values.Split(PathSeparator, StringSplitOptions.RemoveEmptyEntries))
|
||||||
{
|
{
|
||||||
string where = Path.Combine(path, FileName);
|
string where = Path.Join([path, FileName]);
|
||||||
|
|
||||||
if (File.Exists(where))
|
if (File.Exists(where))
|
||||||
return where;
|
return where;
|
||||||
@@ -249,14 +251,9 @@ namespace CustomBuildTool
|
|||||||
|
|
||||||
if (File.Exists(DestinationFile))
|
if (File.Exists(DestinationFile))
|
||||||
{
|
{
|
||||||
FileVersionInfo currentInfo = FileVersionInfo.GetVersionInfo(SourceFile);
|
|
||||||
FileVersionInfo newInfo = FileVersionInfo.GetVersionInfo(DestinationFile);
|
|
||||||
var currentInfoVersion = new Version(currentInfo.FileVersion);
|
|
||||||
var newInfoVersion = new Version(newInfo.FileVersion);
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
currentInfoVersion > newInfoVersion ||
|
File.GetLastWriteTime(SourceFile) > File.GetLastWriteTime(DestinationFile) ||
|
||||||
File.GetLastWriteTime(SourceFile) > File.GetLastWriteTime(DestinationFile)
|
Win32.GetFileVersion(SourceFile) > Win32.GetFileVersion(DestinationFile)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
File.Copy(SourceFile, DestinationFile, true);
|
File.Copy(SourceFile, DestinationFile, true);
|
||||||
@@ -291,6 +288,21 @@ namespace CustomBuildTool
|
|||||||
return !string.IsNullOrWhiteSpace(Value);
|
return !string.IsNullOrWhiteSpace(Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the value of an environment variable from the current process.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Name">The name of the environment variable.</param>
|
||||||
|
/// <param name="Value">The value of the environment variable.</param>
|
||||||
|
/// <returns>True if the environment variable was found.</returns>
|
||||||
|
public static bool GetEnvironmentVariableSpan(string Name, out ReadOnlySpan<char> Value)
|
||||||
|
{
|
||||||
|
var value = Environment.GetEnvironmentVariable(Name, EnvironmentVariableTarget.Process);
|
||||||
|
|
||||||
|
Value = value.AsSpan();
|
||||||
|
|
||||||
|
return !Utils.IsSpanNullOrWhiteSpace(Value);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves the value of an environment variable from the current process.
|
/// Retrieves the value of an environment variable from the current process.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -298,7 +310,7 @@ namespace CustomBuildTool
|
|||||||
/// <returns>True if the environment variable was found.</returns>
|
/// <returns>True if the environment variable was found.</returns>
|
||||||
public static bool HasEnvironmentVariable(string Name)
|
public static bool HasEnvironmentVariable(string Name)
|
||||||
{
|
{
|
||||||
return GetEnvironmentVariable(Name, out _);
|
return GetEnvironmentVariableSpan(Name, out ReadOnlySpan<char> _);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -389,6 +401,18 @@ namespace CustomBuildTool
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Version GetFileVersion(string FileName)
|
||||||
|
{
|
||||||
|
FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(FileName);
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(versionInfo.FileVersion))
|
||||||
|
{
|
||||||
|
return Version.Parse("0.0.0.0");
|
||||||
|
}
|
||||||
|
|
||||||
|
return Version.Parse(versionInfo.FileVersion);
|
||||||
|
}
|
||||||
|
|
||||||
public static void SetErrorMode()
|
public static void SetErrorMode()
|
||||||
{
|
{
|
||||||
NativeMethods.SetErrorMode(NativeMethods.SEM_NOGPFAULTERRORBOX | NativeMethods.SEM_NOOPENFILEERRORBOX);
|
NativeMethods.SetErrorMode(NativeMethods.SEM_NOGPFAULTERRORBOX | NativeMethods.SEM_NOOPENFILEERRORBOX);
|
||||||
|
|||||||
Reference in New Issue
Block a user