Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
console.log(tl.loc("ToolToInstall", packageType, versionSpec));
var versionSpecParts = new VersionParts(versionSpec);
let versionFetcher = new DotNetCoreVersionFetcher();
let versionInfo: VersionInfo = await versionFetcher.getVersionInfo(versionSpecParts.versionSpec, packageType, includePreviewVersions);
if (!versionInfo) {
throw tl.loc("MatchingVersionNotFound", versionSpecParts.versionSpec);
}
let dotNetCoreInstaller = new VersionInstaller(packageType, installationPath);
if (!dotNetCoreInstaller.isVersionInstalled(versionInfo.getVersion())) {
await dotNetCoreInstaller.downloadAndInstall(versionInfo, versionFetcher.getDownloadUrl(versionInfo));
}
toolLib.prependPath(installationPath);
// By default disable Multi Level Lookup unless user wants it enabled.
let performMultiLevelLookup = tl.getBoolInput("performMultiLevelLookup", false);
tl.setVariable("DOTNET_MULTILEVEL_LOOKUP", !performMultiLevelLookup ? "0" : "1");
// Add dot net tools path to "PATH" environment variables, so that tools can be used directly.
addDotNetCoreToolPath();
// Set DOTNET_ROOT for dotnet core Apphost to find runtime since it is installed to a non well-known location.
tl.setVariable('DOTNET_ROOT', installationPath);
}
let toolPath: string;
toolPath = toolLib.findLocalTool('go', normalizeVersion(version));
if (!toolPath) {
// download, extract, cache
toolPath = await acquireGo(version);
tl.debug("Go tool is cached under " + toolPath);
}
setGoEnvironmentVariables(toolPath);
toolPath = path.join(toolPath, 'bin');
//
// prepend the tools path. instructs the agent to prepend for future tasks
//
toolLib.prependPath(toolPath);
}
async function configureDocker() {
var version = tl.getInput("dockerVersion", true);
var releaseType = tl.getInput("releaseType", true);
var dockerPath = await utils.downloadDocker(version, releaseType);
// prepend the tools path. instructs the agent to prepend for future tasks
if (!process.env['PATH'].startsWith(path.dirname(dockerPath))) {
toolLib.prependPath(path.dirname(dockerPath));
}
}
async function configureBuildctl() {
tl.debug("configuring buildctl");
var stableBuildKitVersion = await utils.getStableBuildctlVersion();
var buildctlPath = await utils.downloadBuildctl(stableBuildKitVersion);
// prepend the tools path. instructs the agent to prepend for future tasks
if (!process.env['PATH'].startsWith(path.dirname(buildctlPath))) {
toolLib.prependPath(path.dirname(buildctlPath));
}
}
async function downloadFuncTools() {
const version = await utils.getFuncToolsVersion();
const funcToolsPath = await utils.downloadFuncTools(version);
// prepend the tools path. instructs the agent to prepend for future tasks
if (!process.env['PATH'].startsWith(path.dirname(funcToolsPath))) {
toolLib.prependPath(path.dirname(funcToolsPath));
}
}
let toolPath: string;
toolPath = toolLib.findLocalTool('go', fixVersion(version));
if (!toolPath) {
// download, extract, cache
toolPath = await acquireGo(version);
tl.debug("Go tool is cached under " + toolPath);
}
setGoEnvironmentVariables(toolPath);
toolPath = path.join(toolPath, 'bin');
//
// prepend the tools path. instructs the agent to prepend for future tasks
//
toolLib.prependPath(toolPath);
}
function addDotNetCoreToolPath() {
try {
let globalToolPath: string = "";
if (tl.osType().match(/^Win/)) {
globalToolPath = path.join(process.env.USERPROFILE, Constants.relativeGlobalToolPath);
} else {
globalToolPath = path.join(process.env.HOME, Constants.relativeGlobalToolPath);
}
console.log(tl.loc("PrependGlobalToolPath"));
tl.mkdirP(globalToolPath);
toolLib.prependPath(globalToolPath);
} catch (error) {
//nop
console.log(tl.loc("ErrorWhileSettingDotNetToolPath", JSON.stringify(error)));
}
}
//extract assemblies
const extractRoot: string = await toolLib.extractZip(temp);
console.log('yuniql/var_extractRoot: ' + extractRoot);
//cache assemblies
if (version != 'latest') {
toolLib.cacheDir(extractRoot, "yuniql", version);
} else {
//use v0.0.0 as placeholder for latest version
//TODO: always replace the current cached version for now
toolLib.cleanVersion('v0.0.0');
toolLib.cacheDir(extractRoot, "yuniql", 'v0.0.0');
}
//append PATH
toolLib.prependPath(extractRoot);
}
}
catch (error) {
console.log('yuniql/error: ' + error.message);
taskLib.setResult(taskLib.TaskResult.Failed, error.message);
}
}
toolPath = toolLib.findLocalTool('tfx', version);
}
if (!toolPath) {
toolPath = await acquireTfx(version);
}
}
if (os.platform() !== "win32")
{
toolPath = path.join(toolPath, "/node_modules/.bin/");
}
taskLib.setVariable("__tfxpath", toolPath, false);
toolLib.prependPath(toolPath);
}