MCPcopy Create free account
hub / github.com/Squirrel/Squirrel.Windows / setPEVersionInfoAndIcon

Method setPEVersionInfoAndIcon

src/Update/Program.cs:638–669  ·  view source on GitHub ↗
(string exePath, IPackage package, string iconPath = null)

Source from the content-addressed store, hash-verified

636 }
637
638 static async Task setPEVersionInfoAndIcon(string exePath, IPackage package, string iconPath = null)
639 {
640 var realExePath = Path.GetFullPath(exePath);
641 var company = String.Join(",", package.Authors);
642 var verStrings = new Dictionary<string, string>() {
643 { "CompanyName", company },
644 { "LegalCopyright", package.Copyright ?? "Copyright © " + DateTime.Now.Year.ToString() + " " + company },
645 { "FileDescription", package.Summary ?? package.Description ?? "Installer for " + package.Id },
646 { "ProductName", package.Description ?? package.Summary ?? package.Id },
647 };
648
649 var args = verStrings.Aggregate(new StringBuilder("\"" + realExePath + "\""), (acc, x) => { acc.AppendFormat(" --set-version-string \"{0}\" \"{1}\"", x.Key, x.Value); return acc; });
650 args.AppendFormat(" --set-file-version {0} --set-product-version {0}", package.Version.ToString());
651 if (iconPath != null) {
652 args.AppendFormat(" --set-icon \"{0}\"", Path.GetFullPath(iconPath));
653 }
654
655 // Try to find rcedit.exe
656 string exe = Utility.FindHelperExecutable("rcedit.exe");
657
658 var processResult = await Utility.InvokeProcessAsync(exe, args.ToString(), CancellationToken.None);
659
660 if (processResult.Item1 != 0) {
661 var msg = String.Format(
662 "Failed to modify resources, command invoked was: '{0} {1}'\n\nOutput was:\n{2}",
663 exe, args, processResult.Item2);
664
665 throw new Exception(msg);
666 } else {
667 Console.WriteLine(processResult.Item2);
668 }
669 }
670
671 static async Task createMsiPackage(string setupExe, IPackage package, bool packageAs64Bit)
672 {

Callers

nothing calls this directly

Calls 4

FindHelperExecutableMethod · 0.80
InvokeProcessAsyncMethod · 0.80
FormatMethod · 0.80
ToStringMethod · 0.45

Tested by

no test coverage detected