Last active
May 8, 2021 02:44
-
-
Save nehemiahj/bcf8216ec89220113fe7e8d157bf60ba to your computer and use it in GitHub Desktop.
Update Sitecore NuGet Packages For All Projects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function UpdateSitecorePackagesForAllProjects([string] $OldVersion = "9.3.0", [string] $NewVersion = "10.1.0", [string] $Source = "https://sitecore.myget.org/F/sc-packages/api/v3/index.json") { | |
Write-Host "Old Sitecore Package Version - $OldVersion" -BackgroundColor Magenta | |
Write-Host "New Sitecore Package Version - $NewVersion" -BackgroundColor Magenta | |
$projectsList = Get-Package Sitecore. | Select ProjectName -Unique | |
foreach($projNameObject in $projectsList) { | |
$projName = $projNameObject.ProjectName | |
Write-Host "Start inpsecting project - $projName" -BackgroundColor Green | |
$pkgs = Get-Package Sitecore. -ProjectName $projName | |
foreach($pkg in $pkgs) { | |
if($pkg.Version -eq $OldVersion) { | |
$toInstall = $pkg.Id.Replace(".NoReferences", "") | |
Write-Host "Package to install: $toInstall" -BackgroundColor Yellow | |
$exists = Find-Package -Id $toInstall -Source $Source -Version $NewVersion -ExactMatch | |
if($exists -eq $null) { | |
Write-Host "$toInstall does not exist... `n Upgrade $toInstall manually..." -BackgroundColor Red | |
} | |
else { | |
Install-Package $toInstall -Version $NewVersion -ProjectName $projName -Source $Source | |
Write-Host "Package to uninstall: $($pkg.Id)" -BackgroundColor Yellow | |
Uninstall-Package $pkg.Id -Version $OldVersion -ProjectName $projName | |
} | |
} | |
} | |
Write-Host "Finished inpsecting project - $projName" -BackgroundColor Green | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment