Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specifying the local filename when downloading the installer archive.… #7640

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions Tasks/DotNetCoreInstallerV0/dotnetcoreinstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as utilities from "./utilities";

import * as os from 'os';
import * as path from 'path';
import * as url from "url";

class DotnetCoreInstaller {
constructor(packageType, version) {
Expand Down Expand Up @@ -90,13 +91,14 @@ class DotnetCoreInstaller {
private async downloadAndInstall(downloadUrls: string[]) {
let downloaded = false;
let downloadPath = "";
for (var i = 0; i < downloadUrls.length; i++) {

for (const url of downloadUrls) {
try {
downloadPath = await toolLib.downloadTool(downloadUrls[i]);
downloadPath = await toolLib.downloadTool(url, this.getFileName(url));
downloaded = true;
break;
} catch (error) {
tl.warning(tl.loc("CouldNotDownload", downloadUrls[i], JSON.stringify(error)));
tl.warning(tl.loc("CouldNotDownload", url, JSON.stringify(error)));
}
}

Expand All @@ -115,6 +117,12 @@ class DotnetCoreInstaller {
return cachedDir;
}

private getFileName(x: string) {
const pathname = url.parse(x).pathname;
const parts = pathname.split('/');
return parts[parts.length - 1];
}

private packageType: string;
private version: string;
private cachedToolName: string;
Expand Down