private async Task <string> CreateZipArchiveOfFolder(
            IZipArchiveManager zipArchiveManager,
            IFileSystem fileSystem,
            string folderToZip,
            string injectedCommands)
        {
            if (!fileSystem.DirectoryExists(folderToZip))
            {
                Log.LogError($"Cannot find path containing app: '{folderToZip}'");
                return(string.Empty);
            }

            string appFolderDirectory = fileSystem.GetDirectoryName(folderToZip);
            string fileName           = $"xharness-app-payload-{fileSystem.GetFileName(folderToZip).ToLowerInvariant()}.zip";
            string outputZipPath      = fileSystem.PathCombine(appFolderDirectory, fileName);

            if (fileSystem.FileExists(outputZipPath))
            {
                Log.LogMessage($"Zip archive '{outputZipPath}' already exists, overwriting..");
                fileSystem.DeleteFile(outputZipPath);
            }

            zipArchiveManager.ArchiveDirectory(folderToZip, outputZipPath, true);

            Log.LogMessage($"Adding the XHarness job scripts into the payload archive");
            await zipArchiveManager.AddResourceFileToArchive <CreateXHarnessAppleWorkItems>(outputZipPath, ScriptNamespace + EntryPointScript, EntryPointScript);

            await zipArchiveManager.AddResourceFileToArchive <CreateXHarnessAppleWorkItems>(outputZipPath, ScriptNamespace + RunnerScript, RunnerScript);

            await zipArchiveManager.AddContentToArchive(outputZipPath, CustomCommandsScript + ".sh", injectedCommands);

            return(outputZipPath);
        }
Exemplo n.º 2
0
        private async Task <string> CreateZipArchiveOfFolder(
            IZipArchiveManager zipArchiveManager,
            IFileSystem fileSystem,
            string workItemName,
            bool isAlreadyArchived,
            string folderToZip,
            string injectedCommands)
        {
            string appFolderDirectory = fileSystem.GetDirectoryName(folderToZip);
            string fileName           = $"xharness-app-payload-{workItemName.ToLowerInvariant()}.zip";
            string outputZipPath      = fileSystem.PathCombine(appFolderDirectory, fileName);

            if (fileSystem.FileExists(outputZipPath))
            {
                Log.LogMessage($"Zip archive '{outputZipPath}' already exists, overwriting..");
                fileSystem.DeleteFile(outputZipPath);
            }

            if (!isAlreadyArchived)
            {
                zipArchiveManager.ArchiveDirectory(folderToZip, outputZipPath, true);
            }
            else
            {
                Log.LogMessage($"App payload '{workItemName}` has already been zipped. Copying to '{outputZipPath}` instead");
                fileSystem.FileCopy(folderToZip, outputZipPath);
            }

            Log.LogMessage($"Adding the XHarness job scripts into the payload archive");
            await zipArchiveManager.AddResourceFileToArchive <CreateXHarnessAppleWorkItems>(outputZipPath, ScriptNamespace + EntryPointScript, EntryPointScript);

            await zipArchiveManager.AddResourceFileToArchive <CreateXHarnessAppleWorkItems>(outputZipPath, ScriptNamespace + RunnerScript, RunnerScript);

            await zipArchiveManager.AddContentToArchive(outputZipPath, CustomCommandsScript + ".sh", injectedCommands);

            return(outputZipPath);
        }