Example #1
0
        /// <summary>
        /// Checks chocolatey for updates of this instance.
        /// </summary>
        public void Update()
        {
            var info = new ChocolateyInfo(Packagename);

            if (info.Version > new Version(Version) && ChocolateySupport)
            {
                if (!string.IsNullOrEmpty(info.Powershell.URL86))
                {
                    ChocolateyDownloader.StartDownload(info.Powershell.URL86, $"{BasePath}{Executable}", Packagename);
                }

                if (!string.IsNullOrEmpty(info.Powershell.URL64))
                {
                    ChocolateyDownloader.StartDownload(info.Powershell.URL64, $"{BasePath}{Executablex64}",
                                                       $"{Packagename} x64");
                }

                Version = info.Version.ToString();
                Save(BasePath + FileName);
                NLogger.Debug($"{Packagename} is being updated.");
            }
            else
            {
                NLogger.Debug($"{Packagename} does not need updates");
            }
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Chocolatey"/> class.
        /// </summary>
        /// <param name="pap">The package name to download.</param>
        public Chocolatey(string pap)
        {
            if (pap.Contains("."))
            {
                _nLogger.Info("Expected chocolatey package name, but got a file instead.");
                throw new Exception("Expected chocolatey package name, but got a file instead.");
            }

            Directory.CreateDirectory($"Downloads\\{pap}");

            PackageName           = pap;
            CPaths.PowerShellFile = @"tools\chocolateyInstall.ps1";
            CPaths.CompressedFile = $"{pap}.upackage";
            CPaths.PackageFile    = $"{pap}.nuspec";
            ChocolateyInfo        = new ChocolateyInfo(PackageName);
        }