Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1186 Fixing signtool.exe path for new windows kits #1188

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
19 changes: 6 additions & 13 deletions source/Nuke.Common/Tools/SignTool/SignToolSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Distributed under the MIT License.
// https://github.com/nuke-build/nuke/blob/master/LICENSE

using System;
using System.Linq;
using JetBrains.Annotations;
using Nuke.Common.IO;
Expand All @@ -20,18 +19,12 @@ private static string GetToolPath()
: SpecialFolders.ProgramFiles).NotNull();

var platformIdentifier = EnvironmentInfo.Is64Bit ? "x64" : "x86";
const string windowsKitLastVersion = "10";

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();
var windowsKitsRootDirectory = programDirectory / "Windows Kits" / windowsKitLastVersion;

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we order by version number first before using LastOrDefault?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the order returned is naturally the alphabetical order, meaning version 10.0.22 will be after version 10.0.17.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the info, I did not know it's already ordered. 👍


return signToolPath ?? windowsKitsRootDirectory.GlobFiles("App Certification Kit/signtool.exe").SingleOrDefault();
}
}