public override async Task <bool> InstallAsync() { // A very basic method of installing a package. It has issues, for example Win32 installers // won't be run silently, but it's better than an error. // Make sure installer is downloaded Guard.IsTrue(Status.IsAtLeast(PackageStatus.Downloaded), nameof(Status)); bool success = false; Models.InstallerType typeReduced = Type.Reduce(); if (typeReduced == Models.InstallerType.Win32) { success = await Win32Helper.Install(this); } else if (typeReduced == Models.InstallerType.Msix) { success = await PackagedInstallerHelper.Install(this); } if (success) { Status = PackageStatus.Installed; } return(success); }
/// <summary> /// Determines the <see cref="InstallerType"/> of the downloaded package. /// Requires <see cref="PackageBase.Status"/> to be <see cref="PackageStatus.Downloaded"/>. /// </summary> /// <returns>The file extension that corresponds with the determined <see cref="InstallerType"/>.</returns> public async Task <string> GetInstallerType() { Guard.IsTrue(Status.IsAtLeast(PackageStatus.Downloaded), nameof(Status)); if (Type == InstallerType.Unknown) { Type = PackagedInstallerHelper.GetInstallerType((FileInfo)DownloadItem); } return(Type.GetExtension()); }
public override async Task <ImageBase> CacheAppIcon() { try { Guard.IsTrue(Status.IsAtLeast(PackageStatus.Downloaded), nameof(Status)); return(PackagedInstallerHelper.GetAppIcon( (FileInfo)DownloadItem, Type.HasFlag(InstallerType.Bundle))); } catch { return(TextImage.CreateFromName(Title, ImageType.Logo)); } }
public override async Task <bool> CanLaunchAsync() { Guard.IsNotNull(PackageFamilyName, nameof(PackageFamilyName)); try { return(await PackagedInstallerHelper.IsInstalled(PackageFamilyName)); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine($"Error checking if {PackageFamilyName} is installed. Error:\r\n{ex}"); return(false); } }
public override async Task LaunchAsync() { Guard.IsNotNull(PackageFamilyName, nameof(PackageFamilyName)); await PackagedInstallerHelper.Launch(PackageFamilyName); }
public override async Task <bool> InstallAsync() { // Make sure installer is downloaded Guard.IsTrue(Status.IsAtLeast(PackageStatus.Downloaded), nameof(Status)); return(await PackagedInstallerHelper.Install(this)); }
public override async Task <string> GetCannotBeInstalledReason() { Guard.IsTrue(Status.IsAtLeast(PackageStatus.Downloaded), nameof(Status)); return(PackagedInstallerHelper.GetCannotBeInstalledReason( (FileInfo)DownloadItem, Type.HasFlag(InstallerType.Bundle))); }