本文整理汇总了TypeScript中vsts-task-lib/task.setResourcePath函数的典型用法代码示例。如果您正苦于以下问题:TypeScript setResourcePath函数的具体用法?TypeScript setResourcePath怎么用?TypeScript setResourcePath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setResourcePath函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: run
// extract
console.log(tl.loc("ExtractingPackage", downloadPath));
let extPath: string = tl.osType().match(/^Win/) ? await toolLib.extractZip(downloadPath) : await toolLib.extractTar(downloadPath);
// cache tool
console.log(tl.loc("CachingTool"));
let cachedDir = await toolLib.cacheDir(extPath, this.cachedToolName, this.version, this.arch);
console.log(tl.loc("SuccessfullyInstalled", this.packageType, this.version));
return cachedDir;
}
private packageType: string;
private version: string;
private cachedToolName: string;
private arch: string;
}
async function run() {
let packageType = tl.getInput('packageType', true);
let version = tl.getInput('version', true).trim();
console.log(tl.loc("ToolToInstall", packageType, version));
await new DotnetCoreInstaller(packageType, version).install();
}
var taskManifestPath = path.join(__dirname, "task.json");
tl.debug("Setting resource path to " + taskManifestPath);
tl.setResourcePath(taskManifestPath);
run()
.then(() => tl.setResult(tl.TaskResult.Succeeded, ""))
.catch((error) => tl.setResult(tl.TaskResult.Failed, !!error.message ? error.message : error));
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:31,代码来源:dotnetcoreinstaller.ts
示例2: main
async function main(): Promise<void> {
let buildIdentityDisplayName: string = null;
let buildIdentityAccount: string = null;
try {
tl.setResourcePath(path.join(__dirname, "task.json"));
// set the console code page to "UTF-8"
if (process.platform === "win32") {
tl.execSync(path.resolve(process.env.windir, "system32", "chcp.com"), ["65001"]);
}
// read inputs
let solution = tl.getPathInput("solution", true, false);
let filesList = nutil.resolveFilterSpec(
solution,
tl.getVariable("System.DefaultWorkingDirectory") || process.cwd());
filesList.forEach(solutionFile => {
if (!tl.stats(solutionFile).isFile()) {
throw new Error(tl.loc("NotARegularFile", solutionFile));
}
});
let noCache = tl.getBoolInput("noCache");
let nuGetRestoreArgs = tl.getInput("nuGetRestoreArgs");
let verbosity = tl.getInput("verbosity");
let restoreMode = tl.getInput("restoreMode") || "Restore";
// normalize the restore mode for display purposes, and ensure it's a known one
let normalizedRestoreMode = ["restore", "install"].find(x => restoreMode.toUpperCase() === x.toUpperCase());
if (!normalizedRestoreMode) {
throw new Error(tl.loc("UnknownRestoreMode", restoreMode));
}
restoreMode = normalizedRestoreMode;
let nugetConfigPath = tl.getPathInput("nugetConfigPath", false, true);
if (!tl.filePathSupplied("nugetConfigPath")) {
nugetConfigPath = null;
}
let nugetVersion = tl.getInput('nuGetVersion');
// 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 nuGetPath = tl.getPathInput("nuGetPath", false, false);
let userNuGetProvided = false;
if(tl.filePathSupplied("nuGetPath")){
nuGetPath = nutil.stripLeadingAndTrailingQuotes(nuGetPath);
// True if the user provided their own version of NuGet
userNuGetProvided = true;
if (nugetVersion !== "custom"){
// For back compat, if a path has already been specificed then use it.
// However warn the user in the build of this behavior
tl.warning(tl.loc("Warning_ConflictingNuGetPreference"));
}
}
else {
if (nugetVersion === "custom")
{
throw new Error(tl.loc("NoNuGetSpecified"))
}
// Pull the pre-installed path for NuGet.
nuGetPath = nutil.getBundledNuGetLocation(nugetVersion);
}
let serviceUri = tl.getEndpointUrl("SYSTEMVSSCONNECTION", false);
//find nuget location to use
let credProviderPath = ngToolRunner.locateCredentialProvider();
const quirks = await ngToolRunner.getNuGetQuirksAsync(nuGetPath);
// 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: !userNuGetProvided
};
let configFile = nugetConfigPath;
let credCleanup = () => { return; };
if (useCredConfig) {
//.........这里部分代码省略.........
开发者ID:HSAR,项目名称:vso-agent-tasks,代码行数:101,代码来源:nugetinstaller.ts
示例3: require
"use strict";
import path = require('path');
import * as tl from "vsts-task-lib/task";
import ContainerConnection from "docker-common/containerconnection";
import AuthenticationTokenProvider from "docker-common/registryauthenticationprovider/authenticationtokenprovider"
import ACRAuthenticationTokenProvider from "docker-common/registryauthenticationprovider/acrauthenticationtokenprovider"
import GenericAuthenticationTokenProvider from "docker-common/registryauthenticationprovider/genericauthenticationtokenprovider"
import Q = require('q');
tl.setResourcePath(path.join(__dirname, 'task.json'));
// Change to any specified working directory
tl.cd(tl.getInput("cwd"));
// get the registry server authentication provider
var registryType = tl.getInput("containerregistrytype", true);
var authenticationProvider : AuthenticationTokenProvider;
if(registryType == "Azure Container Registry"){
authenticationProvider = new ACRAuthenticationTokenProvider(tl.getInput("azureSubscriptionEndpoint"), tl.getInput("azureContainerRegistry"));
}
else {
authenticationProvider = new GenericAuthenticationTokenProvider(tl.getInput("dockerRegistryEndpoint"));
}
var registryAuthenticationToken = authenticationProvider.getAuthenticationToken();
// Connect to any specified container host and/or registry
var connection = new ContainerConnection();
connection.open(tl.getInput("dockerHostEndpoint"), registryAuthenticationToken);
开发者ID:shubham90,项目名称:vsts-tasks,代码行数:31,代码来源:container.ts
示例4: main
async function main(): Promise<void> {
tl.setResourcePath(path.join(__dirname, 'task.json'));
let saveNpmrcPath: string;
let npmrc = tl.getInput(constants.NpmAuthenticateTaskInput.WorkingFile);
let workingDirectory = path.dirname(npmrc);
if (!(npmrc.endsWith('.npmrc'))) {
throw new Error(tl.loc('NpmrcNotNpmrc', npmrc));
}
else if (!tl.exist(npmrc)) {
throw new Error(tl.loc('NpmrcDoesNotExist', npmrc));
}
else {
console.log(tl.loc("AuthenticatingThisNpmrc", npmrc));
}
if (tl.getVariable("SAVE_NPMRC_PATH")) {
saveNpmrcPath = tl.getVariable("SAVE_NPMRC_PATH");
}
else {
let tempPath = tl.getVariable('Agent.BuildDirectory') || tl.getVariable('Agent.ReleaseDirectory') || process.cwd();
tempPath = path.join(tempPath, 'npmAuthenticate');
tl.mkdirP(tempPath);
saveNpmrcPath = fs.mkdtempSync(tempPath + path.sep);
tl.setVariable("SAVE_NPMRC_PATH", saveNpmrcPath, false);
tl.setVariable("NPM_AUTHENTICATE_TEMP_DIRECTORY", tempPath, false);
}
let npmrcTable: Object;
//The index file is a json object that keeps track of where .npmrc files are saved.
//There is a key-value pairing of filepaths of original npmrc files to IDs.
//This is important so multiple runs of the npm Authenticate task on the same .npmrc file actually reverts to the original after the build completes.
let indexFile = path.join(saveNpmrcPath, 'index.json');
if (fs.existsSync(indexFile)) { //If the file exists, add to it.
npmrcTable = JSON.parse(fs.readFileSync(indexFile, 'utf8'));
}
else { //If the file doesn't exist, create it.
npmrcTable = new Object();
npmrcTable['index'] = 0;
}
if (npmrcTable[npmrc] === undefined) {
npmrcTable[npmrc] = npmrcTable['index'];
npmrcTable['index']++;
fs.writeFileSync(indexFile, JSON.stringify(npmrcTable));
util.saveFileWithName(npmrc, npmrcTable[npmrc], saveNpmrcPath);
}
let endpointRegistries: npmregistry.INpmRegistry[] = [];
let endpointIds = tl.getDelimitedInput(constants.NpmAuthenticateTaskInput.CustomEndpoint, ',');
if (endpointIds && endpointIds.length > 0) {
await Promise.all(endpointIds.map(async e => {
endpointRegistries.push(await npmregistry.NpmRegistry.FromServiceEndpoint(e, true));
}));
}
let packagingLocation: pkgLocationUtils.PackagingLocation;
try {
packagingLocation = await pkgLocationUtils.getPackagingUris(pkgLocationUtils.ProtocolType.NuGet);
} catch (error) {
tl.debug('Unable to get packaging URIs, using default collection URI');
tl.debug(JSON.stringify(error));
const collectionUrl = tl.getVariable('System.TeamFoundationCollectionUri');
packagingLocation = {
PackagingUris: [collectionUrl],
DefaultPackagingUri: collectionUrl
};
}
let LocalNpmRegistries = await util.getLocalNpmRegistries(workingDirectory, packagingLocation.PackagingUris);
let npmrcFile = fs.readFileSync(npmrc, 'utf8').split(os.EOL);
for (let RegistryURLString of npmrcparser.GetRegistries(npmrc)) {
let registryURL = URL.parse(RegistryURLString);
let registry: npmregistry.NpmRegistry;
if (endpointRegistries && endpointRegistries.length > 0) {
for (let serviceEndpoint of endpointRegistries) {
if (util.toNerfDart(serviceEndpoint.url) == util.toNerfDart(RegistryURLString)) {
let serviceURL = URL.parse(serviceEndpoint.url);
console.log(tl.loc("AddingEndpointCredentials", registryURL.host));
registry = serviceEndpoint;
npmrcFile = clearFileOfReferences(npmrc, npmrcFile, serviceURL);
break;
}
}
}
if (!registry) {
for (let localRegistry of LocalNpmRegistries) {
if (util.toNerfDart(localRegistry.url) == util.toNerfDart(RegistryURLString)) {
let localURL = URL.parse(localRegistry.url);
console.log(tl.loc("AddingLocalCredentials"));
registry = localRegistry;
npmrcFile = clearFileOfReferences(npmrc, npmrcFile, localURL);
break;
}
}
}
if (registry) {
tl.debug(tl.loc('AddingAuthRegistry', registry.url));
//.........这里部分代码省略.........
开发者ID:shubham90,项目名称:vsts-tasks,代码行数:101,代码来源:npmauth.ts
示例5: main
async function main(): Promise<void> {
let buildIdentityDisplayName: string = null;
let buildIdentityAccount: string = null;
try {
tl.setResourcePath(path.join(__dirname, "task.json"));
// set the console code page to "UTF-8"
if (process.platform === "win32") {
tl.execSync(path.resolve(process.env.windir, "system32", "chcp.com"), ["65001"]);
}
// read inputs
let searchPattern = tl.getPathInput("searchPattern", true, false);
let filesList = nutil.resolveFilterSpec(
searchPattern,
tl.getVariable("System.DefaultWorkingDirectory") || process.cwd());
filesList.forEach(packageFile => {
if (!tl.stats(packageFile).isFile()) {
throw new Error(tl.loc("NotARegularFile", packageFile));
}
});
let connectedServiceName = tl.getInput("connectedServiceName");
let internalFeedUri = tl.getInput("feedName");
let nuGetAdditionalArgs = tl.getInput("nuGetAdditionalArgs");
let verbosity = tl.getInput("verbosity");
let nuGetFeedType = tl.getInput("nuGetFeedType") || "external";
// make sure the feed type is an expected one
let normalizedNuGetFeedType
= ["internal", "external"].find(x => nuGetFeedType.toUpperCase() === x.toUpperCase());
if (!normalizedNuGetFeedType) {
throw new Error(tl.loc("UnknownFeedType", nuGetFeedType));
}
nuGetFeedType = normalizedNuGetFeedType;
// 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 = null;
let apiKey: string;
let feedUri: string;
let credCleanup = () => { return; };
if (nuGetFeedType === "internal") {
if (useCredConfig) {
let nuGetConfigHelper = new NuGetConfigHelper(nuGetPathToUse, null, authInfo, environmentSettings);
nuGetConfigHelper.setSources([{ feedName: "internalFeed", feedUri: internalFeedUri }]);
configFile = nuGetConfigHelper.tempNugetConfigPath;
credCleanup = () => tl.rmRF(nuGetConfigHelper.tempNugetConfigPath, true);
}
apiKey = "VSTS";
feedUri = internalFeedUri;
}
else {
feedUri = tl.getEndpointUrl(connectedServiceName, false);
let externalAuth = tl.getEndpointAuthorization(connectedServiceName, false);
apiKey = externalAuth.parameters["password"];
}
try {
let publishOptions = new PublishOptions(
nuGetPathToUse,
//.........这里部分代码省略.........
开发者ID:shashban,项目名称:vsts-tasks,代码行数:101,代码来源:nugetpublisher.ts
示例6: 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
示例7: main
async function main(): Promise<void> {
let packagingLocation: pkgLocationUtils.PackagingLocation;
try {
packagingLocation = await pkgLocationUtils.getPackagingUris(pkgLocationUtils.ProtocolType.NuGet);
} catch (error) {
tl.debug("Unable to get packaging URIs, using default collection URI");
tl.debug(JSON.stringify(error));
const collectionUrl = tl.getVariable("System.TeamFoundationCollectionUri");
packagingLocation = {
PackagingUris: [collectionUrl],
DefaultPackagingUri: collectionUrl};
}
let buildIdentityDisplayName: string = null;
let buildIdentityAccount: string = null;
try {
tl.setResourcePath(path.join(__dirname, "task.json"));
nutil.setConsoleCodePage();
// read inputs
let searchPattern = tl.getPathInput("searchPattern", true, false);
let allowEmptyNupkgMatch = tl.getBoolInput("continueOnEmptyNupkgMatch");
let filesList = nutil.resolveFilterSpec(
searchPattern,
tl.getVariable("System.DefaultWorkingDirectory") || process.cwd(),
allowEmptyNupkgMatch);
filesList.forEach(packageFile => {
if (!tl.stats(packageFile).isFile()) {
throw new Error(tl.loc("NotARegularFile", packageFile));
}
});
let connectedServiceName = tl.getInput("connectedServiceName");
let internalFeedUri = tl.getInput("feedName");
let nuGetAdditionalArgs = tl.getInput("nuGetAdditionalArgs");
let verbosity = tl.getInput("verbosity");
let nuGetFeedType = tl.getInput("nuGetFeedType") || "external";
// make sure the feed type is an expected one
let normalizedNuGetFeedType
= ["internal", "external"].find(x => nuGetFeedType.toUpperCase() === x.toUpperCase());
if (!normalizedNuGetFeedType) {
throw new Error(tl.loc("UnknownFeedType", nuGetFeedType));
}
nuGetFeedType = normalizedNuGetFeedType;
// 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 nuGetPath = tl.getPathInput("nuGetPath", false, false);
let nugetUxOption = tl.getInput("nuGetversion");
let userNuGetProvided = false;
if (nuGetPath !== null && tl.filePathSupplied("nuGetPath")) {
nuGetPath = nutil.stripLeadingAndTrailingQuotes(nuGetPath);
userNuGetProvided = true;
if (nugetUxOption !== "custom")
{
// For back compat, if a path has already been specified then use it.
// However, warn the user in the build of this behavior.
tl.warning(tl.loc("Warning_ConflictingNuGetPreference"));
}
}
else {
if (nugetUxOption === "custom")
{
throw new Error(tl.loc("NoNuGetSpecified"))
}
nuGetPath = nutil.getBundledNuGetLocation(nugetUxOption);
}
let serviceUri = tl.getEndpointUrl("SYSTEMVSSCONNECTION", false);
//find nuget location to use
let credProviderPath = nutil.locateCredentialProvider();
const quirks = await ngToolRunner.getNuGetQuirksAsync(nuGetPath);
// 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 = packagingLocation.PackagingUris;
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: !userNuGetProvided
//.........这里部分代码省略.........
开发者ID:shubham90,项目名称:vsts-tasks,代码行数:101,代码来源:nugetpublisher.ts
示例8: main
async function main(): Promise<void> {
tl.setResourcePath(path.join(__dirname, "task.json"));
let buildIdentityDisplayName: string = null;
let buildIdentityAccount: string = null;
let command: string = tl.getInput("command", true);
let args: string = tl.getInput("arguments", false);
// Getting NuGet
tl.debug('Getting NuGet');
let nuGetPath: string = undefined;
try {
nuGetPath = process.env[nuGetGetter.NUGET_EXE_TOOL_PATH_ENV_VAR];
if (!nuGetPath){
nuGetPath = await nuGetGetter.getNuGet("4.0.0");
}
}
catch (error) {
tl.setResult(tl.TaskResult.Failed, error.message);
return;
}
const version = await peParser.getFileVersionInfoAsync(nuGetPath);
if(version.productVersion.a < 3 || (version.productVersion.a <= 3 && version.productVersion.b < 5))
{
tl.setResult(tl.TaskResult.Failed, tl.loc("Info_NuGetSupportedAfter3_5", version.strings.ProductVersion));
return;
}
try {
nutil.setConsoleCodePage();
let credProviderPath = nutil.locateCredentialProvider();
// Clauses ordered in this way to avoid short-circuit evaluation, so the debug info printed by the functions
// is unconditionally displayed
const quirks = await ngToolRunner.getNuGetQuirksAsync(nuGetPath);
const useCredProvider = ngToolRunner.isCredentialProviderEnabled(quirks) && credProviderPath;
// useCredConfig not placed here: This task will only support NuGet versions >= 3.5.0 which support credProvider both hosted and OnPrem
let accessToken = auth.getSystemAccessToken();
let serviceUri = tl.getEndpointUrl("SYSTEMVSSCONNECTION", false);
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: true
};
let executionOptions = new NuGetExecutionOptions(
nuGetPath,
environmentSettings,
command,
args);
await runNuGetAsync(executionOptions);
} catch (err) {
tl.error(err);
if (buildIdentityDisplayName || buildIdentityAccount) {
tl.warning(tl.loc("BuildIdentityPermissionsHint", buildIdentityDisplayName, buildIdentityAccount));
}
tl.setResult(tl.TaskResult.Failed, "");
}
}
开发者ID:DarqueWarrior,项目名称:vsts-tasks,代码行数:78,代码来源:nuget.ts
注:本文中的vsts-task-lib/task.setResourcePath函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论