Chocolatey is Great
On a side note before we start I’d recommend Chocolatey as an application delivery packaging system to anyone. Far more friendly and easy to use both on the frontend and backend than any other tool I’ve used including SCCM, Symantec Altiris, AppV, AppStack, etc.
Now to the task at hand: You’ve updated a Chocolatey package from its source folder and want to repack it. Lets do that with some PowerShell script.
What Do You Need From Me?
- Make sure to put the proper path in the script by replacing unc with your own.
- Confirm your package works
- If not rinse and repeat. Update the source, repack, retry, until good.
There is a few more tips to give on Chocolatey. Just to drop one I have setup a User & System ran login script, both that run at user login, to drop in choco lines to correct or add new software on the fly. In short instantly deploying a new piece of software across 7,000 VM’s. Many cool things can be done with Chocolatey if you think creatively.
Best Regards
Michael Wood
#------The setup------------
Clear-Host
Write-Host ""
Write-Host " Chocolatey Repackage Utility" -ForegroundColor Cyan
Write-Host "============================================"
Write-Host ""
Write-Host " Why? To repackage an existing Chocolatey" -ForegroundColor Yellow
Write-Host " Package quick like." -ForegroundColor Yellow
Write-Host ""
Write-Host " This only works for packages already made!" -Foreground Red
Write-Host "============================================"
$PackMe = Read-Host -Prompt ' Repack Name (ie, pdfsambasic)'
Write-Host ""
Write-Host ""
#-------Do the work---------
Write-Host " Results..." -Foreground Cyan
Write-Host "============================================"
Choco Pack \\unc\Source\$PackMe\$PackMe.nuspec
$NewPackage = Get-ChildItem -Path "." -Filter $PackMe*.nupkg | ForEach {$_.Name}
$Overwrite = Test-Path -LiteralPath "\\unc\Packages\$NewPackage"
If ($Overwrite){
Write-Host "File already exist named $PackMe.nupkg. You'll be prompted if you'd like to overwrite." -ForegroundColor Yellow
Move-Item .\$NewPackage -Destination \\unc\Packages -Confirm -Force}
Else {
Move-Item .\$NewPackage -Destination "\\unc\Packages"
Write-Host "$NewPackage now available in \\unc\Packages" -Foreground Yellow}
Start-Process "\\unc\Packages"
Write-Host "============================================"
Write-Host ""
Write-Host ""
Write-Host " Done! Good-bye." -ForegroundColor Green
Pause