-
-
Notifications
You must be signed in to change notification settings - Fork 51
Legacy: Generating Patch
Click here to show/hide
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 contain only English letters and numbers
-
version: version number 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
- prevPatchRoot: (optional) path of the directory that holds the previous version's patch files (the directory that holds VersionInfo.info and folders like RepairPatch). If provided, repair patch files for unchanged files will simply be copied from the previous version's patch files instead of being recalculated. If this is the first release of your app, don't use this argument
- ignoredPaths: (optional) path of a text file that stores the paths 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)
- skipUnchangedPatchFiles: (optional)(flag) instructs SimplePatchTool to not generate patch files for files that didn't change since the last version. This could reduce bandwidth usage while uploading the generated patch files to the server. Note that if prevPatchRoot is not provided, this argument will have no effect
- 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 patch 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 1.1" prevPatchRoot="C:\Users\USERNAME\Desktop\PatchFiles 1.0" -name="MyProjectName"
Click here to show/hide
Namespace: SimplePatchToolCore
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
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 (default: true)
PatchCreator CreateInstallerPatch( bool value )
: sets whether or not an installer patch should be generated (default: true)
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 (default: LZMA)
PatchCreator SetPreviousPatchFilesRoot( string previousPatchFilesRoot, bool dontCreatePatchFilesForUnchangedFiles = false )
: corresponds to the prevPatchRoot and skipUnchangedPatchFiles arguments mentioned in the console app section
PatchCreator SilentMode( bool silent )
: sets whether or not PatchCreator should log anything (default: false)
bool Run()
: starts creating the patch asynchronously in a separate thread. This function will return false, if PatchCreator is already running
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.
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
Click here to show/hide
Open Window-Simple Patch Tool window, click the Open Legacy Window button and switch to the CREATE tab:
These parameters correspond to the root, prevRoot, prevPatchRoot, out, name and version arguments mentioned in the console app section. Instead of providing the ignored paths via a text file, you should enter them directly to the Ignored paths field. By default, *output_log.txt
is ignored, which is the log file that Unity automatically generates.
Clicking the Create Patch button starts generating the patch asynchronously, whereas the Generate Console Command button outputs a console command that can be used to generate the patch via the console app.