/// <inheritdoc /> /// <summary> /// Downloads and unpacks the specified plugin version. /// </summary> /// <param name="version">The version to download.</param> public async Task Download(Version version) { var src = Path.Combine(Environment.CurrentDirectory, this.repo.Path); var dst = Path.Combine(Environment.CurrentDirectory, Program.PluginPath, ".staging", this.name.Vendor, this.name.Project); new DirectoryInfo(src).Copy(dst); await Task.FromResult(0); }
/// <inheritdoc /> /// <summary> /// Downloads and unpacks the specified release version. /// </summary> /// <param name="version">The version to download.</param> public async Task Download(Version version) { var releases = await GetReleases(); var release = releases.First(r => !r.Prerelease && !r.Draft && r.Assets.Any(a => a.Name.EndsWith(".zip"))); var asset = release.Assets.First(a => a.Name.EndsWith(".zip")); var file = Path.Combine(Environment.CurrentDirectory, Program.PluginPath, ".staging", this.name.Vendor, this.name.Project, asset.Name); using (var client = new WebClient()) { await client.DownloadFileTaskAsync(asset.BrowserDownloadUrl, file); } using (var zip = ZipFile.Read(file)) { zip.ExtractAll(Path.Combine(Environment.CurrentDirectory, Program.PluginPath, ".staging", this.name.Vendor, this.name.Project), ExtractExistingFileAction.OverwriteSilently); } File.Delete(file); }