I think I already have a solution to this, so I post it here for (constructive) criticism.
function Reinstall-Package { param( [Parameter(Mandatory = $true)] [string] $Id, [Parameter(Mandatory = $true)] [string] $Version, [Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [string] $ProjectName, [switch] $Force ) if (-not $ProjectName) { $ProjectName = (get-project).ProjectName } Uninstall-Package -ProjectName $ProjectName -Id $Id -Force:$Force Install-Package -ProjectName $ProjectName -Id $Id -Version $Version }
This allows us to use the following call to update all package links in the current solution.
Get-Project -All | ?{ $_ | Get-Package | ?{ $_.Id -eq 'Foo.Bar' } } | %{ $_ | Reinstall-Package -Id Foo.Bar -version 1.0.0 -Force }
The -Force switch allows you to reinstall a package, even if it has dependent packages in the project.
Damian Powell Feb 01 '12 at 16:47 2012-02-01 16:47
source share