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);
|
||||
|
||||
// create a stub for portable packages
|
||||
var mainPath = Path.Combine(packDir, MainExeName);
|
||||
var stubPath = Path.Combine(packDir, Path.GetFileNameWithoutExtension(MainExeName) + "_ExecutionStub.exe");
|
||||
var mainExeName = Options.EntryExecutableName;
|
||||
var mainPath = Path.Combine(packDir, mainExeName);
|
||||
var stubPath = Path.Combine(packDir, Path.GetFileNameWithoutExtension(mainExeName) + "_ExecutionStub.exe");
|
||||
CreateExecutableStubForExe(mainPath, stubPath);
|
||||
|
||||
return Task.FromResult(packDir);
|
||||
@@ -205,7 +206,8 @@ public class WindowsPackCommandRunner : PackageBuilder<WindowsPackOptions>
|
||||
File.Delete(Path.Combine(current.FullName, "Squirrel.exe"));
|
||||
|
||||
// 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";
|
||||
File.Move(stubPath, Path.Combine(dir.FullName, stubName));
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
public interface INugetPackCommand
|
||||
{
|
||||
string PackId { get; }
|
||||
string PackVersion { get; }
|
||||
string PackDirectory { get; }
|
||||
string PackAuthors { get; }
|
||||
string PackTitle { get; }
|
||||
string ReleaseNotes { get; }
|
||||
string PackId { get; set; }
|
||||
string PackVersion { get; set; }
|
||||
string PackDirectory { get; set; }
|
||||
string PackAuthors { get; set; }
|
||||
string PackTitle { get; set; }
|
||||
string ReleaseNotes { get; set; }
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
public interface IPackOptions : INugetPackCommand, IPlatformOptions
|
||||
{
|
||||
string Channel { get; }
|
||||
DeltaMode DeltaMode { get; }
|
||||
string EntryExecutableName { get; }
|
||||
string Icon { get; }
|
||||
string Exclude { get; }
|
||||
bool NoPortable { get; }
|
||||
bool NoInst { get; }
|
||||
string Channel { get; set; }
|
||||
DeltaMode DeltaMode { get; set; }
|
||||
string EntryExecutableName { get; set; }
|
||||
string Icon { get; set; }
|
||||
string Exclude { get; set; }
|
||||
bool NoPortable { get; set; }
|
||||
bool NoInst { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Velopack.Packaging.Abstractions;
|
||||
namespace Velopack.Packaging.Abstractions;
|
||||
|
||||
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 string MainExeName { get; private set; }
|
||||
|
||||
protected string MainExePath { get; private set; }
|
||||
|
||||
protected string Channel { get; private set; }
|
||||
|
||||
protected Dictionary<string, string> ExtraNuspecMetadata { get; } = new();
|
||||
|
||||
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)
|
||||
{
|
||||
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()}, " +
|
||||
$"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 " +
|
||||
@@ -55,7 +55,7 @@ public abstract class PackageBuilder<T> : ICommand<T>
|
||||
|
||||
var releaseDir = options.ReleaseDir;
|
||||
var channel = options.Channel?.ToLower() ?? ReleaseEntryHelper.GetDefaultChannel(TargetOs);
|
||||
Channel = channel;
|
||||
options.Channel = channel;
|
||||
|
||||
var entryHelper = new ReleaseEntryHelper(releaseDir.FullName, channel, Log, TargetOs);
|
||||
if (entryHelper.DoesSimilarVersionExist(SemanticVersion.Parse(options.PackVersion))) {
|
||||
@@ -89,7 +89,7 @@ public abstract class PackageBuilder<T> : ICommand<T>
|
||||
}
|
||||
|
||||
MainExePath = mainExePath;
|
||||
MainExeName = Path.GetFileName(mainExePath);
|
||||
options.EntryExecutableName = Path.GetFileName(mainExePath);
|
||||
|
||||
using var _1 = Utility.GetTempDirectory(out var pkgTempDir);
|
||||
TempDir = new DirectoryInfo(pkgTempDir);
|
||||
@@ -221,8 +221,8 @@ public abstract class PackageBuilder<T> : ICommand<T>
|
||||
<description>{packTitle ?? packId}</description>
|
||||
<authors>{packAuthors ?? packId}</authors>
|
||||
<version>{packVersion}</version>
|
||||
<channel>{Channel}</channel>
|
||||
<mainExe>{MainExeName}</mainExe>
|
||||
<channel>{Options.Channel}</channel>
|
||||
<mainExe>{Options.EntryExecutableName}</mainExe>
|
||||
<os>{rid.BaseRID.GetOsShortName()}</os>
|
||||
<rid>{rid.ToDisplay(RidDisplayType.NoVersion)}</rid>
|
||||
{extraMetadata.Trim()}
|
||||
|
||||
@@ -37,10 +37,15 @@ public static partial class OptionMapper
|
||||
|
||||
private static DirectoryInfo StringToDirectoryInfo(string t)
|
||||
{
|
||||
if (t == null) return null;
|
||||
var di = new DirectoryInfo(t);
|
||||
if (!di.Exists) di.Create();
|
||||
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