2017-09-28 37 views
0

例如,我在尋找這樣的命令,將僅更新名爲PackagePrefix開始包:如何在以特定名稱開頭的解決方案中更新所有NuGet包?

Update-Package "PackagePrefix.*" 

我試圖在this blog評論部分提供的腳本,但它扔以下錯誤:

Get-Package | Where Id -like "Contoso.*" | Sort-Object -Property Id -Unique | foreach { Update-Package $_.Id } 
Where-Object : Cannot bind parameter 'FilterScript'. Cannot convert the "Id" value of type "System.String" to type 
"System.Management.Automation.ScriptBlock". 
At line:1 char:20 
+ Get-Package | Where <<<< Id -like "Contoso.*" | Sort-Object -Property Id -Unique | foreach { Update-Package $_.Id } 
    + CategoryInfo   : InvalidArgument: (:) [Where-Object], ParameterBindingException 
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.WhereObjectCommand 
+0

該腳本工作正常,我... – DavidG

+0

我有PowerShell 2.0和3.0的NuGet。由於我的Powershell版本可能是個問題。 – Saravana

回答

0

周圍一點點擺弄之後,我計算過,我使用的是很舊的版本Powershell的(V2.0),並基於the documentation的跟隨着g腳本現在可以工作。我換成WhereWhere-Object

Get-Package | Where-Object {$_.Id -like "Contoso.*"} | Sort-Object -Property Id -Unique | foreach { Update-Package $_.Id } 
相關問題