-
-
Save alimbada/449ddf65b4ef9752eff3 to your computer and use it in GitHub Desktop.
#Put this in Export-Chocolatey.ps1 file and run it: | |
#.\Export-Chocolatey.ps1 > packages.config | |
#You can install the packages using | |
#choco install packages.config -y | |
Write-Output "<?xml version=`"1.0`" encoding=`"utf-8`"?>" | |
Write-Output "<packages>" | |
choco list -lo -r -y | % { " <package id=`"$($_.SubString(0, $_.IndexOf("|")))`" version=`"$($_.SubString($_.IndexOf("|") + 1))`" />" } | |
Write-Output "</packages>" |
I created my own take on this kind of system in my own fork. https://gist.github.com/infogulch/0d81c3d4caccf2f1b6a82dc6f6459397
I based the workflow around committing updates to packages.config in git. See the README for details. I even ran the update script for my computer and committed it to demonstrate the intended workflow. You can find this commit in my gist's revisions. (Btw, if you clone your own gist to local you can commit and push back to the gist to update it.)
I disagree Melbourne, versions in packages.config mean you can know exactly what version is installed. Except if it's overwritten every time that information is lost. But if you keep it in a git repo then you get the best of both!
Write-Output "<?xml version=`"1.0`"encoding=`"utf-8`"?>"
Write-Output "<packages>"
choco list -lo -r -y |%{ "<package id=`"$($_.SubString(0,$_.IndexOf("|")))`"version=`"$($_.SubString($_.IndexOf("|") +1))`"/>"}
Write-Output "</packages>"
Out-File -FilePath .\packages.config
I added one line to this little script. Now, when it executes it automatically creates the pachages.config file that can be directly passed to chocolatey .
Just a comment about this feature, and also the ability to install from a package list...
We need the option to omit versions. We will probably want to install the same stuff but with the most recent version.