當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript task._writeLine函數代碼示例

本文整理匯總了TypeScript中vsts-task-lib/task._writeLine函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript _writeLine函數的具體用法?TypeScript _writeLine怎麽用?TypeScript _writeLine使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了_writeLine函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: getDistributedTestConfigurations

export function getDistributedTestConfigurations() {
    const dtaConfiguration = {} as models.DtaTestConfigurations;
    initTestConfigurations(dtaConfiguration);

    if (dtaConfiguration.vsTestLocationMethod === utils.Constants.vsTestVersionString && dtaConfiguration.vsTestVersion === '12.0') {
        throw (tl.loc('vs2013NotSupportedInDta'));
    }

    if (dtaConfiguration.tiaConfig.tiaEnabled) {
        tl.warning(tl.loc('tiaNotSupportedInDta'));
        dtaConfiguration.tiaConfig.tiaEnabled = false;
    }
    if (dtaConfiguration.runTestsInIsolation) {
        tl.warning(tl.loc('runTestInIsolationNotSupported'));
    }
    if (dtaConfiguration.otherConsoleOptions) {
        tl.warning(tl.loc('otherConsoleOptionsNotSupported'));
    }

    dtaConfiguration.numberOfAgentsInPhase = 0;
    const totalJobsInPhase = parseInt(tl.getVariable('SYSTEM_TOTALJOBSINPHASE'));
    if (!isNaN(totalJobsInPhase)) {
        dtaConfiguration.numberOfAgentsInPhase = totalJobsInPhase;
    }
    tl._writeLine(tl.loc('dtaNumberOfAgents', dtaConfiguration.numberOfAgentsInPhase));

    dtaConfiguration.dtaEnvironment = initDtaEnvironment();
    return dtaConfiguration;
}
開發者ID:colindembovsky,項目名稱:vsts-tasks,代碼行數:29,代碼來源:taskinputparser.ts

示例2: run

async function run() {
	try {

		tl.setResourcePath(path.join( __dirname, 'task.json'));
		var connectedServiceName = tl.getInput('ConnectedServiceName', true);
		var resourceGroupName: string = tl.getInput("ResourceGroupName", true);
		var loadBalancerName: string = tl.getInput("LoadBalancer", true);
		var action: string = tl.getInput("Action", true);
		var endPointAuthCreds = tl.getEndpointAuthorization(connectedServiceName, true);
		var endpointUrl = tl.getEndpointUrl(connectedServiceName, true);

		var SPN = new Array();
		SPN["servicePrincipalClientID"] = endPointAuthCreds.parameters["serviceprincipalid"];
		SPN["servicePrincipalKey"] = endPointAuthCreds.parameters["serviceprincipalkey"];
		SPN["tenantID"] = endPointAuthCreds.parameters["tenantid"];
		SPN["subscriptionId"] = tl.getEndpointDataParameter(connectedServiceName, 'subscriptionid', true);
		SPN["envAuthUrl"] = tl.getEndpointDataParameter(connectedServiceName, 'environmentAuthorityUrl', true);
		SPN["url"] = tl.getEndpointUrl(connectedServiceName, true);
		
		var nicVm = await getNetworkInterface(SPN, endpointUrl, resourceGroupName);
		tl.debug(`Network Interface - ${nicVm.name}'s configuration details fetched for the virtual machine ${process.env.COMPUTERNAME}`);

		var nicLbBackendPoolConfig = null;
		if (action == "Connect") {
			tl._writeLine(tl.loc("ConnectingVMtoLB", loadBalancerName));
			var lb = await nlbUtility.getLoadBalancer(SPN, endpointUrl, loadBalancerName, resourceGroupName);
			nicLbBackendPoolConfig = lb.properties.backendAddressPools;
		}
		else {
			tl._writeLine(tl.loc("DisconnectingVMfromLB", loadBalancerName));
		}
		nicVm.properties.ipConfigurations[0].properties['loadBalancerBackendAddressPools'] = nicLbBackendPoolConfig;
		var setNIStatus = await nlbUtility.setNetworkInterface(SPN, endpointUrl, nicVm, resourceGroupName);
		tl._writeLine(tl.loc(setNIStatus, nicVm.name));
		tl._writeLine(tl.loc("ActionCompletedSuccefully", action, process.env.COMPUTERNAME, loadBalancerName));
	}
	catch(error) {
		tl.setResult(tl.TaskResult.Failed, error);
	}
}
開發者ID:DarqueWarrior,項目名稱:vsts-tasks,代碼行數:40,代碼來源:nlbtask.ts

示例3: initTestConfigurations

function initTestConfigurations(testConfiguration: models.TestConfigurations) {
    testConfiguration.pathtoCustomTestAdapters = tl.getInput('pathtoCustomTestAdapters');
    testConfiguration.sourceFilter = tl.getDelimitedInput('testAssemblyVer2', '\n', true);
    testConfiguration.testDropLocation = tl.getInput('searchFolder');  
    testConfiguration.testcaseFilter = tl.getInput('testFiltercriteria');
    testConfiguration.settingsFile = tl.getPathInput('runSettingsFile');
    testConfiguration.overrideTestrunParameters = tl.getInput('overrideTestrunParameters');
    testConfiguration.buildConfig = tl.getInput('configuration');
    testConfiguration.buildPlatform = tl.getInput('platform');
    testConfiguration.testRunTitle = tl.getInput('testRunTitle');
    testConfiguration.runInParallel = tl.getBoolInput('runInParallel');
    testConfiguration.runTestsInIsolation = tl.getBoolInput('runTestsInIsolation');
    testConfiguration.tiaConfig = getTiaConfiguration();
    testConfiguration.testSelection = tl.getInput('testSelector');
    testConfiguration.otherConsoleOptions = tl.getInput('otherConsoleOptions');

    if (testConfiguration.testSelection.toLowerCase() === 'testplan') {
        testConfiguration.testplan = parseInt(tl.getInput('testPlan'));
        testConfiguration.testPlanConfigId = parseInt(tl.getInput('testConfiguration'));

        const testSuiteStrings = tl.getDelimitedInput('testSuite', ',', true);
        testConfiguration.testSuites = new Array<number>();
        testSuiteStrings.forEach(element => {
        testConfiguration.testSuites.push(parseInt(element));
        });
    }

    testConfiguration.vsTestLocationMethod = tl.getInput('vstestLocationMethod');
    if (testConfiguration.vsTestLocationMethod === utils.Constants.vsTestVersionString) {
        testConfiguration.vsTestVersion = tl.getInput('vsTestVersion');
        if (utils.Helper.isNullEmptyOrUndefined(testConfiguration.vsTestVersion)) {
            tl._writeLine('vsTestVersion is null or empty');
            throw new Error('vsTestVersion is null or empty');
        }
    } else {
        testConfiguration.vsTestLocation = tl.getInput('vsTestLocation');
    }

        // only to facilitate the writing of unit tests 
    testConfiguration.vs15HelperPath = tl.getVariable('vs15Helper');
    if (!testConfiguration.vs15HelperPath) {
        testConfiguration.vs15HelperPath = path.join(__dirname, 'vs15Helper.ps1');
    }

    testConfiguration.codeCoverageEnabled = tl.getBoolInput('codeCoverageEnabled');
}
開發者ID:DarqueWarrior,項目名稱:vsts-tasks,代碼行數:46,代碼來源:taskinputparser.ts

示例4: trackJobQueued

function trackJobQueued(queueUri: string) {
    tl._writeLine('Tracking progress of job queue: ' + queueUri);
    request.get({ url: queueUri }, function callBack(err, httpResponse, body) {
        if (err) {
            tl.setResult(tl.TaskResult.Failed, err);
        } else if (httpResponse.statusCode != 200) {
            failReturnCode(httpResponse, 'Job progress tracking failed to read job queue');
        } else {
            var parsedBody = JSON.parse(body);
            // canceled is spelled wrong in the body with 2 Ls (checking correct spelling also in case they fix it)
            if (parsedBody.cancelled || parsedBody.canceled) {
                tl.setResult(tl.TaskResult.Failed, 'Jenkins job canceled.');
            }
            var executable = parsedBody.executable;
            if (!executable) {
                // job has not actually been queued yet, keep checking
                setTimeout(function () {
                    trackJobQueued(queueUri);
                }, captureConsolePollInterval);
            } else {
                jenkinsTaskName = parsedBody.task.name;
                jenkinsExecutableNumber = parsedBody.executable.number;
                if (parsedBody.executable.url.indexOf(port) >= 0) {
                	jenkinsExecutableUrl = parsedBody.executable.url
                }
                else{
                	jenkinsExecutableUrl = parsedBody.executable.url.replace('/job', ':' + port + '/job');	
                }
                console.log('Jenkins job started: ' + jenkinsExecutableUrl);

                if (captureConsole) {
                    // start capturing console
                    captureJenkinsConsole(0);
                } else {
                    // no console option, just create link and finish
                    createLinkAndFinish(tl.TaskResult.Succeeded, 'Queued', 'Jenkins job successfully queued: ' + jenkinsExecutableUrl);
                }
            }
        }
    });
}
開發者ID:grawcho,項目名稱:vso-agent-tasks,代碼行數:41,代碼來源:jenkinsqueuejobtask.ts

示例5: getTestSelectorBasedInputs

function getTestSelectorBasedInputs(testConfiguration: models.TestConfigurations) {
    const testSelection = testConfiguration.testSelection.toLowerCase();
    switch (testSelection) {
        case 'testplan':
            tl._writeLine(tl.loc('testSelectorInput', tl.loc('testPlanSelector')));
            testConfiguration.testplan = parseInt(tl.getInput('testPlan'));
            tl._writeLine(tl.loc('testPlanInput', testConfiguration.testplan));

            testConfiguration.testPlanConfigId = parseInt(tl.getInput('testConfiguration'));
            tl._writeLine(tl.loc('testplanConfigInput', testConfiguration.testPlanConfigId));

            const testSuiteStrings = tl.getDelimitedInput('testSuite', ',', true);
            testConfiguration.testSuites = new Array<number>();
            testSuiteStrings.forEach(element => {
                const testSuiteId = parseInt(element);
                tl._writeLine(tl.loc('testSuiteSelected', testSuiteId));
                testConfiguration.testSuites.push(testSuiteId);
            });
            break;
        case 'testassemblies':
            tl._writeLine(tl.loc('testSelectorInput', tl.loc('testAssembliesSelector')));
            testConfiguration.sourceFilter = tl.getDelimitedInput('testAssemblyVer2', '\n', true);
            tl._writeLine(tl.loc('testAssemblyFilterInput', testConfiguration.sourceFilter));

            testConfiguration.testcaseFilter = tl.getInput('testFiltercriteria');
            tl._writeLine(tl.loc('testFilterCriteriaInput', testConfiguration.testcaseFilter));
            break;
        case 'testrun':
            tl._writeLine(tl.loc('testSelectorInput', tl.loc('testRunSelector')));
            testConfiguration.onDemandTestRunId = tl.getInput('tcmTestRun');
            if (parseInt(testConfiguration.onDemandTestRunId) <= 0) {
                throw new Error(tl.loc('testRunIdInvalid', testConfiguration.onDemandTestRunId));
            }
            tl._writeLine(tl.loc('testRunIdInput', testConfiguration.onDemandTestRunId));
            break;
    }
}
開發者ID:colindembovsky,項目名稱:vsts-tasks,代碼行數:37,代碼來源:taskinputparser.ts

示例6: function

 request.get({url: serverEndpointUrl+"crumbIssuer/api/xml?xpath=concat(//crumbRequestField,%22:%22,//crumb)" }, function (err, httpResponse, body) {
     if (err) {
         tl._writeLine('crumb='+crumb);
         tl.setResult(tl.TaskResult.Failed, err);
     } else if (httpResponse.statusCode != 200) {
         failReturnCode(httpResponse, 'crumb request failed.');
     } else {
         crumb = body.replace('Jenkins-Crumb:','');
         console.log('crumb created:' + crumb);
         request.post({ url: jobQueueUrl, headers:{'.crumb':crumb } }, function (err, httpResponse, body) {
             if (err) {
                 tl.setResult(tl.TaskResult.Failed, err);
             } else if (httpResponse.statusCode != 201) {
                 failReturnCode(httpResponse, 'Job creation failed.');
             } else {
                 console.log('Jenkins job queued');
                 var queueUri = httpResponse.headers.location + 'api/json';
                 trackJobQueued(queueUri);
             }
         }).auth(username, password, true);       
     }
 }).auth(username, password, true);    
開發者ID:grawcho,項目名稱:vso-agent-tasks,代碼行數:22,代碼來源:jenkinsqueuejobtask.ts

示例7: checkSuccess

function checkSuccess() {
    var resultUrl
    if (jenkinsExecutableUrl.indexOf(port) >= 0) {
        resultUrl = protocol + username + ':' + password + '@' + jenkinsExecutableUrl.replace(protocol,"") + 'api/json';
        } else {
            resultUrl = protocol + username + ':' + password + '@' + jenkinsExecutableUrl.replace(protocol,"").replace('/job', ':' + port + '/job') + 'api/json';	
        }
    resultUrl = protocol + username + ':' + password + '@' + jenkinsExecutableUrl.replace(protocol,"") + 'api/json';
    tl._writeLine('Tracking completion status of job: ' + resultUrl);
    request.get({ url: resultUrl }, function callBack(err, httpResponse, body) {
        if (err) {
            tl.setResult(tl.TaskResult.Failed, err);
        } else if (httpResponse.statusCode != 200) {
            failReturnCode(httpResponse, 'Job progress tracking failed to read job result');
        } else {
            var parsedBody = JSON.parse(body);
            var resultCode = parsedBody.result;
            if (resultCode) {
                resultCode = resultCode.toUpperCase(); 
                var resultStr = getResultString(resultCode);
                tl.debug(resultUrl + ' resultCode: ' + resultCode + ' resultStr: ' + resultStr);
                var completionMessage = 'Jenkins job: ' + resultCode + ' ' + jobName + ' ' + jenkinsExecutableUrl;
                if (resultCode == "SUCCESS" || resultCode == 'UNSTABLE') {
                    createLinkAndFinish(tl.TaskResult.Succeeded, resultStr, completionMessage);
                } else {
                    createLinkAndFinish(tl.TaskResult.Failed, resultStr, completionMessage);
                }
            } else {
                // result not updated yet -- keep trying
                setTimeout(function () {
                    checkSuccess();
                }, captureConsolePollInterval);
            }
        }
    });
}
開發者ID:grawcho,項目名稱:vso-agent-tasks,代碼行數:36,代碼來源:jenkinsqueuejobtask.ts

示例8: run

async function run() {
    let sshClientConnection: any;
    let cleanUpScriptCmd: string;
    const remoteCmdOptions: RemoteCommandOptions = new RemoteCommandOptions();

    try {
        tl.setResourcePath(path.join(__dirname, 'task.json'));

        //read SSH endpoint input
        const sshEndpoint = tl.getInput('sshEndpoint', true);
        const username: string = tl.getEndpointAuthorizationParameter(sshEndpoint, 'username', false);
        const password: string = tl.getEndpointAuthorizationParameter(sshEndpoint, 'password', true); //passphrase is optional
        const privateKey: string = process.env['ENDPOINT_DATA_' + sshEndpoint + '_PRIVATEKEY']; //private key is optional, password can be used for connecting
        const hostname: string = tl.getEndpointDataParameter(sshEndpoint, 'host', false);
        let port: string = tl.getEndpointDataParameter(sshEndpoint, 'port', true); //port is optional, will use 22 as default port if not specified
        if (!port || port === '') {
            tl._writeLine(tl.loc('UseDefaultPort'));
            port = '22';
        }

        //setup the SSH connection configuration based on endpoint details
        let sshConfig;
        if (privateKey && privateKey !== '') {
            tl.debug('Using private key for ssh connection.');
            sshConfig = {
                host: hostname,
                port: port,
                username: username,
                privateKey: privateKey,
                passphrase: password
            }
        } else {
            //use password
            tl.debug('Using username and password for ssh connection.');
            sshConfig = {
                host: hostname,
                port: port,
                username: username,
                password: password
            }
        }

        //read the run options
        const runOptions: string = tl.getInput('runOptions', true);
        let commands: string[];
        let scriptFile: string;
        let args: string;

        if (runOptions === 'commands') {
            // Split on '\n' and ';', flatten, and remove empty entries
            commands = tl.getDelimitedInput('commands', '\n', true)
                .map(s => s.split(';'))
                .reduce((a, b) => a.concat(b))
                .filter(s => s.length > 0);
        } else if (runOptions === 'inline') {
            let inlineScript: string = tl.getInput('inline', true);
            if (inlineScript && !inlineScript.startsWith('#!')) {
                const bashHeader: string = '#!/bin/bash';
                tl.debug('No script header detected.  Adding: ' + bashHeader);
                inlineScript = bashHeader + os.EOL + inlineScript;
            }
            const tempDir = tl.getVariable('Agent.TempDirectory') || os.tmpdir();
            scriptFile = path.join(tempDir, 'sshscript_' + new Date().getTime()); // default name
            try {
                // Make sure the directory exists or else we will get ENOENT
                if (!fs.existsSync(tempDir))
                {
                    tl.mkdirP(tempDir);
                }
                fs.writeFileSync(scriptFile, inlineScript);
            } catch (err) {
                tl.error(tl.loc('FailedToWriteScript', err.message));
                tryDeleteFile(scriptFile);
                throw err;
            }
        } else {
            scriptFile = tl.getPathInput('scriptPath', true, true);
            args = tl.getInput('args')
        }

        const failOnStdErr: boolean = tl.getBoolInput('failOnStdErr');
        remoteCmdOptions.failOnStdErr = failOnStdErr;

        //setup the SSH connection
        tl._writeLine(tl.loc('SettingUpSshConnection', sshConfig.username, sshConfig.host, sshConfig.port));
        try {
            sshClientConnection = await sshHelper.setupSshClientConnection(sshConfig);
        } catch (err) {
            tl.setResult(tl.TaskResult.Failed, tl.loc('ConnectionFailed', err));
        }

        if (sshClientConnection) {
            //SSH connection successful
            tl._writeLine(tl.loc('SshConnectionSuccessful'));
            if (runOptions === 'commands') {
                //run commands specified by the user
                for (const command of commands) {
                    tl.debug('Running command ' + command + ' on remote machine.');
                    tl._writeLine(command);
                    const returnCode: string = await sshHelper.runCommandOnRemoteMachine(
//.........這裏部分代碼省略.........
開發者ID:Microsoft,項目名稱:vsts-tasks,代碼行數:101,代碼來源:ssh.ts

示例9: run

async function run() {
    let sshHelper: SshHelper;
    try {
        tl.setResourcePath(path.join(__dirname, 'task.json'));

        // read SSH endpoint input
        const sshEndpoint = tl.getInput('sshEndpoint', true);
        const username: string = tl.getEndpointAuthorizationParameter(sshEndpoint, 'username', false);
        const password: string = tl.getEndpointAuthorizationParameter(sshEndpoint, 'password', true); //passphrase is optional
        const privateKey: string = process.env['ENDPOINT_DATA_' + sshEndpoint + '_PRIVATEKEY']; //private key is optional, password can be used for connecting
        const hostname: string = tl.getEndpointDataParameter(sshEndpoint, 'host', false);
        let port: string = tl.getEndpointDataParameter(sshEndpoint, 'port', true); //port is optional, will use 22 as default port if not specified
        if (!port) {
            tl._writeLine(tl.loc('UseDefaultPort'));
            port = '22';
        }

        // set up the SSH connection configuration based on endpoint details
        let sshConfig;
        if (privateKey) {
            tl.debug('Using private key for ssh connection.');
            sshConfig = {
                host: hostname,
                port: port,
                username: username,
                privateKey: privateKey,
                passphrase: password
            }
        } else {
            // use password
            tl.debug('Using username and password for ssh connection.');
            sshConfig = {
                host: hostname,
                port: port,
                username: username,
                password: password
            }
        }

        // contents is a multiline input containing glob patterns
        const contents: string[] = tl.getDelimitedInput('contents', '\n', true);
        const sourceFolder: string = tl.getPathInput('sourceFolder', true, true);
        let targetFolder: string = tl.getInput('targetFolder');

        if (!targetFolder) {
            targetFolder = "./";
        } else {
            // '~/' is unsupported
            targetFolder = targetFolder.replace(/^~\//, "./");
        }

        // read the copy options
        const cleanTargetFolder: boolean = tl.getBoolInput('cleanTargetFolder', false);
        const overwrite: boolean = tl.getBoolInput('overwrite', false);
        const failOnEmptySource: boolean = tl.getBoolInput('failOnEmptySource', false);
        const flattenFolders: boolean = tl.getBoolInput('flattenFolders', false);

        if (!tl.stats(sourceFolder).isDirectory()) {
            throw tl.loc('SourceNotFolder');
        }

        // initialize the SSH helpers, set up the connection
        sshHelper = new SshHelper(sshConfig);
        await sshHelper.setupConnection();

        if (cleanTargetFolder) {
            tl._writeLine(tl.loc('CleanTargetFolder', targetFolder));
            const cleanTargetFolderCmd = 'rm -rf "' + targetFolder + '"/*';
            try {
                await sshHelper.runCommandOnRemoteMachine(cleanTargetFolderCmd, null);
            } catch (err) {
                throw tl.loc('CleanTargetFolderFailed', err);
            }
        }

        // identify the files to copy
        const filesToCopy: string[] = getFilesToCopy(sourceFolder, contents);

        // copy files to remote machine
        if (filesToCopy) {
            tl.debug('Number of files to copy = ' + filesToCopy.length);
            tl.debug('filesToCopy = ' + filesToCopy);

            let failureCount = 0;
            tl._writeLine(tl.loc('CopyingFiles', filesToCopy.length));
            for (const fileToCopy of filesToCopy) {
                try {
                    tl.debug('fileToCopy = ' + fileToCopy);

                    let relativePath;
                    if (flattenFolders) {
                        relativePath = path.basename(fileToCopy);
                    } else {
                        relativePath = fileToCopy.substring(sourceFolder.length)
                            .replace(/^\\/g, "")
                            .replace(/^\//g, "");
                    }
                    tl.debug('relativePath = ' + relativePath);
                    const targetPath = path.posix.join(targetFolder, relativePath);

//.........這裏部分代碼省略.........
開發者ID:Microsoft,項目名稱:vsts-tasks,代碼行數:101,代碼來源:copyfilesoverssh.ts

示例10: main


//.........這裏部分代碼省略.........

        let nugetConfigPath = tl.getPathInput("nugetConfigPath", false, true);
        if (!tl.filePathSupplied("nugetConfigPath")) {
            nugetConfigPath = null;
        }

        // due to a bug where we accidentally allowed nuGetPath to be surrounded by quotes before,
        // locateNuGetExe() will strip them and check for existence there.
        let userNuGetPath = tl.getPathInput("nuGetPath", false, false);
        if (!tl.filePathSupplied("nuGetPath")) {
            userNuGetPath = null;
        }

        let serviceUri = tl.getEndpointUrl("SYSTEMVSSCONNECTION", false);

        // find nuget location to use
        let nuGetPathToUse = ngToolRunner.locateNuGetExe(userNuGetPath);
        let credProviderPath = ngToolRunner.locateCredentialProvider();

        const quirks = await ngToolRunner.getNuGetQuirksAsync(nuGetPathToUse);

        // clauses ordered in this way to avoid short-circuit evaluation, so the debug info printed by the functions
        // is unconditionally displayed
        const useCredProvider = ngToolRunner.isCredentialProviderEnabled(quirks) && credProviderPath;
        const useCredConfig = ngToolRunner.isCredentialConfigEnabled(quirks) && !useCredProvider;

        let accessToken = auth.getSystemAccessToken();
        let urlPrefixes = await locationHelpers.assumeNuGetUriPrefixes(serviceUri);
        tl.debug(`discovered URL prefixes: ${urlPrefixes}`);

        // Note to readers: This variable will be going away once we have a fix for the location service for
        // customers behind proxies
        let testPrefixes = tl.getVariable("NuGetTasks.ExtraUrlPrefixesForTesting");
        if (testPrefixes) {
            urlPrefixes = urlPrefixes.concat(testPrefixes.split(";"));
            tl.debug(`all URL prefixes: ${urlPrefixes}`);
        }

        const authInfo = new auth.NuGetAuthInfo(urlPrefixes, accessToken);
        let environmentSettings: ngToolRunner.NuGetEnvironmentSettings = {
            authInfo: authInfo,
            credProviderFolder: useCredProvider ? path.dirname(credProviderPath) : null,
            extensionsDisabled: !userNuGetPath,
        };

        let configFile = nugetConfigPath;
        let credCleanup = () => { return; };
        if (useCredConfig) {
            if (nugetConfigPath) {
                let nuGetConfigHelper = new NuGetConfigHelper(
                    nuGetPathToUse,
                    nugetConfigPath,
                    authInfo,
                    environmentSettings);
                const packageSources = await nuGetConfigHelper.getSourcesFromConfig();

                if (packageSources.length !== 0) {
                    nuGetConfigHelper.setSources(packageSources);
                    credCleanup = () => tl.rmRF(nuGetConfigHelper.tempNugetConfigPath, true);
                    configFile = nuGetConfigHelper.tempNugetConfigPath;
                }
            }
            else {
                if (credProviderPath) {
                    tl.warning(tl.loc("Warning_NoConfigForOldNuGet"));
                }
                else {
                    tl._writeLine(tl.loc("Warning_NoConfigForNoCredentialProvider"));
                }
            }
        }

        try {
            let restoreOptions = new RestoreOptions(
                restoreMode,
                nuGetPathToUse,
                configFile,
                noCache,
                verbosity,
                nuGetRestoreArgs,
                environmentSettings);

            for (const solutionFile of filesList) {
                await restorePackagesAsync(solutionFile, restoreOptions);
            }
        } finally {
            credCleanup();
        }

        tl.setResult(tl.TaskResult.Succeeded, tl.loc("PackagesInstalledSuccessfully"));
    } catch (err) {
        tl.error(err);

        if (buildIdentityDisplayName || buildIdentityAccount) {
            tl.warning(tl.loc("BuildIdentityPermissionsHint", buildIdentityDisplayName, buildIdentityAccount));
        }

        tl.setResult(tl.TaskResult.Failed, tl.loc("PackagesFailedToInstall"));
    }
}
開發者ID:shashban,項目名稱:vsts-tasks,代碼行數:101,代碼來源:nugetinstaller.ts


注:本文中的vsts-task-lib/task._writeLine函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。