Add IsPortable flag to update manager

This commit is contained in:
Caelan Sayler
2024-03-27 17:03:59 +00:00
parent 02881c5ace
commit d7fe3edbfa
5 changed files with 21 additions and 0 deletions

View File

@@ -171,6 +171,9 @@ public class WindowsPackCommandRunner : PackageBuilder<WindowsPackOptions>
var stubName = (Options.PackTitle ?? Options.PackId) + ".exe";
File.Move(stubPath, Path.Combine(dir.FullName, stubName));
// create a .portable file to indicate this is a portable package
File.Create(Path.Combine(dir.FullName, ".portable")).Close();
await EasyZip.CreateZipFromDirectoryAsync(Log, outputPath, dir.FullName, Utility.CreateProgressDelegate(progress, 40, 100));
progress(100);
}

View File

@@ -39,6 +39,14 @@ namespace Velopack.Locators
/// <summary> The release channel this package was built for. </summary>
public string? Channel { get; }
/// <summary>
/// A flag indicating if this is a portable build, and that the settings should be self-contained in the package.
/// On Windows, this is true for portable builds, and false for non-portable builds which were installed by Setup.exe
/// On OSX and Linux, this is always false, because settings and application files should be stored in the user's
/// home directory.
/// </summary>
public bool IsPortable { get; }
/// <summary>
/// Finds .nupkg files in the PackagesDir and returns a list of ReleaseEntryName objects.
/// </summary>

View File

@@ -59,6 +59,9 @@ namespace Velopack.Locators
/// <inheritdoc/>
public abstract string? Channel { get; }
/// <inheritdoc/>
public virtual bool IsPortable => false;
/// <inheritdoc/>
public virtual string? ThisExeRelativePath {
get {

View File

@@ -31,6 +31,10 @@ namespace Velopack.Locators
/// <inheritdoc />
public override string? PackagesDir => CreateSubDirIfDoesNotExist(RootAppDir, "packages");
/// <inheritdoc />
public override bool IsPortable =>
RootAppDir != null ? File.Exists(Path.Combine(RootAppDir, ".portable")) : false;
/// <inheritdoc />
public override string? Channel { get; }

View File

@@ -24,6 +24,9 @@ namespace Velopack
/// <summary> True if this application is currently installed, and is able to download/check for updates. </summary>
public virtual bool IsInstalled => Locator.CurrentlyInstalledVersion != null;
/// <inheritdoc cref="IVelopackLocator.IsPortable" />
public virtual bool IsPortable => Locator.IsPortable;
/// <summary> True if there is a local update prepared that requires a call to <see cref="ApplyUpdatesAndRestart(VelopackAsset, string[])"/> to be applied. </summary>
public virtual bool IsUpdatePendingRestart {
get {