【问题标题】:Can you script NuGet's update-package cmdlet to update or reinstall?您可以编写 NuGet 的 update-package cmdlet 脚本来更新或重新安装吗?
【发布时间】:2018-08-08 03:00:31
【问题描述】:

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

类似的东西

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

但我看不到 update-package 允许我执行此操作的任何返回值。

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

【问题讨论】:

    标签: visual-studio-2015 nuget


    【解决方案1】:

    我认为我能做的最好的就是像使用 Get-Package

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-04
      • 1970-01-01
      • 2019-01-30
      • 2023-03-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多