diff --git a/src/Fallout.Common/Tools/SignTool/SignTool.Generated.cs b/src/Fallout.Common/Tools/SignTool/SignTool.Generated.cs index 6a2c8f294..1f17e2f81 100644 --- a/src/Fallout.Common/Tools/SignTool/SignTool.Generated.cs +++ b/src/Fallout.Common/Tools/SignTool/SignTool.Generated.cs @@ -18,9 +18,12 @@ namespace Fallout.Common.Tools.SignTool; ///

Sign Tool is a command-line tool that digitally signs files, verifies signatures in files, and time-stamps files.

For more details, visit the official website.

[ExcludeFromCodeCoverage] -public partial class SignToolTasks : ToolTasks +[NuGetTool(Id = PackageId, Executable = PackageExecutable)] +public partial class SignToolTasks : ToolTasks, IRequireNuGetPackage { public static string SignToolPath { get => new SignToolTasks().GetToolPathInternal(); set => new SignToolTasks().SetToolPath(value); } + public const string PackageId = "Microsoft.Windows.SDK.BuildTools"; + public const string PackageExecutable = "signtool.exe"; ///

Sign Tool is a command-line tool that digitally signs files, verifies signatures in files, and time-stamps files.

For more details, visit the official website.

public static IReadOnlyCollection SignTool(ArgumentStringHandler arguments, string workingDirectory = null, IReadOnlyDictionary environmentVariables = null, int? timeout = null, bool? logOutput = null, bool? logInvocation = null, Action logger = null, Func exitHandler = null) => new SignToolTasks().Run(arguments, workingDirectory, environmentVariables, timeout, logOutput, logInvocation, logger, exitHandler); ///

Use the sign command to sign files using embedded signatures. Signing protects a file from tampering, and allows users to verify the signer (you) based on a signing certificate. The options below allow you to specify signing parameters and to select the signing certificate you wish to use.

For more details, visit the official website.

diff --git a/src/Fallout.Common/Tools/SignTool/SignTool.json b/src/Fallout.Common/Tools/SignTool/SignTool.json index c41aebeee..958737cbf 100644 --- a/src/Fallout.Common/Tools/SignTool/SignTool.json +++ b/src/Fallout.Common/Tools/SignTool/SignTool.json @@ -6,6 +6,9 @@ "name": "SignTool", "officialUrl": "https://docs.microsoft.com/en-us/dotnet/framework/tools/signtool-exe", "help": "Sign Tool is a command-line tool that digitally signs files, verifies signatures in files, and time-stamps files.", + "nugetPackageId": "Microsoft.Windows.SDK.BuildTools", + "packageExecutable": "signtool.exe", + "customExecutable": true, "tasks": [ { "help": "Use the sign command to sign files using embedded signatures. Signing protects a file from tampering, and allows users to verify the signer (you) based on a signing certificate. The options below allow you to specify signing parameters and to select the signing certificate you wish to use.", diff --git a/src/Fallout.Common/Tools/SignTool/SignToolTasks.cs b/src/Fallout.Common/Tools/SignTool/SignToolTasks.cs index 57c6f9334..fba22a730 100644 --- a/src/Fallout.Common/Tools/SignTool/SignToolTasks.cs +++ b/src/Fallout.Common/Tools/SignTool/SignToolTasks.cs @@ -1,6 +1,5 @@ using System; -using System.Linq; -using Fallout.Common.IO; +using System.Runtime.InteropServices; using Fallout.Common.Tooling; namespace Fallout.Common.Tools.SignTool; @@ -9,24 +8,17 @@ partial class SignToolTasks { protected override string GetToolPath(ToolOptions options = null) { - var programDirectory = EnvironmentInfo.SpecialFolder( - EnvironmentInfo.Is64Bit - ? SpecialFolders.ProgramFilesX86 - : SpecialFolders.ProgramFiles).NotNull(); + var architecture = RuntimeInformation.OSArchitecture switch + { + Architecture.Arm64 => "arm64", + Architecture.X86 => "x86", + Architecture.X64 => "x64", + _ => throw new ArgumentException("Unsupported architecture") + }; - var platformIdentifier = EnvironmentInfo.Is64Bit ? "x64" : "x86"; - - return new[] - { - programDirectory / "Windows Kits" / "10" / "bin" / "10.0.15063.0", - programDirectory / "Windows Kits" / "10" / "App Certification Kit", - programDirectory / "Windows Kits" / "10" / "bin" / platformIdentifier, - programDirectory / "Windows Kits" / "8.1" / "bin" / platformIdentifier, - programDirectory / "Windows Kits" / "8.0" / "bin" / platformIdentifier, - programDirectory / "Microsoft SDKs" / "Windows" / "v7.1A" / "Bin" - } - .Select(x => x / "signtool.exe") - .WhereFileExists() - .FirstOrDefault(); + return NuGetToolPathResolver.GetPackageExecutable( + packageId: PackageId, + packageExecutable: PackageExecutable, + framework: architecture); } }