我正在为 VSTS 构建一个自定义发布任务。我正在使用Node和Typescript构建它。在我的任务中,有什么方法可以下载 NuGet 包?像这样:
import nuget = require('nuget-lib');
import tl = require('vsts-task-lib/task');
async function run() {
try {
console.log('Starting... Will try to download latest nuget.')
const package = nuget.fetch('Microsoft.EntityFrameworkCore.Tools');
// Do stuff with package...
console.log('Task done!');
}
catch (err) {
tl.setResult(tl.TaskResult.Failed, err.message);
}
}
run();
我的任务需要 NuGet 包中的一些内容,我不希望将其包含在包本身中,因为如果 NuGet 包更新,我需要更新包。
我知道我可以让我的构建步骤在工件中包含必要的包,但我希望我的发布步骤能够在没有这些依赖项的情况下运行。
只需在代码中调用 nuget.exe install 命令,类似于 NuGet 任务:VSTS-tasks/Tasks/NuGet