本文整理匯總了TypeScript中packaging-common/nuget/NuGetToolGetter.getNuGet函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript getNuGet函數的具體用法?TypeScript getNuGet怎麽用?TypeScript getNuGet使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了getNuGet函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: run
async function run() {
try {
taskLib.setResourcePath(path.join(__dirname, 'task.json'));
const versionSpec = taskLib.getInput('versionSpec', false) || DEFAULT_NUGET_VERSION;
const checkLatest = taskLib.getBoolInput('checkLatest', false);
await nuGetGetter.getNuGet(versionSpec, checkLatest, true);
} catch (error) {
console.error('ERR:' + error.message);
taskLib.setResult(taskLib.TaskResult.Failed, '');
}
}
示例2: installNuGet
public static async installNuGet(version: string) {
try {
const proxy: tl.ProxyConfiguration = tl.getHttpProxyConfiguration();
if (proxy) {
console.log(tl.loc("InstallingNuGetVersion", version));
await nuGetGetter.getNuGet(version, false, true);
NuGetInstaller.setProxy(proxy);
}
}
catch (error) {
throw tl.loc("FailureWhileInstallingNuGetVersion", version, error.message);
}
}
示例3: main
async function main(): Promise<void> {
tl.setResourcePath(path.join(__dirname, "task.json"));
// Getting NuGet
tl.debug("Getting NuGet");
let nuGetPath: string;
let nugetVersion: string;
try {
nuGetPath = tl.getVariable(nuGetGetter.NUGET_EXE_TOOL_PATH_ENV_VAR)
|| tl.getVariable(NUGET_EXE_CUSTOM_LOCATION);
if (!nuGetPath) {
const cachedVersionToUse = await nuGetGetter.cacheBundledNuGet();
nuGetPath = await nuGetGetter.getNuGet(cachedVersionToUse);
}
const nugetVersionInfo: VersionInfo = await peParser.getFileVersionInfoAsync(nuGetPath);
if (nugetVersionInfo && nugetVersionInfo.fileVersion){
nugetVersion = nugetVersionInfo.fileVersion.toString();
}
}
catch (error) {
tl.setResult(tl.TaskResult.Failed, error.message);
return;
} finally{
_logNugetStartupVariables(nuGetPath, nugetVersion);
}
const nugetCommand = tl.getInput("command", true);
switch (nugetCommand) {
case "restore":
nugetRestore.run(nuGetPath);
break;
case "pack":
nugetPack.run(nuGetPath);
break;
case "push":
nugetPublish.run(nuGetPath);
break;
case "custom":
nugetCustom.run(nuGetPath);
break;
default:
tl.setResult(tl.TaskResult.Failed, tl.loc("Error_CommandNotRecognized", nugetCommand));
break;
}
}
示例4: 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 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 nugetUxOption = 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(nuGetPath !== null && tl.filePathSupplied("nuGetPath")){
nuGetPath = nutil.stripLeadingAndTrailingQuotes(nuGetPath);
// True if the user provided their own version of NuGet
userNuGetProvided = true;
if (nugetUxOption !== "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 (nugetUxOption === "custom")
{
throw new Error(tl.loc("NoNuGetSpecified"))
}
// Pull the pre-installed path for NuGet.
let nuGetPathSuffix: string;
let versionToUse: string;
if (nugetUxOption === "4.0.0.2283") {
nuGetPathSuffix = "NuGet/4.0.0/";
versionToUse = "4.0.0";
}
else if (nugetUxOption === "3.5.0.1829") {
nuGetPathSuffix = "NuGet/3.5.0/";
versionToUse = "3.5.0";
}
else if (nugetUxOption === "3.3.0") {
nuGetPathSuffix = "NuGet/3.3.0/";
versionToUse = "3.3.0";
}
else {
throw new Error(tl.loc("NGCommon_UnabletoDetectNuGetVersion"));
}
// save and reset the tool path env var, so this task doesn't act as a tool installer
const tempNuGetPath = tl.getVariable(ngToolGetter.NUGET_EXE_TOOL_PATH_ENV_VAR);
const cachedVersion = await ngToolGetter.cacheBundledNuGet(versionToUse, nuGetPathSuffix);
nuGetPath = await ngToolGetter.getNuGet(cachedVersion);
tl.setVariable(ngToolGetter.NUGET_EXE_TOOL_PATH_ENV_VAR, tempNuGetPath);
}
//find nuget location to use
let credProviderPath = nutil.locateCredentialProvider();
const quirks = await ngToolRunner.getNuGetQuirksAsync(nuGetPath);
//.........這裏部分代碼省略.........