How to use the azure-pipelines-tool-lib/tool.findLocalToolVersions function in azure-pipelines-tool-lib

To help you get started, we’ve selected a few azure-pipelines-tool-lib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / azure-pipelines-tasks / Tasks / UsePythonV1 / usepythonversion.ts View on Github external
async function useCpythonVersion(parameters: Readonly, platform: Platform): Promise {
    const desugaredversion = desugarDevVersion(parameters.version);
    const semanticversion: string = pythonVersionToSemantic(desugaredversion);
    task.debug(`Semantic version spec of ${parameters.version} is ${semanticversion}`);

    const installDir: string | null = tool.findLocalTool('Python', semanticversion, parameters.architecture);

    console.log('INSTALL DIR - ' + installDir);

    if (!installDir) {
        // Fail and list available versions
        const x86Versions = tool.findLocalToolVersions('Python', 'x86')
            .map(s => `${s} (x86)`)
            .join(os.EOL);

        const x64Versions = tool.findLocalToolVersions('Python', 'x64')
            .map(s => `${s} (x64)`)
            .join(os.EOL);

        throw new Error([
            task.loc('VersionNotFound', parameters.version, parameters.architecture),
            task.loc('ListAvailableVersions', task.getVariable('Agent.ToolsDirectory')),
            x86Versions,
            x64Versions,
            task.loc('ToolNotFoundMicrosoftHosted', 'Python', 'https://aka.ms/hosted-agent-software'),
            task.loc('ToolNotFoundSelfHosted', 'Python', 'https://go.microsoft.com/fwlink/?linkid=871498')
        ].join(os.EOL));
    }
github microsoft / azure-pipelines-tasks / Tasks / UsePythonV1 / usepythonversion.ts View on Github external
async function useCpythonVersion(parameters: Readonly, platform: Platform): Promise {
    const desugaredversion = desugarDevVersion(parameters.version);
    const semanticversion: string = pythonVersionToSemantic(desugaredversion);
    task.debug(`Semantic version spec of ${parameters.version} is ${semanticversion}`);

    const installDir: string | null = tool.findLocalTool('Python', semanticversion, parameters.architecture);

    console.log('INSTALL DIR - ' + installDir);

    if (!installDir) {
        // Fail and list available versions
        const x86Versions = tool.findLocalToolVersions('Python', 'x86')
            .map(s => `${s} (x86)`)
            .join(os.EOL);

        const x64Versions = tool.findLocalToolVersions('Python', 'x64')
            .map(s => `${s} (x64)`)
            .join(os.EOL);

        throw new Error([
            task.loc('VersionNotFound', parameters.version, parameters.architecture),
            task.loc('ListAvailableVersions', task.getVariable('Agent.ToolsDirectory')),
            x86Versions,
            x64Versions,
            task.loc('ToolNotFoundMicrosoftHosted', 'Python', 'https://aka.ms/hosted-agent-software'),
            task.loc('ToolNotFoundSelfHosted', 'Python', 'https://go.microsoft.com/fwlink/?linkid=871498')
        ].join(os.EOL));
    }

    task.setVariable('pythonLocation', installDir);

    // Append to path
github jfrog / artifactory-vsts-extension / tasks / ArtifactoryNuget / nugetBuild.js View on Github external
let RunTaskCbk = async(function (cliPath) {
    let nugetCommand = tl.getInput("command");
    let nugetExec = tl.which("nuget", false);
    if (!nugetExec && nugetCommand.localeCompare("restore") === 0) {
        let localVersions = toolLib.findLocalToolVersions(NUGET_TOOL_NAME);
        if (localVersions === undefined || localVersions.length === 0) {
            await(downloadAndRunNuget(cliPath, nugetCommand));
        } else {
            console.log("The following version/s " + localVersions + " were found on the build agent");
            addToPathAndExec(cliPath, nugetCommand, localVersions[localVersions.length - 1]);
        }
    } else {
        exec(cliPath, nugetCommand);
    }
});