mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Fix bugs with cross-compiling
This commit is contained in:
@@ -72,8 +72,9 @@ public class WindowsPackCommandRunner : PackageBuilder<WindowsPackOptions>
|
|||||||
File.Copy(updatePath, Path.Combine(packDir, "Squirrel.exe"), true);
|
File.Copy(updatePath, Path.Combine(packDir, "Squirrel.exe"), true);
|
||||||
|
|
||||||
// create a stub for portable packages
|
// create a stub for portable packages
|
||||||
var mainPath = Path.Combine(packDir, MainExeName);
|
var mainExeName = Options.EntryExecutableName;
|
||||||
var stubPath = Path.Combine(packDir, Path.GetFileNameWithoutExtension(MainExeName) + "_ExecutionStub.exe");
|
var mainPath = Path.Combine(packDir, mainExeName);
|
||||||
|
var stubPath = Path.Combine(packDir, Path.GetFileNameWithoutExtension(mainExeName) + "_ExecutionStub.exe");
|
||||||
CreateExecutableStubForExe(mainPath, stubPath);
|
CreateExecutableStubForExe(mainPath, stubPath);
|
||||||
|
|
||||||
return Task.FromResult(packDir);
|
return Task.FromResult(packDir);
|
||||||
@@ -205,7 +206,8 @@ public class WindowsPackCommandRunner : PackageBuilder<WindowsPackOptions>
|
|||||||
File.Delete(Path.Combine(current.FullName, "Squirrel.exe"));
|
File.Delete(Path.Combine(current.FullName, "Squirrel.exe"));
|
||||||
|
|
||||||
// move the stub to the root of the portable package
|
// move the stub to the root of the portable package
|
||||||
var stubPath = Path.Combine(current.FullName, Path.GetFileNameWithoutExtension(MainExeName) + "_ExecutionStub.exe");
|
var stubPath = Path.Combine(current.FullName,
|
||||||
|
Path.GetFileNameWithoutExtension(Options.EntryExecutableName) + "_ExecutionStub.exe");
|
||||||
var stubName = (Options.PackTitle ?? Options.PackId) + ".exe";
|
var stubName = (Options.PackTitle ?? Options.PackId) + ".exe";
|
||||||
File.Move(stubPath, Path.Combine(dir.FullName, stubName));
|
File.Move(stubPath, Path.Combine(dir.FullName, stubName));
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
public interface INugetPackCommand
|
public interface INugetPackCommand
|
||||||
{
|
{
|
||||||
string PackId { get; }
|
string PackId { get; set; }
|
||||||
string PackVersion { get; }
|
string PackVersion { get; set; }
|
||||||
string PackDirectory { get; }
|
string PackDirectory { get; set; }
|
||||||
string PackAuthors { get; }
|
string PackAuthors { get; set; }
|
||||||
string PackTitle { get; }
|
string PackTitle { get; set; }
|
||||||
string ReleaseNotes { get; }
|
string ReleaseNotes { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
public interface IPackOptions : INugetPackCommand, IPlatformOptions
|
public interface IPackOptions : INugetPackCommand, IPlatformOptions
|
||||||
{
|
{
|
||||||
string Channel { get; }
|
string Channel { get; set; }
|
||||||
DeltaMode DeltaMode { get; }
|
DeltaMode DeltaMode { get; set; }
|
||||||
string EntryExecutableName { get; }
|
string EntryExecutableName { get; set; }
|
||||||
string Icon { get; }
|
string Icon { get; set; }
|
||||||
string Exclude { get; }
|
string Exclude { get; set; }
|
||||||
bool NoPortable { get; }
|
bool NoPortable { get; set; }
|
||||||
bool NoInst { get; }
|
bool NoInst { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace Velopack.Packaging.Abstractions;
|
namespace Velopack.Packaging.Abstractions;
|
||||||
|
|
||||||
public interface IPlatformOptions : IOutputOptions
|
public interface IPlatformOptions : IOutputOptions
|
||||||
{
|
{
|
||||||
RID TargetRuntime { get; }
|
RID TargetRuntime { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,12 +24,8 @@ public abstract class PackageBuilder<T> : ICommand<T>
|
|||||||
|
|
||||||
protected T Options { get; private set; }
|
protected T Options { get; private set; }
|
||||||
|
|
||||||
protected string MainExeName { get; private set; }
|
|
||||||
|
|
||||||
protected string MainExePath { get; private set; }
|
protected string MainExePath { get; private set; }
|
||||||
|
|
||||||
protected string Channel { get; private set; }
|
|
||||||
|
|
||||||
protected Dictionary<string, string> ExtraNuspecMetadata { get; } = new();
|
protected Dictionary<string, string> ExtraNuspecMetadata { get; } = new();
|
||||||
|
|
||||||
private readonly Regex REGEX_EXCLUDES = new Regex(@".*[\\\/]createdump.*|.*\.vshost\..*|.*\.nupkg$", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
private readonly Regex REGEX_EXCLUDES = new Regex(@".*[\\\/]createdump.*|.*\.vshost\..*|.*\.nupkg$", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||||
@@ -43,7 +39,11 @@ public abstract class PackageBuilder<T> : ICommand<T>
|
|||||||
|
|
||||||
public async Task Run(T options)
|
public async Task Run(T options)
|
||||||
{
|
{
|
||||||
if (options.TargetRuntime?.BaseRID != TargetOs) {
|
if (options.TargetRuntime == null) {
|
||||||
|
options.TargetRuntime = RID.Parse(TargetOs.GetOsShortName());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.TargetRuntime.BaseRID != TargetOs) {
|
||||||
throw new UserInfoException($"To build packages for {TargetOs.GetOsLongName()}, " +
|
throw new UserInfoException($"To build packages for {TargetOs.GetOsLongName()}, " +
|
||||||
$"the target rid must be {TargetOs} (actually was {options.TargetRuntime?.BaseRID}). " +
|
$"the target rid must be {TargetOs} (actually was {options.TargetRuntime?.BaseRID}). " +
|
||||||
$"If your real intention was to cross-compile a release for {options.TargetRuntime?.BaseRID} then you " +
|
$"If your real intention was to cross-compile a release for {options.TargetRuntime?.BaseRID} then you " +
|
||||||
@@ -55,7 +55,7 @@ public abstract class PackageBuilder<T> : ICommand<T>
|
|||||||
|
|
||||||
var releaseDir = options.ReleaseDir;
|
var releaseDir = options.ReleaseDir;
|
||||||
var channel = options.Channel?.ToLower() ?? ReleaseEntryHelper.GetDefaultChannel(TargetOs);
|
var channel = options.Channel?.ToLower() ?? ReleaseEntryHelper.GetDefaultChannel(TargetOs);
|
||||||
Channel = channel;
|
options.Channel = channel;
|
||||||
|
|
||||||
var entryHelper = new ReleaseEntryHelper(releaseDir.FullName, channel, Log, TargetOs);
|
var entryHelper = new ReleaseEntryHelper(releaseDir.FullName, channel, Log, TargetOs);
|
||||||
if (entryHelper.DoesSimilarVersionExist(SemanticVersion.Parse(options.PackVersion))) {
|
if (entryHelper.DoesSimilarVersionExist(SemanticVersion.Parse(options.PackVersion))) {
|
||||||
@@ -89,7 +89,7 @@ public abstract class PackageBuilder<T> : ICommand<T>
|
|||||||
}
|
}
|
||||||
|
|
||||||
MainExePath = mainExePath;
|
MainExePath = mainExePath;
|
||||||
MainExeName = Path.GetFileName(mainExePath);
|
options.EntryExecutableName = Path.GetFileName(mainExePath);
|
||||||
|
|
||||||
using var _1 = Utility.GetTempDirectory(out var pkgTempDir);
|
using var _1 = Utility.GetTempDirectory(out var pkgTempDir);
|
||||||
TempDir = new DirectoryInfo(pkgTempDir);
|
TempDir = new DirectoryInfo(pkgTempDir);
|
||||||
@@ -221,8 +221,8 @@ public abstract class PackageBuilder<T> : ICommand<T>
|
|||||||
<description>{packTitle ?? packId}</description>
|
<description>{packTitle ?? packId}</description>
|
||||||
<authors>{packAuthors ?? packId}</authors>
|
<authors>{packAuthors ?? packId}</authors>
|
||||||
<version>{packVersion}</version>
|
<version>{packVersion}</version>
|
||||||
<channel>{Channel}</channel>
|
<channel>{Options.Channel}</channel>
|
||||||
<mainExe>{MainExeName}</mainExe>
|
<mainExe>{Options.EntryExecutableName}</mainExe>
|
||||||
<os>{rid.BaseRID.GetOsShortName()}</os>
|
<os>{rid.BaseRID.GetOsShortName()}</os>
|
||||||
<rid>{rid.ToDisplay(RidDisplayType.NoVersion)}</rid>
|
<rid>{rid.ToDisplay(RidDisplayType.NoVersion)}</rid>
|
||||||
{extraMetadata.Trim()}
|
{extraMetadata.Trim()}
|
||||||
|
|||||||
@@ -37,10 +37,15 @@ public static partial class OptionMapper
|
|||||||
|
|
||||||
private static DirectoryInfo StringToDirectoryInfo(string t)
|
private static DirectoryInfo StringToDirectoryInfo(string t)
|
||||||
{
|
{
|
||||||
|
if (t == null) return null;
|
||||||
var di = new DirectoryInfo(t);
|
var di = new DirectoryInfo(t);
|
||||||
if (!di.Exists) di.Create();
|
if (!di.Exists) di.Create();
|
||||||
return di;
|
return di;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static RID StringToRID(string t) => RID.Parse(t);
|
private static RID StringToRID(string t)
|
||||||
|
{
|
||||||
|
if (t == null) return null;
|
||||||
|
return RID.Parse(t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user