您可以编写 NuGet 的 update-package cmdlet 脚本来更新或重新安装吗?

Can you script NuGet's update-package cmdlet to update or reinstall?

我需要编写脚本 Visual Studio 2015 的包管理器控制台以将自定义包更新到最新版本,如果该包没有更新,请重新安装当前版本。

像这样

$ret = update-package -Id foobar
if ($ret indiciated that no package was updated)
   update-package -Reinstall -Id foobar

但我无法从更新包中看到任何允许我执行此操作的 return 值。

这是一个工作流程的一部分,我让许多开发人员将他们的项目更新到我通过包 foobar 的安装控制的最新已知良好版本。ps1 脚本。

我认为我能做的最好的就是像

这样使用 Get-Package
if ($(Get-Package -Updates|where{$_.Id -eq foobar})) { 
    Update-Package -Id foobar 
}
else {
    Update-Package -Reinstall -Id foobar
}