mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Automatically detecting runtime when not specified.
This commit is contained in:
@@ -339,6 +339,7 @@ public class WindowsPackCommandRunner : PackageBuilder<WindowsPackOptions>
|
|||||||
private void CompileWixTemplateToMsi(Action<int> progress, DirectoryInfo portableDirectory, string msiFilePath)
|
private void CompileWixTemplateToMsi(Action<int> progress, DirectoryInfo portableDirectory, string msiFilePath)
|
||||||
{
|
{
|
||||||
var templateData = MsiBuilder.ConvertOptionsToTemplateData(
|
var templateData = MsiBuilder.ConvertOptionsToTemplateData(
|
||||||
|
MainExePath,
|
||||||
portableDirectory,
|
portableDirectory,
|
||||||
GetShortcuts(),
|
GetShortcuts(),
|
||||||
GetRuntimeDependencies(),
|
GetRuntimeDependencies(),
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.Runtime.Versioning;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
using AsmResolver.PE;
|
||||||
using HandlebarsDotNet;
|
using HandlebarsDotNet;
|
||||||
using Markdig;
|
using Markdig;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@@ -105,7 +106,7 @@ public static class MsiBuilder
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MsiTemplateData ConvertOptionsToTemplateData(DirectoryInfo portableDir, ShortcutLocation shortcuts,
|
public static MsiTemplateData ConvertOptionsToTemplateData(string mainExePath, DirectoryInfo portableDir, ShortcutLocation shortcuts,
|
||||||
string runtimeDeps, WindowsPackOptions options)
|
string runtimeDeps, WindowsPackOptions options)
|
||||||
{
|
{
|
||||||
// WiX Identifiers may contain ASCII characters A-Z, a-z, digits, underscores (_), or
|
// WiX Identifiers may contain ASCII characters A-Z, a-z, digits, underscores (_), or
|
||||||
@@ -120,6 +121,12 @@ public static class MsiBuilder
|
|||||||
msiVersion = $"{parsedVersion.Major}.{parsedVersion.Minor}.{parsedVersion.Patch}.0";
|
msiVersion = $"{parsedVersion.Major}.{parsedVersion.Minor}.{parsedVersion.Patch}.0";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RuntimeCpu runtimeCpu = options.TargetRuntime.Architecture;
|
||||||
|
if (runtimeCpu == RuntimeCpu.Unknown) {
|
||||||
|
runtimeCpu = GetMachineForBinary(mainExePath);
|
||||||
|
options.TargetRuntime.Architecture = runtimeCpu;
|
||||||
|
}
|
||||||
|
|
||||||
return new MsiTemplateData() {
|
return new MsiTemplateData() {
|
||||||
WixId = wixId,
|
WixId = wixId,
|
||||||
AppId = options.PackId,
|
AppId = options.PackId,
|
||||||
@@ -128,8 +135,8 @@ public static class MsiBuilder
|
|||||||
AppMsiVersion = msiVersion,
|
AppMsiVersion = msiVersion,
|
||||||
AppVersion = parsedVersion.ToFullString(),
|
AppVersion = parsedVersion.ToFullString(),
|
||||||
SourceDirectoryPath = portableDir.FullName,
|
SourceDirectoryPath = portableDir.FullName,
|
||||||
Is64Bit = options.TargetRuntime.Architecture is not RuntimeCpu.x86 and not RuntimeCpu.Unknown,
|
Is64Bit = runtimeCpu is RuntimeCpu.x64,
|
||||||
IsArm64 = options.TargetRuntime.Architecture is RuntimeCpu.arm64,
|
IsArm64 = runtimeCpu is RuntimeCpu.arm64,
|
||||||
InstallForAllUsers = options.InstLocation.HasFlag(InstallLocation.PerMachine),
|
InstallForAllUsers = options.InstLocation.HasFlag(InstallLocation.PerMachine),
|
||||||
InstallForCurrentUser = options.InstLocation.HasFlag(InstallLocation.PerUser),
|
InstallForCurrentUser = options.InstLocation.HasFlag(InstallLocation.PerUser),
|
||||||
UpgradeCodeGuid = GuidUtil.CreateGuidFromHash($"{options.PackId}:UpgradeCode").ToString(),
|
UpgradeCodeGuid = GuidUtil.CreateGuidFromHash($"{options.PackId}:UpgradeCode").ToString(),
|
||||||
@@ -148,6 +155,17 @@ public static class MsiBuilder
|
|||||||
WelcomeMessage = GetPlainTextMessage(options.InstWelcome),
|
WelcomeMessage = GetPlainTextMessage(options.InstWelcome),
|
||||||
LicenseRtfFilePath = GetLicenseRtfPath(options.InstLicense, portableDir.Parent),
|
LicenseRtfFilePath = GetLicenseRtfPath(options.InstLicense, portableDir.Parent),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static RuntimeCpu GetMachineForBinary(string path)
|
||||||
|
{
|
||||||
|
var image = PEImage.FromFile(path);
|
||||||
|
|
||||||
|
if (image.MachineType.HasFlag(AsmResolver.PE.File.Headers.MachineType.Amd64))
|
||||||
|
return RuntimeCpu.x64;
|
||||||
|
if (image.MachineType.HasFlag(AsmResolver.PE.File.Headers.MachineType.Arm64))
|
||||||
|
return RuntimeCpu.arm64;
|
||||||
|
return RuntimeCpu.x86;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[SupportedOSPlatform("windows")]
|
[SupportedOSPlatform("windows")]
|
||||||
|
|||||||
Reference in New Issue
Block a user