Saltar al contenido principal

TestVelopackLocator class

Namespace: Velopack.Locators

Provides a mock / test implementation of VelopackLocator. This can be used to verify that your application is able to find and prepare updates from your chosen update source without actually having an installed application. This could be used in a CI/CD pipeline, or unit tests etc.

[ExcludeFromCodeCoverage]
public class TestVelopackLocator : VelopackLocator, IVelopackLocator, IProcessImpl

Inherits: VelopackLocator
Implements: IVelopackLocator, IProcessImpl

Constructors​

ConstructorSummary
TestVelopackLocatorProvides a mock / test implementation of VelopackLocator. This can be used to verify that
TestVelopackLocatorProvides a mock / test implementation of VelopackLocator. This can be used to verify that

TestVelopackLocator(appId, version, packagesDir, logger)​

public TestVelopackLocator(string appId, string version, string packagesDir, IVelopackLogger? logger = null)

Provides a mock / test implementation of VelopackLocator. This can be used to verify that your application is able to find and prepare updates from your chosen update source without actually having an installed application. This could be used in a CI/CD pipeline, or unit tests etc.

Parameters

NameTypeDescription
appIdstring
versionstring
packagesDirstring
loggerIVelopackLogger

TestVelopackLocator(appId, version, packagesDir, appDir, rootDir, updateExe, channel, logger, localPackage, processPath)​

public TestVelopackLocator(string appId, string version, string packagesDir, string? appDir, string? rootDir, string? updateExe, string? channel = null, IVelopackLogger? logger = null, VelopackAsset? localPackage = null, string processPath = null)

Provides a mock / test implementation of VelopackLocator. This can be used to verify that your application is able to find and prepare updates from your chosen update source without actually having an installed application. This could be used in a CI/CD pipeline, or unit tests etc.

Parameters

NameTypeDescription
appIdstring
versionstring
packagesDirstring
appDirstring
rootDirstring
updateExestring
channelstring
loggerIVelopackLogger
localPackageVelopackAsset
processPathstring

Properties​

PropertySummary
AppIdThe unique application Id. This is used in various app paths.
RootAppDirThe root directory of the application. On Windows, this folder contains all
PackagesDirThe directory in which nupkg files are stored for this application.
UpdateExePathThe path to the current Update.exe or similar on other operating systems.
CurrentlyInstalledVersionThe currently installed version of the application, or null if the app is not installed.
AppContentDirThe directory in which versioned application files are stored.
ChannelThe release channel this package was built for.
LogThe logging interface to use for Velopack diagnostic messages.
ProcessProvides an abstraction for dealing with the dotnet Process API. This is used to start processes and
ExitCode

AppId​

public override string? AppId { get; }

The unique application Id. This is used in various app paths.

RootAppDir​

public override string? RootAppDir { get; }

The root directory of the application. On Windows, this folder contains all the application files, but that may not be the case on other operating systems.

PackagesDir​

public override string? PackagesDir { get; }

The directory in which nupkg files are stored for this application.

UpdateExePath​

public override string? UpdateExePath { get; }

The path to the current Update.exe or similar on other operating systems.

CurrentlyInstalledVersion​

public override SemanticVersion? CurrentlyInstalledVersion { get; }

The currently installed version of the application, or null if the app is not installed.

AppContentDir​

public override string? AppContentDir { get; }

The directory in which versioned application files are stored.

Channel​

public override string? Channel { get; }

The release channel this package was built for.

Log​

public override IVelopackLogger Log { get; }

The logging interface to use for Velopack diagnostic messages.

Process​

public override IProcessImpl Process { get; }

Provides an abstraction for dealing with the dotnet Process API. This is used to start processes and get information about the current process.

ExitCode​

public int? ExitCode { get; }

Methods​

MethodSummary
GetLatestLocalFullPackageFinds latest .nupkg file in the PackagesDir or null if not found.
GetCurrentProcessPathGets the full path to the current process executable.
GetCurrentProcessIdGets the process ID of the current process.
StartProcessStarts a new process with the specified executable path, arguments, and options.
ExitExit the current process with the given exit code.

GetLatestLocalFullPackage()​

public override VelopackAsset? GetLatestLocalFullPackage()

Finds latest .nupkg file in the PackagesDir or null if not found.

Returns VelopackAsset

GetCurrentProcessPath()​

public string GetCurrentProcessPath()

Gets the full path to the current process executable.

Returns string — The full path to the current process executable.

GetCurrentProcessId()​

public uint GetCurrentProcessId()

Gets the process ID of the current process.

Returns uint — The process ID of the current process.

StartProcess(exePath, args, workDir, showWindow)​

public void StartProcess(string exePath, IEnumerable<string> args, string workDir, bool showWindow)

Starts a new process with the specified executable path, arguments, and options.

Parameters

NameTypeDescription
exePathstringThe path to the executable to start.
argsIEnumerable<string>The command-line arguments to pass to the process.
workDirstringThe working directory for the new process.
showWindowboolWhether to show a window for the new process.

Exit(exitCode)​

public void Exit(int exitCode)

Exit the current process with the given exit code.

Parameters

NameTypeDescription
exitCodeintThe exit code

Generated from Velopack 1.2.0