示例#1
0
        public (bool result, string packageFileName) Execute(string outputDirectory, IReadOnlyList <MsBuildPackageReference> packageReferences)
        {
            using (var hasher = new Hasher())
            {
                if (!Directory.Exists(outputDirectory))
                {
                    log.Error($"The output directory {outputDirectory} does not exist");
                    return(false, null);
                }

                var packages = GetPackages(hasher, packageReferences);

                var packageHash = hasher.GetPackageCombinationHash(AssemblyVersion, packages);
                log.Normal($"Hash of the package combination is {packageHash}");

                var destination = Path.Combine(outputDirectory, $"Calamari.{packageHash}.zip");
                if (File.Exists(destination))
                {
                    log.Normal("Calamari zip with the right package combination hash already exists");
                    return(true, destination);
                }

                DeleteExistingCalamariZips(destination);

                log.Normal("Scanning Calamari Packages");

                var indexEntries = packages.SelectMany(p => p.GetSourceFiles(log)).ToArray();

                log.Normal("Creating consolidated Calamari package");
                var sw = Stopwatch.StartNew();

                ConsolidatedPackageCreator.Create(indexEntries, destination);

                log.Normal($"Package creation took {sw.ElapsedMilliseconds:n0}ms");

                foreach (var item in indexEntries.Select(i => new { i.PackageId, i.Platform }).Distinct())
                {
                    log.Normal($"Packaged {item.PackageId} for {item.Platform}");
                }

                return(true, destination);
            }
        }