Skip to content

Commit

Permalink
Added support for "Microsoft BuildTools" Nuget Package (nuke-build#1186)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustavo Calheiros committed Apr 5, 2024
1 parent 1279c3c commit e9401fb
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions source/Nuke.Common/Tools/SignTool/SignToolSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System.Linq;
using JetBrains.Annotations;
using NuGet.Configuration;
using Nuke.Common.IO;

namespace Nuke.Common.Tools.SignTool;
Expand All @@ -20,11 +21,25 @@ private static string GetToolPath()

var platformIdentifier = EnvironmentInfo.Is64Bit ? "x64" : "x86";
const string windowsKitLastVersion = "10";
const string windowsKitVersionWildcard = windowsKitLastVersion + ".*";
const string signtoolExe = "signtool.exe";
const string microsoftBuildToolsNugetPackage = "microsoft.windows.sdk.buildtools";

var windowsKitsRootDirectory = programDirectory / "Windows Kits" / windowsKitLastVersion;

var signToolPath = windowsKitsRootDirectory.GlobFiles($"bin/{windowsKitLastVersion}.*/{platformIdentifier}/signtool.exe").LastOrDefault();
var signToolPath = windowsKitsRootDirectory.GlobFiles($"bin/{windowsKitVersionWildcard}/{platformIdentifier}/{signtoolExe}").LastOrDefault();

return signToolPath ?? windowsKitsRootDirectory.GlobFiles("App Certification Kit/signtool.exe").SingleOrDefault();
if(signToolPath == null)
{
var nugetPath = SettingsUtility.GetGlobalPackagesFolder(Settings.LoadDefaultSettings(null));

signToolPath = AbsolutePath.Create(nugetPath)
.GlobFiles($"{microsoftBuildToolsNugetPackage}/{windowsKitVersionWildcard}/bin/{windowsKitVersionWildcard}/{platformIdentifier}/{signtoolExe}")
.LastOrDefault();

signToolPath ??= windowsKitsRootDirectory.GlobFiles($"App Certification Kit/{signtoolExe}").SingleOrDefault();
}

return signToolPath;
}
}

0 comments on commit e9401fb

Please # to comment.