Example #1
0
        private static void AppendMetadata(ZipArchive archive, ApplicationPackageDefinition definition, string version)
        {
            var metadata = new ApplicationPackage {
                Id          = definition.Id,
                Name        = definition.Name,
                Description = definition.Description,
                Version     = version,
            };

            PackageTools.AppendMetadata(archive, metadata, version);
        }
Example #2
0
        /// <summary>
        /// Creates an Application Package using the specified
        /// definition file.
        /// </summary>
        /// <param name="version">The version of the package to create.</param>
        /// <param name="outputFilename">The file name of the output package.</param>
        public static async Task CreatePackage(ApplicationPackageDefinition definition, string rootPath, string version, string outputFilename)
        {
            var outputFilenameFull = Path.GetFullPath(outputFilename);
            var outputPath         = Path.GetDirectoryName(outputFilenameFull);

            if (string.IsNullOrEmpty(outputPath))
            {
                throw new ApplicationException("Empty package output path!");
            }

            PathEx.CreatePath(outputPath);

            await PackageTools.WriteArchive(outputFilename, async archive => {
                AppendMetadata(archive, definition, version);

                foreach (var fileDefinition in definition.Files)
                {
                    var destPath = Path.Combine("bin", fileDefinition.Destination);

                    await PackageTools.AddFiles(archive, rootPath, fileDefinition.Path, destPath, fileDefinition.Exclude?.ToArray());
                }
            });
        }