Skip to content
This repository has been archived by the owner on Jul 1, 2020. It is now read-only.

Legacy: Generating Patch

Süleyman Yasir KULA edited this page May 23, 2019 · 9 revisions

NOTE: using projects is the easier and the recommended way of creating patches.

Use the Patcher create command. It takes the following arguments:

  • root: path of the up-to-date (latest) version of your application
  • out: patch files will be generated here
  • name: a unique name for your SimplePatchTool project. This name is used in several key locations, so give it a meaningful name with low collision chance and try not to change it after releasing the first version of your app. Name can only contain English letters and numbers
  • version: version code of the latest version of your app, e.g. 1.0, 0.4.11.3 and so on
  • prevRoot: (optional) path of the previous version of your application. Providing a prevRoot will create an incremental patch. If this is the first release of your app, don't use this argument
  • ignoredPaths: (optional) path of a text file that stores paths of files/directories relative to the root path that SimplePatchTool should ignore. One ignored path per line
  • compressionRepair: (optional) sets the compression algorithm used to compress the repair patch files (LZMA, GZIP or NONE)
  • compressionIncremental: (optional) sets the compression algorithm used to compress the incremental patch files (LZMA, GZIP or NONE)
  • compressionInstaller: (optional) sets the compression algorithm used to compress the installer patch files (LZMA, GZIP or NONE)
  • dontCreateRepairPatch: (optional)(flag) as the name suggests, instructs SimplePatchTool to not generate a repair patch. Might be useful when e.g. you have created a patch from version 1.2 to 1.3 and now you want to create only an incremental patch that patches directly from version 1.1 to 1.3 (and not wait for SimplePatchTool to regenerate the same repair files)
  • dontCreateInstallerPatch: (optional)(flag) instructs SimplePatchTool to not generate an installer patch
  • silent: (optional)(flag) progress will not be logged to the console

Example: Patcher create -root="C:\App v1.1" -prevRoot="C:\App v1.0" -version="1.1" -out="C:\Users\USERNAME\Desktop\PatchFiles" -name="MyProjectName"

Via Scripting API

Namespace: SimplePatchToolCore

Creating PatchCreator

public PatchCreator( string rootPath, string outputPath, string projectName, VersionCode version ): creates a new PatchCreator instance. Its parameters correspond to the root, out, name and version arguments mentioned in the console app section. VersionCode supports implicit casting from string

Configuring PatchCreator

PatchCreator LoadIgnoredPathsFromFile( string pathToIgnoredPathsList ): corresponds to the ignoredPaths argument mentioned in the console app section

PatchCreator AddIgnoredPath( string ignoredPath ): PatchCreator ignores the specified path

PatchCreator AddIgnoredPaths( IEnumerable<string> ignoredPaths ): PatchCreator ignores the specified paths

PatchCreator CreateRepairPatch( bool value ): sets whether or not a repair patch should be generated

PatchCreator CreateInstallerPatch( bool value ): sets whether or not an installer patch should be generated

PatchCreator CreateIncrementalPatch( bool value, string previousVersionRoot = null, int diffQuality = 3 ): sets whether or not an incremental patch should be generated. If value is equal to true, a previousVersionRoot must be provided (which corresponds to the prevRoot argument mentioned in the console app section). As diffQuality increases, produced incremental patch will be smaller but it will take more time to calculate the binary diff files. Note that increasing diffQuality will have no effect after some point (usually, higher values than the default value will produce the same binary diff file)

PatchCreator SetBaseDownloadURL( string baseDownloadURL ): sets the BaseDownloadURL of the VersionInfo that will be generated

PatchCreator SetMaintenanceCheckURL( string maintenanceCheckURL ): sets the MaintenanceCheckURL of the VersionInfo that will be generated

PatchCreator SetCompressionFormat( CompressionFormat repairPatch, CompressionFormat installerPatch, CompressionFormat incrementalPatch ): corresponds to the compression settings mentioned in the console app section

PatchCreator SilentMode( bool silent ): sets whether or not PatchCreator should log anything

Executing PatchCreator

bool Run(): starts creating the patch asynchronously in a separate thread. This function will return false, if PatchCreator is already running

Fetching PatchCreator's progress

There are two ways to fetch PatchCreator's progress:

  • 1. Calling the following methods and properties manually from time to time

string FetchLog(): fetches the next log that PatchCreator has generated. Returns null, if there is no log in the queue

void Cancel(): cancels the operation

bool IsRunning { get; }: returns true if PatchCreator is currently running

  • 2. Using a PatchCreator.IListener object

You can register a listener to PatchCreator using the SetListener function. This listener will receive the following callbacks:

void LogReceived( string log );
void Finished(); // PatchCreator finished running

Be aware that any expensive operations performed in these callbacks will block the PatchCreator's thread.

Fetching the result of the operation

PatchResult Result { get; }: returns PatchResult.Success if patch is created successfully, PatchResult.Failed otherwise. Its value should be checked after IsRunning returns false

Example code: SimplePatchToolConsoleApp.Program.CreatePatch

Clone this wiki locally