Пример #1
0
        public async Task <YamlDefinition> CreateFromFile(string filePath, CancellationToken cancellationToken = default)
        {
            var detector = new InstallerTypeDetector();
            var detected = await detector.DetectSetupType(filePath, cancellationToken).ConfigureAwait(false);

            YamlDefinition yaml;

            switch (detected)
            {
            case YamlInstallerType.msi:
                yaml = await Task.Run(() => this.CreateFromMsi(filePath), cancellationToken).ConfigureAwait(false);

                break;

            case YamlInstallerType.none:
            case YamlInstallerType.exe:
            case YamlInstallerType.inno:
            case YamlInstallerType.nullsoft:
            case YamlInstallerType.wix:
                yaml = await Task.Run(() => this.CreateFromExe(filePath), cancellationToken).ConfigureAwait(false);

                yaml.Installers[0].InstallerType = detected;
                break;

            case YamlInstallerType.msix:
            case YamlInstallerType.appx:
                yaml = await this.CreateFromMsix(filePath, cancellationToken).ConfigureAwait(false);

                yaml.Installers[0].InstallerType = detected;
                yaml.MinOperatingSystemVersion   = Version.Parse("10.0.0");
                break;

            default:
                yaml = new YamlDefinition
                {
                    Installers = new List <YamlInstaller>
                    {
                        new YamlInstaller()
                    }
                };
                break;
            }

            yaml.Id = (yaml.Publisher + "." + yaml.Name).Replace(" ", string.Empty);
            yaml.Installers[0].Sha256 = await this.CalculateHashAsync(new FileInfo(filePath), cancellationToken).ConfigureAwait(false);

            if (yaml.License != null && yaml.License.IndexOf("Copy", StringComparison.OrdinalIgnoreCase) == -1 && yaml.License.IndexOf("(C)", StringComparison.OrdinalIgnoreCase) == -1 && yaml.License.IndexOf("http", StringComparison.OrdinalIgnoreCase) == -1)
            {
                yaml.License = "Copyright (C) " + yaml.License;
            }

            return(yaml);
        }
Пример #2
0
        public async Task <YamlManifest> CreateFromFile(string filePath, CancellationToken cancellationToken = default)
        {
            var detector = new InstallerTypeDetector();
            var detected = await detector.DetectSetupType(filePath, cancellationToken).ConfigureAwait(false);

            YamlManifest yaml;

            switch (detected)
            {
            case YamlInstallerType.Msi:
                yaml = await Task.Run(() => this.CreateFromMsi(filePath), cancellationToken).ConfigureAwait(false);

                break;

            case YamlInstallerType.None:
            case YamlInstallerType.Exe:
            case YamlInstallerType.InnoSetup:
            case YamlInstallerType.Nullsoft:
            case YamlInstallerType.Wix:
                yaml = await Task.Run(() => this.CreateFromExe(filePath), cancellationToken).ConfigureAwait(false);

                yaml.Installers[0].InstallerType = detected;
                break;

            case YamlInstallerType.Msix:
            case YamlInstallerType.Appx:
                yaml = await this.CreateFromMsix(filePath, cancellationToken).ConfigureAwait(false);

                yaml.Installers[0].InstallerType   = detected;
                yaml.MinimumOperatingSystemVersion = Version.Parse("10.0.0");
                break;

            default:
                yaml = new YamlManifest
                {
                    Installers = new List <YamlInstaller>
                    {
                        new YamlInstaller()
                    }
                };
                break;
            }

            yaml.PackageIdentifier             = (yaml.Publisher + "." + yaml.PackageName).Replace(" ", string.Empty);
            yaml.Installers[0].InstallerSha256 = await this.CalculateHashAsync(new FileInfo(filePath), cancellationToken).ConfigureAwait(false);

            if (yaml.Copyright != null && yaml.Copyright.IndexOf("Copy", StringComparison.OrdinalIgnoreCase) == -1 && yaml.Copyright.IndexOf("(C)", StringComparison.OrdinalIgnoreCase) == -1 && yaml.Copyright.IndexOf("http", StringComparison.OrdinalIgnoreCase) == -1)
            {
                yaml.Copyright = "Copyright (C) " + yaml.Copyright;
            }

            return(yaml);
        }
Пример #3
0
        public void TestInno()
        {
            var sd = new InstallerTypeDetector();

            var resources = typeof(InstallerTypeDetectorTests).Assembly.GetManifestResourceNames();
            var inno      = resources.First(r => r.IndexOf("inno", StringComparison.OrdinalIgnoreCase) != -1);

            using (var s = typeof(InstallerTypeDetectorTests).Assembly.GetManifestResourceStream(inno))
            {
                var detect = sd.DetectSetupType(s).Result;
                Assert.AreEqual(YamlInstallerType.InnoSetup, detect);
            }
        }