public override async Task <StepResult> Execute(InstallationState state) { if (!Directory.Exists(state.TargetDirectoryPath)) { Directory.CreateDirectory(state.TargetDirectoryPath); } using (var fileStream = new FileStream(state.Package.Path, FileMode.Open)) { using (var zipArchive = new ZipArchive(fileStream)) { foreach (var entry in zipArchive.Entries) { if (!(entry.FullName.EndsWith("/") && string.IsNullOrEmpty(entry.Name))) { state.UpdateStatus($"Extracting: {entry.Name}"); string fullEntryPath = Path.Combine(state.TargetDirectoryPath, entry.FullName); if (!Directory.Exists(Path.GetDirectoryName(fullEntryPath))) { Directory.CreateDirectory(Path.GetDirectoryName(fullEntryPath)); } using (var entryFileSteam = new FileStream(fullEntryPath, FileMode.Create)) { using (var entryStream = entry.Open()) { await entryStream.CopyToAsync(entryFileSteam); } } } } } } return(StepResult.Success); }
public override Task <StepResult> Execute(InstallationState state) { state.UpdateStatus("Cleaning up."); if (File.Exists(state.Package.Path)) { File.Delete(state.Package.Path); } return(Task.FromResult(StepResult.Success)); }
public override async Task <StepResult> Execute(InstallationState state) { state.UpdateStatus("Downloading package..."); var package = await state.Processor.DownloadPackage(state.ComponentDefinition.Component); if (package != null) { state.Package = package; return(StepResult.Success); } else { return(StepResult.Failure); } }
public override Task <StepResult> Execute(InstallationState state) { state.UpdateStatus("Creating shortcuts..."); var iconPath = Path.Combine(state.TargetDirectoryPath, "Icon.ico"); var wsh = new WshShell(); var shortcut = wsh.CreateShortcut(Path.Combine(targetDirectory, state.ComponentDefinition.ShortName + ".lnk")) as IWshRuntimeLibrary.IWshShortcut; shortcut.TargetPath = Path.Combine(state.TargetDirectoryPath, state.ComponentDefinition.ApplicationFileName); shortcut.WindowStyle = 1; shortcut.Description = state.ComponentDefinition.Description; shortcut.WorkingDirectory = state.TargetDirectoryPath; if (System.IO.File.Exists(iconPath)) { shortcut.IconLocation = iconPath; } shortcut.Save(); return(Task.FromResult(StepResult.Success)); }