public override bool Execute()
        {
            if (Assets.Length == 0)
            {
                // Do nothing if there are no assets to pack.
                return(true);
            }

            var packageFiles = new List <StaticWebAssetPackageFile>();

            foreach (var file in AdditionalPackageFiles)
            {
                packageFiles.Add(new StaticWebAssetPackageFile
                {
                    Id          = file.ItemSpec,
                    PackagePath = file.GetMetadata("PackagePath")
                });
            }

            foreach (var asset in Assets)
            {
                packageFiles.Add(new StaticWebAssetPackageFile
                {
                    Id          = asset.ItemSpec,
                    PackagePath = asset.GetMetadata("TargetPath")
                });
            }

            packageFiles.Sort((x, y) => string.Compare(x.Id, y.Id, StringComparison.Ordinal));

            var manifest = new StaticWebAssetsPackManifest
            {
                Files            = packageFiles.ToArray(),
                ElementsToRemove = AdditionalElementsToRemoveFromPacking.Select(e => e.ItemSpec).OrderBy(id => id).ToArray()
            };

            PersistManifest(manifest);

            return(!Log.HasLoggedErrors);
        }
        private void PersistManifest(StaticWebAssetsPackManifest manifest)
        {
            var data                 = JsonSerializer.SerializeToUtf8Bytes(manifest, ManifestSerializationOptions);
            var dataHash             = ComputeHash(data);
            var fileExists           = File.Exists(ManifestPath);
            var existingManifestHash = fileExists ? ComputeHash(File.ReadAllBytes(ManifestPath)) : "";

            if (!fileExists)
            {
                Log.LogMessage(MessageImportance.Low, $"Creating manifest because manifest file '{ManifestPath}' does not exist.");
                File.WriteAllBytes(ManifestPath, data);
            }
            else if (!string.Equals(dataHash, existingManifestHash, StringComparison.Ordinal))
            {
                Log.LogMessage(MessageImportance.Low, $"Updating manifest because manifest version '{dataHash}' is different from existing manifest hash '{existingManifestHash}'.");
                File.WriteAllBytes(ManifestPath, data);
            }
            else
            {
                Log.LogMessage(MessageImportance.Low, $"Skipping manifest update because manifest version '{dataHash}' has not changed.");
            }
        }