From 18426d048170a6d1b71c6ecf79a729cbc5c1d173 Mon Sep 17 00:00:00 2001 From: hevinci Date: Wed, 26 Oct 2022 20:57:27 +0800 Subject: [PATCH] Update AssetBundleBuilder --- .../BuildTasks/TaskCopyBuildinFiles.cs | 22 +++++++---- .../BuildTasks/TaskCreatePatchManifest.cs | 37 ++++++++++++------- .../BuildTasks/TaskCreatePatchPackage.cs | 28 +++++++++----- 3 files changed, 57 insertions(+), 30 deletions(-) diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyBuildinFiles.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyBuildinFiles.cs index 33df614..b8ff795 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyBuildinFiles.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyBuildinFiles.cs @@ -40,17 +40,25 @@ namespace YooAsset.Editor // 拷贝补丁清单文件 { - string manifestFileName = YooAssetSettingsData.GetPatchManifestFileName(buildPackageName, buildPackageVersion); - string sourcePath = $"{packageOutputDirectory}/{manifestFileName}"; - string destPath = $"{streamingAssetsDirectory}/{manifestFileName}"; + string fileName = YooAssetSettingsData.GetPatchManifestFileName(buildPackageName, buildPackageVersion); + string sourcePath = $"{packageOutputDirectory}/{fileName}"; + string destPath = $"{streamingAssetsDirectory}/{fileName}"; EditorTools.CopyFile(sourcePath, destPath, true); } - // 拷贝静态版本文件 + // 拷贝补丁清单哈希文件 { - string versionFileName = YooAssetSettingsData.GetStaticVersionFileName(buildPackageName); - string sourcePath = $"{packageOutputDirectory}/{versionFileName}"; - string destPath = $"{streamingAssetsDirectory}/{versionFileName}"; + string fileName = YooAssetSettingsData.GetPatchManifestHashFileName(buildPackageName, buildPackageVersion); + string sourcePath = $"{packageOutputDirectory}/{fileName}"; + string destPath = $"{streamingAssetsDirectory}/{fileName}"; + EditorTools.CopyFile(sourcePath, destPath, true); + } + + // 拷贝补丁清单版本文件 + { + string fileName = YooAssetSettingsData.GetPatchManifestVersionFileName(buildPackageName); + string sourcePath = $"{packageOutputDirectory}/{fileName}"; + string destPath = $"{streamingAssetsDirectory}/{fileName}"; EditorTools.CopyFile(sourcePath, destPath, true); } diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs index 618f0c5..ace5439 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs @@ -45,21 +45,32 @@ namespace YooAsset.Editor UpdateBuiltInBundleReference(patchManifest, buildResultContext.Results); } } - + // 创建补丁清单文件 - string manifestFileName = YooAssetSettingsData.GetPatchManifestFileName(buildParameters.PackageName, buildParameters.PackageVersion); - string manifestFilePath = $"{pipelineOutputDirectory}/{manifestFileName}"; - PatchManifest.Serialize(manifestFilePath, patchManifest); - BuildRunner.Log($"创建补丁清单文件:{manifestFilePath}"); + string packageHash = string.Empty; + { + string fileName = YooAssetSettingsData.GetPatchManifestFileName(buildParameters.PackageName, buildParameters.PackageVersion); + string filePath = $"{pipelineOutputDirectory}/{fileName}"; + PatchManifest.Serialize(filePath, patchManifest); + packageHash = HashUtility.FileMD5(filePath); + BuildRunner.Log($"创建补丁清单文件:{filePath}"); + } - // 创建静态版本文件 - string staticVersionFileName = YooAssetSettingsData.GetStaticVersionFileName(buildParameters.PackageName); - string staticVersionFilePath = $"{pipelineOutputDirectory}/{staticVersionFileName}"; - StaticVersion staticVersion = new StaticVersion(); - staticVersion.PackageVersion = buildParameters.PackageVersion; - staticVersion.ManifestCRC = HashUtility.FileCRC32(manifestFilePath); - StaticVersion.Serialize(staticVersionFilePath, staticVersion); - BuildRunner.Log($"创建静态版本文件:{staticVersionFilePath}"); + // 创建补丁清单哈希文件 + { + string fileName = YooAssetSettingsData.GetPatchManifestHashFileName(buildParameters.PackageName, buildParameters.PackageVersion); + string filePath = $"{pipelineOutputDirectory}/{fileName}"; + FileUtility.CreateFile(filePath, packageHash); + BuildRunner.Log($"创建补丁清单哈希文件:{filePath}"); + } + + // 创建补丁清单版本文件 + { + string fileName = YooAssetSettingsData.GetPatchManifestVersionFileName(buildParameters.PackageName); + string filePath = $"{pipelineOutputDirectory}/{fileName}"; + FileUtility.CreateFile(filePath, buildParameters.PackageVersion); + BuildRunner.Log($"创建补丁清单版本文件:{filePath}"); + } } /// diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchPackage.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchPackage.cs index 6c12520..d6c80c8 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchPackage.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchPackage.cs @@ -28,25 +28,33 @@ namespace YooAsset.Editor // 拷贝Report文件 { - string reportFileName = YooAssetSettingsData.GetReportFileName(buildParameters.PackageName, buildParameters.PackageVersion); - string sourcePath = $"{pipelineOutputDirectory}/{reportFileName}"; - string destPath = $"{packageOutputDirectory}/{reportFileName}"; + string fileName = YooAssetSettingsData.GetReportFileName(buildParameters.PackageName, buildParameters.PackageVersion); + string sourcePath = $"{pipelineOutputDirectory}/{fileName}"; + string destPath = $"{packageOutputDirectory}/{fileName}"; EditorTools.CopyFile(sourcePath, destPath, true); } // 拷贝补丁清单文件 { - string manifestFileName = YooAssetSettingsData.GetPatchManifestFileName(buildParameters.PackageName, buildParameters.PackageVersion); - string sourcePath = $"{pipelineOutputDirectory}/{manifestFileName}"; - string destPath = $"{packageOutputDirectory}/{manifestFileName}"; + string fileName = YooAssetSettingsData.GetPatchManifestFileName(buildParameters.PackageName, buildParameters.PackageVersion); + string sourcePath = $"{pipelineOutputDirectory}/{fileName}"; + string destPath = $"{packageOutputDirectory}/{fileName}"; EditorTools.CopyFile(sourcePath, destPath, true); } - // 拷贝静态版本文件 + // 拷贝补丁清单哈希文件 { - string versionFileName = YooAssetSettingsData.GetStaticVersionFileName(buildParameters.PackageName); - string sourcePath = $"{pipelineOutputDirectory}/{versionFileName}"; - string destPath = $"{packageOutputDirectory}/{versionFileName}"; + string fileName = YooAssetSettingsData.GetPatchManifestHashFileName(buildParameters.PackageName, buildParameters.PackageVersion); + string sourcePath = $"{pipelineOutputDirectory}/{fileName}"; + string destPath = $"{packageOutputDirectory}/{fileName}"; + EditorTools.CopyFile(sourcePath, destPath, true); + } + + // 拷贝补丁清单版本文件 + { + string fileName = YooAssetSettingsData.GetPatchManifestVersionFileName(buildParameters.PackageName); + string sourcePath = $"{pipelineOutputDirectory}/{fileName}"; + string destPath = $"{packageOutputDirectory}/{fileName}"; EditorTools.CopyFile(sourcePath, destPath, true); }