Downloads:
348,561,652
Downloads of v 0.9.8.29-alpha1:
727
Last Update:
02 Jan 2015
Package Maintainer(s):
Software Author(s):
- Rob Reynolds
- The Chocolatey Team
Tags:
nuget apt-get machine repository chocolatey- Software Specific:
- Software Site
- Software License
- Package Specific:
- Package outdated?
- Package broken?
- Contact Maintainers
- Contact Site Admins
- Software Vendor?
- Report Abuse
- Download
Chocolatey
This is a prerelease version of Chocolatey.
- 1
- 2
- 3
0.9.8.29-alpha1 | Updated: 02 Jan 2015
- Software Specific:
- Software Site
- Software License
- Package Specific:
- Package outdated?
- Package broken?
- Contact Maintainers
- Contact Site Admins
- Software Vendor?
- Report Abuse
- Download
Downloads:
348,561,652
Downloads of v 0.9.8.29-alpha1:
727
Maintainer(s):
Software Author(s):
- Rob Reynolds
- The Chocolatey Team
Chocolatey 0.9.8.29-alpha1
This is a prerelease version of Chocolatey.
- 1
- 2
- 3
Some Checks Have Failed or Are Not Yet Complete
Not All Tests Have Passed
Validation Testing Unknown
Verification Testing Unknown
Scan Testing Resulted in Investigate
Please visit our documentation to learn how to install/uninstall Chocolatey.
To upgrade Chocolatey, run the following command from the command line or from PowerShell:
This package is exempt from moderation. While it is likely safe for you, there is more risk involved.
Chocolatey is a package manager for Windows (like apt-get but for Windows). It was designed to be a decentralized framework for quickly installing applications and tools that you need. It is built on the NuGet infrastructure currently using PowerShell as its focus for delivering packages from the distros to your door, err computer.
Chocolatey is brought to you by the work and inspiration of the community, the work and thankless nights of the Chocolatey Team (https://github.com/orgs/chocolatey/members), and Rob heading up the direction.
You can host your own sources and add them to chocolatey, you can extend chocolatey's capabilities, and folks, it's only going to get better.
Commands
There are quite a few commands you can call - you should check out the command reference at: https://github.com/chocolatey/chocolatey/wiki/CommandsReference
- Search - choco search something
- List - choco list -lo
- Install - choco install baretail
- Update - choco update baretail
- Uninstall - choco uninstall baretail
- Install ruby gem - choco install compass -source ruby
- Install python egg - choco install sphynx -source python
- Install windows feature - choco install IIS -source windowsfeatures
- Install webpi feature - choco install IIS7.5Express -source webpi
More advanced commands and switches listed on the command reference, including how you can force a package to install the x86 version of a package.
Create Packages?
We have some great guidance on how to do that. Where? I'll give you a hint, it rhymes with sticky! https://github.com/chocolatey/chocolatey/wiki/CreatePackages
In that mess there is a link to the Helper Reference - https://github.com/chocolatey/chocolatey/wiki/HelpersReference
Chocolatey gods?
Humor related to playing off of tiki gods. We like humor. Don't take life so seriously, you will never get out alive.
@echo off
SET DIR=%~dp0%
if '%1'=='/?' goto usage
if '%1'=='-?' goto usage
if '%1'=='?' goto usage
if '%1'=='/help' goto usage
if '%1'=='help' goto usage
if '%1'=='--help' goto usage
SET PS_ARGS=%*
IF NOT '%1'=='' SET PS_ARGS=%PS_ARGS:"=\"%
IF NOT '%1'=='' SET PS_ARGS=%PS_ARGS:\\"=\"%
@PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%DIR%chocolatey.ps1' %PS_ARGS%"
SET ErrLvl=%ERRORLEVEL%
goto :exit
:exit
exit /b %ErrLvl%
goto :eof
:usage
@PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%DIR%chocolatey.ps1' help"
<?xml version="1.0"?>
<chocolatey>
<useNuGetForSources>false</useNuGetForSources>
<checksumFiles>true</checksumFiles>
<virusCheck>false</virusCheck>
<tempLocation></tempLocation>
<sources>
<source id="chocolatey" value="https://chocolatey.org/api/v2/" />
</sources>
</chocolatey>
param(
[parameter(Position=0)]
[string]$command,
[string]$source='',
[string]$version='',
[alias("all")][switch] $allVersions = $false,
[alias("ia","installArgs")][string] $installArguments = '',
[alias("o","override","overrideArguments","notSilent")]
[switch] $overrideArgs = $false,
[alias("f")][switch] $force = $false,
[alias("pre")][switch] $prerelease = $false,
[alias("lo")][switch] $localonly = $false,
[alias("v")][switch] $verbosity = $false,
#[switch] $debug,
[string] $name,
[switch] $ignoreDependencies = $false,
[alias("x86")][switch] $forceX86 = $false,
[alias("params")][alias("parameters")][alias("pkgParams")][string]$packageParameters = '',
[alias("q")][switch] $quiet = $false,
[parameter(Position=1, ValueFromRemainingArguments=$true)]
[string[]]$packageNames=@('')
)
[switch] $debug = $false
if ($PSBoundParameters['Debug']) {
$debug = $true
}
if ($PSBoundParameters['Verbose']) {
$verbosity = $true
}
# chocolatey
# Copyright (c) 2011-Present Rob Reynolds & RealDimensions Software, LLC
# Committers and Contributors: Rob Reynolds, Rich Siegel, Matt Wrock, Anthony Mastrean, Alan Stevens, Gary Ewan Park
# Crediting contributions by Chris Ortman, Nekresh, Staxmanade, Chrissie1, AnthonyMastrean, Rich Siegel, Matt Wrock and other contributors from the community.
# Big thanks to Keith Dahlby for all the powershell help!
# Apache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0
## Set the culture to invariant
$currentThread = [System.Threading.Thread]::CurrentThread;
$culture = [System.Globalization.CultureInfo]::InvariantCulture;
$currentThread.CurrentCulture = $culture;
$currentThread.CurrentUICulture = $culture;
#Let's get Chocolatey!
$chocVer = '0.9.8.29-alpha1'
$nugetChocolateyPath = (Split-Path -parent $MyInvocation.MyCommand.Definition)
$nugetPath = (Split-Path -Parent $nugetChocolateyPath)
$nugetExePath = Join-Path $nuGetPath 'bin'
$nugetLibPath = Join-Path $nuGetPath 'lib'
$badLibPath = Join-Path $nuGetPath 'lib-bad'
$extensionsPath = Join-Path $nugetPath 'extensions'
$chocInstallVariableName = "ChocolateyInstall"
$nugetExe = Join-Path $nugetChocolateyPath 'nuget.exe'
$7zip = Join-Path $nugetChocolateyPath 'tools\7za.exe'
$ShimGen = Join-Path $nugetChocolateyPath 'tools\shimgen.exe'
$checksumExe = Join-Path $nugetChocolateyPath 'tools\checksum.exe'
$h1 = '====================================================='
$h2 = '-------------------------'
$globalConfig = ''
$userConfig = ''
$env:ChocolateyEnvironmentDebug = 'false'
$env:ChocolateyEnvironmentQuiet = 'false'
$RunNote = "DarkCyan"
$Warning = "Magenta"
$ErrorColor = "Red"
$Note = "Green"
$DebugPreference = "SilentlyContinue"
if ($debug) {
$DebugPreference = "Continue";
$env:ChocolateyEnvironmentDebug = 'true'
}
# ensure module loading preference is on
$PSModuleAutoLoadingPreference = "All";
if ($quiet) {
$env:ChocolateyEnvironmentQuiet = 'true'
}
# check permission of process and issue warning - we can't use
# Test-ProcessAdminRights b/c it would use overridden Write-Debug/Write-Host
# which may log into a folder the user doesn't have access to write to.
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent([Security.Principal.TokenAccessLevels]'Query,Duplicate'))
if (!($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))) {
@"
Chocolatey detected you are not running from an elevated command shell
(cmd/powershell). You may experience errors - many functions/packages
require admin rights. Only advanced users should run choco w/out an
elevated shell (and very advanced users as non-admin). When you open
the command shell, you should ensure "Run as Administrator".
"@ | Write-Host -ForegroundColor $Warning -BackgroundColor Black
}
$installModule = Join-Path $nugetChocolateyPath (Join-Path 'helpers' 'chocolateyInstaller.psm1')
Import-Module $installModule
# grab functions from files
Resolve-Path $nugetChocolateyPath\functions\*.ps1 |
? { -not ($_.ProviderPath.Contains(".Tests.")) } |
% { . $_.ProviderPath }
# load extensions if they exist
if(Test-Path($extensionsPath)) {
Write-Debug 'Loading community extensions'
#Resolve-Path $extensionsPath\**\*\*.psm1 | % { Write-Debug "Importing `'$_`'"; Import-Module $_.ProviderPath }
Get-ChildItem $extensionsPath -recurse -filter "*.psm1" | Select -ExpandProperty FullName | % { Write-Debug "Importing `'$_`'"; Import-Module $_; }
}
# issue deprecation Warning
if ($nugetPath -eq (Join-Path $env:SystemDrive 'chocolatey')) {
$programData = [Environment]::GetFolderPath("CommonApplicationData")
$newChocoPath = Join-Path "$programData" 'chocolatey'
@"
The default install location has been changed to '$newChocoPath'.
This install will be updated to that location in the next version. It
is strongly suggested you move this installation to the new location
as soon as possible to limit write access from all users. Do not forget
to update PATH & $chocInstallVariableName environment variables.
"@ | Write-Host -ForegroundColor $Warning -BackgroundColor Black
}
$tempLocation = Get-ConfigValue 'tempLocation'
if ($tempLocation -ne '') {
Write-Host "Switching `$env:Temp to '$tempLocation'"
}
# bump installarguments back to quotes
$installArguments = $installArguments.Replace("'","""")
$packageParameters = $packageParameters.Replace("'","""")
#main entry point
Append-Log
Write-Debug "Arguments: `$command = '$command'|`$force=$force`
|`$prerelease=$prerelease|`$packageNames='$packageNames'`
|`$source='$source'`
|`$version='$version'|`$allVersions=$allVersions`
|`$overrideArguments=$overrideArgs|`$InstallArguments='$installArguments'`
|`$localonly=$localonly|`$verbosity=$verbosity|`$debug=$debug|`$quiet=$quiet`
|`$name='$name'|`$ignoreDependencies=$ignoreDependencies|`$forceX86=$forceX86`
|`$packageParameters='$packageParameters'`
|PowerShellVersion=$($host.version)|OSVersion=$([System.Environment]::OSVersion.Version.ToString())"
$currentProtocol = [System.Net.ServicePointManager]::SecurityProtocol
Write-Debug "Current Security Protocol - $currentProtocol"
# run level environment variables
$env:chocolateyForceX86 = $null
if ($forceX86) {
$env:chocolateyForceX86 = $true
}
$env:chocolateyPackageParameters = $packageParameters
$chocolateyErrored = $false
$badPackages = ''
#todo: This does not catch package names that come later
foreach ($packageName in $packageNames) {
try {
switch -wildcard ($command) {
"install" { Chocolatey-Install $packageName $source $version $installArguments }
"installmissing" { Chocolatey-InstallIfMissing $packageName $source $version }
"update" { Chocolatey-Update $packageName $source }
"uninstall" { Chocolatey-Uninstall $packageName $version $installArguments }
"search" { Chocolatey-List $packageName $source }
"list" { Chocolatey-List $packageName $source }
"version" { Chocolatey-Version $packageName $source }
"webpi" { Chocolatey-WebPI $packageName $installArguments }
"windowsfeatures" { Chocolatey-WindowsFeatures $packageName }
"cygwin" { Chocolatey-Cygwin $packageName $installArguments }
"python" { Chocolatey-Python $packageName $version $installArguments }
"gem" { Chocolatey-RubyGem $packageName $version $installArguments }
"pack" { Chocolatey-Pack $packageName }
"push" { Chocolatey-Push $packageName $source }
"help" { Chocolatey-Help}
"sources" { Chocolatey-Sources $packageName $name $source }
default {Write-Host "Please run chocolatey /? or chocolatey help - chocolatey v$chocVer";}
}
}
catch {
$chocolateyErrored = $true
Write-Host "$($_.Exception.Message)" -BackgroundColor $ErrorColor -ForegroundColor White ;
if ($badPackages -ne '') { $badPackages += ', '}
$badPackages += "$packageName"
}
finally {
# ensure protocol is reset appropriately
[System.Net.ServicePointManager]::SecurityProtocol = $currentProtocol
}
}
if ($badPackages -ne '') {
Write-Host "Command `'$command`' failed (sometimes this indicates a partial failure). Additional info/packages: $badpackages" -BackgroundColor $ErrorColor -ForegroundColor White
}
if ($chocolateyErrored) {
Write-Debug "Exiting with non-zero exit code."
exit 1
}
exit 0
function Append-Log{
param(
[string] $chocoInstallLog = ''
)
Write-Debug "Running 'Append-InstallLog' with chocoInstallLog:`'$chocoInstallLog`'";
if ($chocoInstallLog -eq '') {
$chocoInstallLog = (Join-Path $nugetChocolateyPath 'chocolateyInstall.log')
}
$header =
@"
$(get-date -format 'yyyyMMdd-HH:mm:ss') [CHOCO] ################################################################################
$(get-date -format 'yyyyMMdd-HH:mm:ss') [CHOCO] # Going Chocolatey on $(Get-Date -Format u) #
$(get-date -format 'yyyyMMdd-HH:mm:ss') [CHOCO] ################################################################################
"@
try {
write-output $header | out-file -append $chocoInstallLog }
catch {Write-Error "Could not delete `'$chocoInstallLog`': $($_.Exception.Message)"}
}
function Chocolatey-Cygwin {
param(
[string] $packageName,
[string] $installerArguments =''
)
Write-Debug "Running 'Chocolatey-Cygwin' for $packageName with installerArguments:`'$installerArguments`'";
Chocolatey-InstallIfMissing 'cyg-get'
Write-Host "Chocolatey (v$chocVer) is installing $packageName and dependencies (using Cygwin). By installing you accept the license for $packageName and each dependency you are installing." -ForegroundColor $RunNote -BackgroundColor Black
$chocoInstallLog = Join-Path $nugetChocolateyPath 'chocolateyCygwinInstall.log';
Append-Log $chocoInstallLog
$packageArgs = "/c cyg-get $packageName"
# if ($version -notlike '') {
# $packageArgs = "$packageArgs -v $version";
# }
if ($installerArguments -ne '') {
Write-Debug "Adding installerArguments `'$installerArguments`'"
$packageArgs = "$packageArgs $installerArguments";
}
Write-Host "Opening minimized PowerShell window and calling `'cmd.exe $packageArgs`'. If progress is taking a long time, please check that window. It also may not be 100% silent..." -ForegroundColor $Warning -BackgroundColor Black
$statements = "cmd.exe $packageArgs | Tee-Object -FilePath `'$chocoInstallLog`';"
Start-ChocolateyProcessAsAdmin "$statements" -minimized -nosleep
#Start-Process -FilePath "$($env:windir)\System32\WindowsPowerShell\v1.0\powershell.exe" -ArgumentList "-NoProfile -ExecutionPolicy unrestricted -Command `"cmd.exe $packageArgs | Tee-Object -FilePath $chocoInstallLog; Write-Host 'finished';Start-Sleep 5`"" -Wait -Verb "RunAs" -WindowStyle Minimized | Wait-Process
Create-InstallLogIfNotExists $chocoInstallLog
$installOutput = Get-Content $chocoInstallLog -Encoding Ascii
foreach ($line in $installOutput) {
Write-Host $line
}
Write-Host "Finished installing `'$packageName`' and dependencies - if errors not shown in console, none detected. Check log for errors if unsure." -ForegroundColor $RunNote -BackgroundColor Black
}
function Chocolatey-Help {
@"
Version: `'$chocVer'`
Install Directory: `'$nugetPath`'
== Chocolatey? ==
"I'm a tools enabler, a global silent installer. I met your mother.
Some want to call me apt-get for Windows, I just want to get #chocolatey!"
Chocolatey is a package manager for Windows (like apt-get but for Windows).
It was designed to be a decentralized framework for quickly installing
applications and tools that you need. It is built on the NuGet
infrastructure currently using PowerShell as its focus for delivering
packages from the distros to your door, err computer.
Chocolatey is brought to you by the work and inspiration of the community,
the work and thankless nights of the Chocolatey Team
(https://github.com/orgs/chocolatey/members), and Rob (@ferventcoder)
heading up the direction.
You can host your own sources and add them to chocolatey, you can extend
chocolatey's capabilities, and folks, it's only going to get better.
== Chocolatey gods? ==
Humor related to playing off of tiki gods. We like humor. Don't take life
so seriously, you will never get out alive.
== Release Notes ==
https://github.com/chocolatey/chocolatey/wiki/ReleaseNotes
== Package License Acceptance Terms ==
The act of running chocolatey to install a package constitutes acceptance
of the license for the application, executable(s), or other artifacts
that are brought to your machine as a result of a chocolatey install.
This acceptance occurs whether you know the license terms or not. It is
suggested that you read and understand the license terms of any package
you plan to install prior to installation through chocolatey.
If you do not accept the license of a package you are installing, please
uninstall it and any artifacts that end up on your machine as a result
of the install.
== Waiver of Responsibility ==
The use of chocolatey means that an individual using chocolatey assumes
the responsibility for any changes (including any damages of any sort)
that occur to the system as a result of using chocolatey.
This does not supercede the verbage or enforcement of the license for
chocolatey (currently Apache 2.0), it is only noted here that you are
waiving any rights to collect damages by your use of chocolatey.
It is recommended you read the license
(http://www.apache.org/licenses/LICENSE-2.0) to gain a full understanding
(especially section 8. Limitation of Liability) prior to using chocolatey.
== Commands ==
For all commands check out the command reference at:
https://github.com/chocolatey/chocolatey/wiki/CommandsReference
* Search - choco search something
* List locally installed packages - choco list -lo
* Install - choco install baretail
* Update - choco update baretail
* Uninstall - choco uninstall baretail
* Install ruby gem - choco install compass -source ruby
* Install python egg - choco install sphynx -source python
* Install windows feature - choco install IIS -source windowsfeatures
* Install webpi feature - choco install IIS7.5Express -source webpi
More advanced commands and switches listed on the command reference,
including how you can force a package to install the x86 version of a
package.
Examples:
* choco install nunit
* choco install nunit -version 2.5.7.10213
* choco install packages.config
* choco update nunit -source http://somelocalfeed.com/nuget/
* choco help
* choco search nunit
* choco list -localonly
* choco version
* choco version nunit
* choco uninstall nunit
* choco install sphynx -source python
== Create Packages? ==
We have some great guidance on how to do that. Where? I'll give you a
hint, it rhymes with sticky!
https://github.com/chocolatey/chocolatey/wiki/CreatePackages
In that mess there is a link to the Helper Reference -
https://github.com/chocolatey/chocolatey/wiki/HelpersReference
"@ | Write-Host
}
function Chocolatey-Install {
param(
[string] $packageName,
[string] $source = '',
[string] $version = '',
[string] $installerArguments = ''
)
Write-Debug "Running 'Chocolatey-Install' for `'$packageName`' with source: `'$source`', version: `'$version`', installerArguments:`'$installerArguments`'";
if($($packageName).EndsWith('.config')) {
Write-Debug "Chocolatey-Install has determined that package $packageName ends with `'.config`' - calling Chocolatey-PackagesConfig"
Chocolatey-PackagesConfig $packageName
return
}
switch -wildcard ($source)
{
"webpi" { Chocolatey-WebPI $packageName $installerArguments; }
"windowsfeatures" { Chocolatey-WindowsFeatures $packageName; }
"cygwin" { Chocolatey-Cygwin $packageName $installerArguments; }
"python" { Chocolatey-Python $packageName $version $installerArguments; }
"ruby" { Chocolatey-RubyGem $packageName $version $installerArguments; }
default {Chocolatey-Nuget $packageName $source $version $installerArguments;}
}
}
function Chocolatey-InstallAll {
param(
[string] $source = ''
)
Write-Debug "Running 'Chocolatey-InstallAll' with source:`'$source`'";
if ($source -eq '' -or $source -eq 'https://go.microsoft.com/fwlink/?LinkID=230477' -or $source -eq 'https://chocolatey.org/api/v2/') {
write-host 'Source must be specified and cannot be nuget.org/chocolatey.org'
return
}
if ($source.StartsWith('http')) {
$webClient = New-Object System.Net.WebClient
$defaultCreds = [System.Net.CredentialCache]::DefaultCredentials
if ($defaultCreds -ne $null) {
$webClient.Credentials = $defaultCreds
}
if (!$source.EndsWith('/')) { $source = $source + '/' }
$feedUrl = $source + 'Packages/'
write-host "Installing all packages from $feedUrl"
$feed = [xml]$webClient.DownloadString($feedUrl)
$entries = $feed | select -ExpandProperty feed | select -ExpandProperty entry
foreach ($entry in $entries) {
if ($entry.properties.id -ne $null) {
$pkgId = $entry.properties.id
$pkgVersion = $entry.properties.version
Chocolatey-Nuget "$pkgId" -version $pkgVersion -source $source
}
}
} else {
$files = get-childitem $source -include *.nupkg -recurse
foreach ($file in $files) {
$packageName = $file.Name -replace "(\.\d{1,})+.nupkg"
Chocolatey-Nuget $packageName -source $source
}
}
}
function Chocolatey-InstallExtension {
param(
[string] $packageFolder,
[string] $packageName
)
Write-Debug "Running 'Chocolatey-InstallExtension' for $packageName with packageFolder:`'$packageFolder`'";
$packageExtensionPath = Join-Path $extensionsPath $packageName
$packageExtensionsFromPath = Join-Path $packageFolder 'extensions'
if(Test-Path($packageExtensionPath)) {
Write-Debug "We are removing the contents of `'$packageExtensionPath`'"
Remove-Item $packageExtensionPath -recurse -force -EA SilentlyContinue
}
if(!(Test-Path($packageExtensionPath))) { md $packageExtensionPath | out-null}
if (!(Test-Path($packageExtensionsFromPath))) {
Write-Host "The package `'$packageName`' seems to be missing the extensions folder at `'$packageExtensionsFromPath`'."
} else {
Write-Host "Installing extension `'$packageName`'. You will be able to use it next time you run chocolatey."
Copy-Item $packageExtensionsFromPath\* $packageExtensionPath -recurse -force
}
}
function Chocolatey-InstallIfMissing {
param(
[string] $packageName,
[string] $source = '',
[string] $version = ''
)
Write-Debug "Running 'Chocolatey-InstallIfMissing' for $packageName with source:`'$source`', version: `'$version`'";
Write-Warning "installmissing command is deprecated and will be removed. Install provides the same functionality now."
if($version -eq '') {
$packageFolder = (Get-PackageFoldersForPackage $packageName)
if($packageFolder){return}
}
$versions = Chocolatey-Version $packageName $source
if ($versions.'found' -contains 'no version' -or ($version -ne '' -and $versions.'found' -ne $version)) {
Chocolatey-Nuget $packageName $source $version
}
}
function Chocolatey-List {
param(
[string] $selector='',
[string] $source='',
[switch] $returnOutput = $false
)
Write-Debug "Running 'Chocolatey-List' with selector: `'$selector`', source:`'$source`'";
if ($source -like 'webpi') {
$chocoInstallLog = Join-Path $nugetChocolateyPath 'chocolateyWebPIList.log';
$webpiArgs ="/c webpicmd /List /ListOption:All"
Start-ChocolateyProcessAsAdmin "cmd.exe $webpiArgs | Tee-Object -FilePath `'$chocoInstallLog`';" -nosleep
Create-InstallLogIfNotExists $chocoInstallLog
$installOutput = Get-Content $chocoInstallLog -Encoding Ascii
foreach ($line in $installOutput) {
Write-Host $line
}
} elseif ($source -like 'windowsfeatures') {
$dism = "$env:WinDir\System32\dism.exe"
if (Test-Path "$env:WinDir\sysnative\dism.exe") {
$dism = "$env:WinDir\sysnative\dism.exe"
}
$chocoInstallLog = Join-Path $nugetChocolateyPath 'chocolateyWindowsFeaturesInstall.log';
Append-Log $chocoInstallLog
$windowsFeaturesArgs ="/c $dism /online /get-features /format:table | Tee-Object -FilePath `'$chocoInstallLog`';"
Start-ChocolateyProcessAsAdmin "cmd.exe $windowsFeaturesArgs" -nosleep
Create-InstallLogIfNotExists $chocoInstallLog
$installOutput = Get-Content $chocoInstallLog -Encoding Ascii
foreach ($line in $installOutput) {
Write-Host $line
}
} else {
$params = @()
$params += 'list'
$parameters = "list"
if ($selector -ne '') {
$params += "`"$selector`""
}
if ($allVersions -eq $true) {
Write-Debug "Showing all versions of packages"
$params += '-all'
}
if ($prerelease -eq $true -or $localonly -eq $true -or $source -eq $nugetLibPath) {
Write-Debug "Showing prerelease versions of packages"
$params += '-Prerelease'
}
if ($verbosity -eq $true) {
$params += '-verbosity', 'detailed'
}
$params += '-NonInteractive'
if ($localonly) {
$source = $nugetLibPath
}
if ($source -ne '') {
$params += '-Source', "`"$source`""
} else {
$srcArgs = Get-SourceArguments $source
if ($srcArgs -ne '') {
$srcArgs = $srcArgs.Replace('-Source ','')
$params += '-Source', "$srcArgs" #already quoted from Get-SourceArguments
}
}
Write-Debug "Executing command [`"$nugetExe`" $params]"
$global:packageList = @{}
$process = New-Object System.Diagnostics.Process
$process.StartInfo = New-Object System.Diagnostics.ProcessStartInfo($nugetExe, $params)
# Redirecting output slows things down a bit. In
# the interest of performance, only use redirection
# if we are returning a PS-Object at the end
if ($returnOutput) {
$LogAction = {
# we know this is one line of data otherwise we would need to split lines
foreach ($line in $EventArgs.Data) {
#Write-Host "$line" #this line really slows things down
if (!$line.IsNullOrEmpty) {
$package = $line.Split(" ")
$global:packageList.Add("$($package[0])","$($package[1])")
}
}
}
$writeOutput = $LogAction
$writeError = {
foreach ($line in $EventArgs.Data) {
if (!$line.IsNullOrEmpty) {
# do not stop execution, but pass the output back to the user.
Write-Host "[ERROR] $line" -ForegroundColor $ErrorColor -BackgroundColor Black
}
}
}
$process.EnableRaisingEvents = $true
Register-ObjectEvent -InputObject $process -SourceIdentifier "LogOutput_ChocolateyList" -EventName OutputDataReceived -Action $writeOutput | Out-Null
Register-ObjectEvent -InputObject $process -SourceIdentifier "LogErrors_ChocolateyList" -EventName ErrorDataReceived -Action $writeError | Out-Null
$process.StartInfo.RedirectStandardOutput = $true
$process.StartInfo.RedirectStandardError = $true
}
$process.StartInfo.UseShellExecute = $false
$process.Start() | Out-Null
if ($process.StartInfo.RedirectStandardOutput) { $process.BeginOutputReadLine() }
if ($process.StartInfo.RedirectStandardError) { $process.BeginErrorReadLine() }
$process.WaitForExit()
if ($returnOutput) {
# For some reason this forces the jobs to finish and waits for
# them to do so. Without this it never finishes.
Unregister-Event -SourceIdentifier "LogOutput_ChocolateyList"
#Wait-Job "LogOutput_ChocolateyList" -Timeout 10
#Remove-Job "LogOutput_ChocolateyList" #-Force
Unregister-Event -SourceIdentifier "LogErrors_ChocolateyList"
#Wait-Job "LogErrors_ChocolateyList" -Timeout 10
#Remove-Job "LogErrors_ChocolateyList"
}
$exitCode = $process.ExitCode
$process.Dispose()
Write-Debug "Command [`"$nugetExe`" $params] exited with `'$exitCode`'."
if ($returnOutput) {
# not a bug
return ,$packageList
}
}
}
function Chocolatey-NuGet {
param(
[string] $packageName,
[string] $source = '',
[string] $version = '',
[string] $installerArguments = ''
)
Write-Debug "Running 'Chocolatey-NuGet' for $packageName with source:`'$source`'. Force? $force";
if ($packageName -eq 'all') {
Write-Debug "Running install all";
Chocolatey-InstallAll $source
return
}
if ($packageName -eq $null -or $packageName.Trim() -eq '') {
Throw "Please provide a package name to install."
}
$srcArgs = ""
if ($source -ne '') {
$srcArgs = "(from $source)"
}
Write-Host "Chocolatey (v$chocVer) is installing `'$packageName`' and dependencies. By installing you accept the license for `'$packageName`' and each dependency you are installing." -ForegroundColor $RunNote -BackgroundColor Black
Write-Debug "Installing packages to `"$nugetLibPath`"."
$nugetOutput = (Run-NuGet $packageName $source $version).Split("`n")
foreach ($line in $nugetOutput) {
Write-Debug "Evaluating NuGet output for line: $line"
if ($line -like "*already installed*" -and $force -eq $false) {
Write-Host "$line" # does not show up when combined with the line below
Write-Host "If you want to reinstall the current version of an existing package, please use the -force command." -ForegroundColor $Warning -BackgroundColor Black
Write-Host ""
}
if ($line -notlike "*not installed*" -and $line -notlike "Installing *" -and ($line -notlike "*already installed*" -or $force -eq $true) -and $line -notlike "Attempting to resolve dependency*") {
$installedPackageName = ''
$installedPackageVersion = ''
$regex = [regex]"'[.\S]+\s?"
$pkgNameMatches = $regex.Matches($line) | select -First 1
if ($pkgNameMatches -ne $null) {
$installedPackageName = $pkgNameMatches -replace "'", "" -replace " ", ""
}
$regex = [regex]"[\d\.]+[\-\w]*[[)]?'"
$pkgVersionMatches = $regex.Matches($line) | select -First 1
if ($pkgVersionMatches -ne $null) {
$installedPackageVersion = $pkgVersionMatches -replace '\)', '' -replace "'", "" -replace " ", ""
}
if ($installedPackageName -eq '') {
$regex = [regex]"`"[.\S]+\s?"
$pkgNameMatches = $regex.Matches($line) | select -First 1
$installedPackageName = $pkgNameMatches -replace "`"", "" -replace " ", ""
$installedPackageVersion = $version
}
if ($installedPackageName -ne '') {
$packageFolder = ''
if ($installedPackageVersion -ne '') {
$packageFolder = Join-Path $nugetLibPath "$($installedPackageName).$($installedPackageVersion)"
} else {
#search the lib directory for the highest number of the folder
$packageFolder = Get-ChildItem $nugetLibPath | ?{$_.name -match "^$installedPackageName*"} | sort name -Descending | select -First 1
$packageFolder = $packageFolder.FullName
}
if ($packageFolder -ne '') {
Write-Debug "NuGet installed $installedPackageName. If we are ignoring dependencies ($ignoreDependencies) then we will clean this up."
if ($ignoreDependencies -and $installedPackageName -ne $packageName) {
Remove-Item $packageFolder -force -recurse
} else {
Write-Host " "
Write-Host "$installedPackageName v$installedPackageVersion" -ForegroundColor $Note -BackgroundColor Black
if ([System.IO.Directory]::Exists($packageFolder)) {
try {
Delete-ExistingErrorLog $installedPackageName
Run-ChocolateyPS1 $packageFolder $installedPackageName "install" $installerArguments
Get-ChocolateyBins $packageFolder
if ($installedPackageName.ToLower().EndsWith('.extension')) {
Chocolatey-InstallExtension $packageFolder $installedPackageName
}
} catch {
Move-BadInstall $installedPackageName $installedPackageVersion $packageFolder
Write-Error "Package `'$installedPackageName v$installedPackageVersion`' did not install successfully: $($_.Exception.Message)"
if ($badPackages -ne '') { $badPackages += ', '}
$badPackages += "$packageName"
$chocolateyErrored = $true
}
}
}
}
}
}
}
Update-SessionEnvironment
Write-Host "Finished installing `'$packageName`' and dependencies - if errors not shown in console, none detected. Check log for errors if unsure." -ForegroundColor $RunNote -BackgroundColor Black
}
function Chocolatey-Pack {
param(
[string] $packageName
)
Write-Debug "Running 'Chocolatey-Pack' for $packageName. If nuspec name is not passed, it will find the nuspec file in the current working directory";
$packageArgs = "pack $packageName -NoPackageAnalysis -NonInteractive"
$logFile = Join-Path $nugetChocolateyPath 'pack.log'
$errorLogFile = Join-Path $nugetChocolateyPath 'error.log'
Write-Host "Calling `'$nugetExe $packageArgs`'."
$process = Start-Process $nugetExe -ArgumentList $packageArgs -NoNewWindow -Wait -RedirectStandardOutput $logFile -RedirectStandardError $errorLogFile -PassThru
# this is here for specific cases in Posh v3 where -Wait is not honored
try { if (!($process.HasExited)) { Wait-Process -Id $process.Id } } catch { }
$nugetOutput = Get-Content $logFile -Encoding Ascii
foreach ($line in $nugetOutput) {
Write-Host $line
}
$errors = Get-Content $errorLogFile
if ($process.ExitCode -ne 0) {
throw $errors
}
}
function Chocolatey-PackagesConfig {
param(
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string] $packagesConfigPath
)
Write-Debug "Running 'Chocolatey-PackagesConfig' with packagesConfigPath:`'$packagesConfigPath`'";
if(-not(Test-Path $packagesConfigPath)) {
Write-Debug "No file exists at `'$packagesConfigPath`'"
if (-not($($packagesConfigPath).Contains('\'))) {
Write-Debug "Going to attempt to install $packagesConfigPath as regular chocolatey package."
Chocolatey-Nuget $packagesConfigPath
}
return
}
$h1
"Installing packages from manifest: '$(Resolve-Path $packagesConfigPath)'"
$h1
$xml = [xml] (Get-Content $packagesConfigPath)
$xml.packages.package | ?{ $_.id -ne '' -and $_.id -ne $null} | %{
Write-Debug "Calling Chocolatey-Install -packageName $_.id -source $_.source -version $_.version"
Chocolatey-Install -packageName $_.id -source $_.source -version $_.version
}
}
function Chocolatey-Push {
param(
[string] $packageName,
[string] $source = 'https://chocolatey.org/'
)
Write-Debug "Running 'Chocolatey-Push' for $packageName with source:`'$source`'";
$srcArgs = "-source $source"
if ($source -like '') {
$srcArgs = '-source https://chocolatey.org/'
Write-Debug "Setting source to `'$srcArgs`'"
}
$packageArgs = "push $packageName $srcArgs -NonInteractive"
$logFile = Join-Path $nugetChocolateyPath 'push.log'
$errorLogFile = Join-Path $nugetChocolateyPath 'error.log'
Write-Host "Calling `'$nugetExe $packageArgs`'. This may take a few minutes. Please wait for the command to finish." -ForegroundColor $Note -BackgroundColor Black
$process = Start-Process $nugetExe -ArgumentList $packageArgs -NoNewWindow -Wait -RedirectStandardOutput $logFile -RedirectStandardError $errorLogFile -PassThru
# this is here for specific cases in Posh v3 where -Wait is not honored
try { if (!($process.HasExited)) { Wait-Process -Id $process.Id } } catch { }
$nugetOutput = Get-Content $logFile -Encoding Ascii
foreach ($line in $nugetOutput) {
Write-Host $line -ForegroundColor $Note -BackgroundColor Black
}
$errors = Get-Content $errorLogFile
if ($process.ExitCode -ne 0) {
throw $errors
}
if ($source -like '' -or $source -like 'https://chocolatey.org/') {
@"
Your package may be subject to moderation. A moderator will review the
package prior to acceptance. You should have received an email. If you
don't hear back from moderators within one business day, please reply
to the email and ask for status or use contact site admins on the
package page to contact moderators.
Please ensure your registered email address is correct and emails from
chocolateywebadmin at googlegroups dot com are not being sent to your
spam/junk folder.
"@ | Write-Host -ForegroundColor $Warning -BackgroundColor Black
}
}
function Chocolatey-Python {
param(
[string] $packageName,
[string] $version ='',
[string] $installerArguments =''
)
Write-Debug "Running 'Chocolatey-Python' for $packageName with version:`'$version`', installerArguments: `'$installerArguments`'";
Chocolatey-InstallIfMissing 'python'
if ($($env:Path).ToLower().Contains("python") -eq $false) {
$env:Path = Get-EnvironmentVariable -Name 'Path' -Scope Machine
}
Chocolatey-InstallIfMissing 'easy.install'
Write-Host "Chocolatey (v$chocVer) is installing $packageName and dependencies (using Python). By installing you accept the license for $packageName and each dependency you are installing." -ForegroundColor $RunNote -BackgroundColor Black
$chocoInstallLog = Join-Path $nugetChocolateyPath 'chocolateyPythonInstall.log';
Append-Log $chocoInstallLog
$packageArgs = "/c easy_install $packageName"
if ($version -notlike '') {
Write-Debug "Adding version arguments `'$version`'"
$packageArgs = "/c easy_install $packageName==$version";
}
if ($installerArguments -ne '') {
Write-Debug "Adding installerArguments `'$installerArguments`'"
$packageArgs = "$packageArgs $installerArguments";
}
#Write-Debug "Running `'cmd.exe $packageArgs`'' and saving to `'$chocoInstallLog`'"
#& cmd.exe $packagesArgs | Tee-Object -FilePath $chocoInstallLog
Write-Host "Opening minimized PowerShell window and calling `'cmd.exe $packageArgs`'. If progress is taking a long time, please check that window. It also may not be 100% silent..." -ForegroundColor $Warning -BackgroundColor Black
$process = Start-Process -FilePath "$($env:windir)\System32\WindowsPowerShell\v1.0\powershell.exe" -ArgumentList "-NoProfile -ExecutionPolicy unrestricted -Command `"cmd.exe $packageArgs | Tee-Object -FilePath `'$chocoInstallLog`'`"" -Wait -WindowStyle Minimized -PassThru
# this is here for specific cases in Posh v3 where -Wait is not honored
try { if (!($process.HasExited)) { Wait-Process -Id $process.Id } } catch { }
Create-InstallLogIfNotExists $chocoInstallLog
$installOutput = Get-Content $chocoInstallLog -Encoding Ascii
foreach ($line in $installOutput) {
Write-Host $line
}
Write-Host "Finished installing `'$packageName`' and dependencies - if errors not shown in console, none detected. Check log for errors if unsure." -ForegroundColor $RunNote -BackgroundColor Black
}
function Chocolatey-RubyGem {
param(
[string] $packageName,
[string] $version ='',
[string] $installerArguments =''
)
Write-Debug "Running 'Chocolatey-RubyGem' for $packageName with version:`'$version`', installerArguments: `'$installerArguments`'";
Chocolatey-InstallIfMissing 'ruby'
if ($($env:Path).ToLower().Contains("ruby") -eq $false) {
$env:Path = Get-EnvironmentVariable -Name 'Path' -Scope Machine
}
Write-Host "Chocolatey (v$chocVer) is installing $packageName and dependencies (using RubyGems.org). By installing you accept the license for $packageName and each dependency you are installing." -ForegroundColor $RunNote -BackgroundColor Black
$chocoInstallLog = Join-Path $nugetChocolateyPath 'chocolateyRubyInstall.log';
Append-Log $chocoInstallLog
$packageArgs = "/c gem install $packageName"
if ($version -notlike '') {
Write-Debug "Adding version arguments `'$version`'"
$packageArgs = "$packageArgs -v $version";
}
if ($installerArguments -ne '') {
Write-Debug "Adding installerArguments `'$installerArguments`'"
$packageArgs = "$packageArgs $installerArguments";
}
Write-Host "Calling cmd.exe $packageArgs"
& cmd.exe $packageArgs
#Write-Host "Opening minimized PowerShell window and calling `'cmd.exe $packageArgs`'. If progress is taking a long time, please check that window. It also may not be 100% silent..." -ForegroundColor $Warning -BackgroundColor Black
#Start-Process -FilePath "$($env:windir)\System32\WindowsPowerShell\v1.0\powershell.exe" -ArgumentList "-NoProfile -ExecutionPolicy unrestricted -Command `"cmd.exe $packageArgs | Tee-Object -FilePath $chocoInstallLog`"" -Wait -WindowStyle Minimized
#Create-InstallLogIfNotExists $chocoInstallLog
#$installOutput = Get-Content $chocoInstallLog -Encoding Ascii
#foreach ($line in $installOutput) {
# Write-Host $line
#}
Write-Host "Finished installing `'$packageName`' and dependencies - if errors not shown in console, none detected. Check log for errors if unsure." -ForegroundColor $RunNote -BackgroundColor Black
}
function Chocolatey-Sources {
param(
[string] $operation='',
[string] $name='' ,
[string] $source=''
)
if ($operation -eq $null -or $operation -eq '') {$operation = 'list'}
Write-Debug "Running 'Chocolatey-Sources' operation `'$operation`' with source name:`'$name`', source location:`'$source`'";
switch($operation)
{
"list" { Get-Sources | format-table @{Expression={$_.id};Label="ID";width=25},@{Expression={$_.value};Label="URI"} }
"add" {
if ($name -eq '' -or $name -eq $null -or $source -eq '' -or $source -eq $null ) { throw "Please provide -name NameOfSource -source LocationOfSource"}
Write-UserConfig { param($userConfig)
$newSource = $userConfig.selectSingleNode("//source[@id='$name']")
if (-not $newSource){
$newSource = $userConfig.CreateElement("source")
$idAttr = $userConfig.CreateAttribute("id")
$idAttr.Value = $name
$newSource.SetAttributeNode($idAttr) | Out-Null
$valueAttr = $userConfig.CreateAttribute("value")
$valueAttr.Value = $source
$newSource.SetAttributeNode($valueAttr) | Out-Null
$sources = $userConfig.selectSingleNode("//sources")
$sources.AppendChild($newSource) | Out-Null
Write-Host "Source $name added."
$true
} else {
Write-Host "Source $name already exists"
}
}
}
"remove" {
if ($name -eq '' -or $name -eq $null) { throw "Please provide -name NameOfSource"}
Write-UserConfig { param($userConfig)
$source = $userConfig.selectSingleNode("//source[@id='$name']")
if ($source){
$sources = $userConfig.selectSingleNode("//sources")
$sources.RemoveChild($source) | Out-Null
Write-Host "Source $name removed."
$true
} else {
Write-Host "Source $name does not exist or is a global which can't be removed (use disable if this is the case)."
}
}
}
"enable" {
if ($name -eq '' -or $name -eq $null) { throw "Please provide -name NameOfSource"}
Write-UserConfig { param($userConfig)
$disabledNode = $userConfig.selectSingleNode("//disabled[@id='$name']")
if ($disabledNode){
$sources = $userConfig.selectSingleNode("//sources")
$sources.RemoveChild($disabledNode) | Out-Null
Write-Host "Source $name enabled."
$true
} else {
Write-Host "Source $name already enabled"
}
}
}
"disable" {
if ($name -eq '' -or $name -eq $null) { throw "Please provide -name NameOfSource"}
Write-UserConfig { param($userConfig)
$disabledNode = $userConfig.selectSingleNode("//disabled[@id='$name']")
if (-not $disabledNode){
$disabledNode = $userConfig.CreateElement("disabled")
$idAttr = $userConfig.CreateAttribute("id")
$idAttr.Value = $name
$disabledNode.SetAttributeNode($idAttr) | Out-Null
$sources = $userConfig.selectSingleNode("//sources")
$sources.AppendChild($disabledNode) | Out-Null
Write-Host "Source $name disabled."
$true
} else {
Write-Host "Source $name already disabled"
}
}
}
default { throw "Unrecognized sources operation '$operation'"}
}
}
function Chocolatey-Uninstall {
param(
[string] $packageName,
[string] $version = '',
[string] $installerArguments = ''
)
Write-Debug "Running 'Chocolatey-Uninstall' for $packageName with version:`'$version`', installerArguments: `'$installerArguments`'";
if(!$packageName) {
Write-ChocolateyFailure "Chocolatey-Uninstall" "Missing PackageName input parameter."
return
}
if ($packageName -eq 'all') {
write-host "Uninstalling all packages is not yet supported in this version. "
# by default this should prompt user 2x. Also can provide a -nuke switch for prompt bypass
return
}
Write-Host "Chocolatey (v$chocVer) is uninstalling $packageName..." -ForegroundColor $RunNote -BackgroundColor Black
$packages = $packageName
foreach ($package in $packages) {
$versions = Chocolatey-Version $package $source
if ($versions.found -eq "no version") {
write-host "not installed"
} else {
Write-Debug "Looking for $($package).$($versions.found)"
$packageFolder = Join-Path $nugetLibPath "$($package).$($versions.found)"
Write-host "Uninstalling from folder $packageFolder"
Get-ChocolateyBins $packageFolder -uninstall
Run-ChocolateyPS1 $packageFolder $package -action 'uninstall'
Remove-Item -Recurse -Force $packageFolder
}
}
}
function Chocolatey-Update {
param(
[string] $packageName ='',
[string] $source = ''
)
Write-Debug "Running 'Chocolatey-Update' for '$packageName' with source:`'$source`'.";
if ($packageName -eq 'all') {
Write-Host "Chocolatey is going to determine all packages available for an update. You may not see any output for awhile..."
}
$updated = $false
$versions = Chocolatey-Version $packageName $source
foreach ($version in $versions) {
if ($version -ne $null -and (($version.'foundCompare' -lt $version.'latestCompare') -or ($force -and $versions.'foundCompare' -eq $versions.'latestCompare'))) {
Write-Host "Updating $($version.name) from $($version.found) to $($version.latest)"
Chocolatey-NuGet $version.name $source
$updated = $true
} else {
Write-Debug "$($version.name) - you have either a newer version or the same version already available"
}
}
if (! $updated) {
Write-Host "Nothing to update."
}
}
function Chocolatey-Version {
param(
[string] $packageName='',
[string] $source=''
)
if ($packageName -eq '') {$packageName = 'chocolatey';}
Write-Debug "Running 'Chocolatey-Version' for $packageName with source:`'$source`'.";
$packages = @{}
if ($packageName -eq 'all') {
Write-Debug "Reading all packages in $nugetLibPath"
$packageName = ''
}
if ($packageName -eq 'chocolatey') {
Write-Debug "Getting $packageName from returned list"
$packages.Add("$packageName","$chocVer")
} else {
Write-Debug "Getting local packages based on all or passed in package name"
$packages = Chocolatey-List -selector "$packageName" -source "$nugetLibPath" -returnOutput
}
if ($packageName -ne '') {
Write-Debug "Getting $packageName from returned local list"
$package = $packages.GetEnumerator() | ?{$_.Name -eq $packageName} | Select-Object
$packages.Clear()
$packages.Add("$($package.Name)","$($package.Value)")
}
$versionFound = ''
$versionsObj = New-Object –typename PSObject
foreach ($package in $packages.GetEnumerator()) {
$packageName = $package.Name
if ($packageName -eq '') { continue }
$versionFound = $package.Value
if (!$localOnly) {
$remotePackages = Chocolatey-List -selector "$packageName" -source "$source" -returnOutput
Write-Debug "Getting $packageName from returned remote list"
$remotePackage = $remotePackages.GetEnumerator() | ?{$_.Name -eq $packageName} | Select-Object
$versionLatest = ''
if ($remotePackage -ne $null) {
$versionLatest = $remotePackage.Value
}
#todo - make this compare prerelease information as well
$versionLatestCompare = Get-LongPackageVersion $versionLatest
$versionFoundCompare = ''
if ($versionFound -ne 'no version') {
$versionFoundCompare = Get-LongPackageVersion $versionFound
}
$verMessage = "A more recent version is available"
if ($versionLatestCompare -eq $versionFoundCompare) {
$verMessage = "Latest version installed"
}
if ($versionLatestCompare -lt $versionFoundCompare) {
$verMessage = "Your version is newer than the most recent. You must be smarter than the average bear..."
}
if ($versionLatest -eq '') {
$verMessage = "$package does not appear to be on the source(s) specified: "
}
$versions = @{name=$($package.Name); latest = $versionLatest; found = $versionFound; latestCompare = $versionLatestCompare; foundCompare = $versionFoundCompare; verMessage = $verMessage}
$versionsObj = New-Object –typename PSObject -Property $versions
$versionsObj
} else {
$versions = @{name=$($package.Name); found = $versionFound}
$versionsObj = New-Object –typename PSObject -Property $versions
$versionsObj
}
}
# exit error 1 if querying a single package, it is not installed, and not called from another function (ie cup)
$commandType=((Get-Variable -Name MyInvocation -Scope 1 -ValueOnly).MyCommand).CommandType
if ($packages.Count -eq 1 -and $versionFound -eq '' -and $commandType -ne 'Function') {
throw "No package found"
}
}
function Chocolatey-WebPI {
param(
[string] $packageName,
[string] $installerArguments =''
)
Write-Debug "Running 'Chocolatey-WebPI' for $packageName with installerArguments:`'$installerArguments`'";
Chocolatey-InstallIfMissing 'webpicommandline'
Write-Host "Chocolatey (v$chocVer) is installing $packageName and dependencies (using WebPI). By installing you accept the license for $packageName and each dependency you are installing." -ForegroundColor $RunNote -BackgroundColor Black
$chocoInstallLog = Join-Path $nugetChocolateyPath 'chocolateyWebPiInstall.log';
Append-Log $chocoInstallLog
$packageArgs = "/c webpicmd /Install /AcceptEula /SuppressReboot /Products:$packageName"
if ($installerArguments -ne '') {
Write-Debug "Adding installerArguments `'$installerArguments`'"
$packageArgs = "$packageArgs $installerArguments"
}
if ($overrideArgs -eq $true) {
$packageArgs = "/c webpicmd $installerArguments /Products:$packageName"
write-host "Overriding arguments for WebPI to be `'$packageArgs`'"
}
Write-Host "Opening minimized PowerShell window and calling `'cmd.exe $packageArgs`'. If progress is taking a long time, please check that window. It also may not be 100% silent..." -ForegroundColor $Warning -BackgroundColor Black
$statements = "cmd.exe $packageArgs | Tee-Object -FilePath `'$chocoInstallLog`';"
Start-ChocolateyProcessAsAdmin "$statements" -minimized -nosleep
#Start-Process -FilePath "cmd" -ArgumentList "$packageArgs" -Verb "runas" -Wait >$chocoInstallLog #-PassThru -UseNewEnvironment >
#Start-Process -FilePath "$($env:windir)\System32\WindowsPowerShell\v1.0\powershell.exe" -ArgumentList "-NoProfile -ExecutionPolicy unrestricted -Command `"cmd.exe $packageArgs | Out-String`"" -Verb "runas" -Wait | Write-Host #-PassThru -UseNewEnvironment
#Start-Process -FilePath "$($env:windir)\System32\WindowsPowerShell\v1.0\powershell.exe" -ArgumentList "-NoProfile -ExecutionPolicy unrestricted -Command `"cmd.exe $packageArgs | Tee-Object -FilePath $chocoInstallLog`"" -Verb "RunAs" -Wait -WindowStyle Minimized
Create-InstallLogIfNotExists $chocoInstallLog
$installOutput = Get-Content $chocoInstallLog -Encoding Ascii
foreach ($line in $installOutput) {
Write-Host $line
}
Write-Host "Finished installing `'$packageName`' and dependencies - if errors not shown in console, none detected. Check log for errors if unsure." -ForegroundColor $RunNote -BackgroundColor Black
}
function Chocolatey-WindowsFeatures {
param(
[string] $packageName
)
Write-Debug "Running 'Chocolatey-WindowsFeatures' for $packageName";
Write-Host "Chocolatey (v$chocVer) is installing $packageName and dependencies (from Windows Features). By installing you accept the license for $packageName and each dependency you are installing." -ForegroundColor $RunNote -BackgroundColor Black
$chocoInstallLog = Join-Path $nugetChocolateyPath 'chocolateyWindowsFeaturesInstall.log';
Append-Log $chocoInstallLog
# On a 64-bit OS, the 32-bit version of DISM can be called if the powershell host is 32-bit and results in an error...
# This is due to the file system redirector. To fix this we just need to use the "sysnative" directory to force 32 bit processes
# to fetch items in the real system32 directory and not in SysWOW64.
$dism = "$env:WinDir\System32\dism.exe"
if (Test-Path "$env:WinDir\sysnative\dism.exe") {
$dism = "$env:WinDir\sysnative\dism.exe"
}
$checkStatement=@"
`$dismInfo=(cmd /c `"$dism /Online /Get-FeatureInfo /FeatureName:$packageName`")
if(`$dismInfo -contains 'State : Enabled') {return}
if(`$dismInfo -contains 'State : Enable Pending') {return}
"@
$osVersion = (Get-WmiObject -class Win32_OperatingSystem).Version
$packageArgs = "/c $dism /Online /NoRestart /Enable-Feature"
if($osVersion -ge 6.2) {
$packageArgs += " /all"
}
$packageArgs += " /FeatureName:$packageName"
Write-Host "Opening minimized PowerShell window and calling `'cmd.exe $packageArgs`'. If progress is taking a long time, please check that window. It also may not be 100% silent..." -ForegroundColor $Warning -BackgroundColor Black
$statements = $checkStatement + "`ncmd.exe $packageArgs | Tee-Object -FilePath `'$chocoInstallLog`';"
Start-ChocolateyProcessAsAdmin "$statements" -minimized -nosleep -validExitCodes @(0,1)
Create-InstallLogIfNotExists $chocoInstallLog
$installOutput = Get-Content $chocoInstallLog -Encoding Ascii
foreach ($line in $installOutput) {
Write-Host $line
}
if($installOutput.Count -eq 0) {
Write-Host "`'$packageName`' has already been installed - if errors not shown in console, none detected. Check log for errors if unsure." -ForegroundColor $RunNote -BackgroundColor Black
}
else {
Write-Host "Finished installing `'$packageName`' and dependencies - if errors not shown in console, none detected. Check log for errors if unsure." -ForegroundColor $RunNote -BackgroundColor Black
}
}
function Create-InstallLogIfNotExists{
param(
[string] $chocoInstallLog = ''
)
Write-Debug "Running 'Create-InstallLog' with chocoInstallLog:`'$chocoInstallLog`'";
if ($chocoInstallLog -eq '') {
$chocoInstallLog = (Join-Path $nugetChocolateyPath 'chocolateyInstall.log')
}
try {
if (![System.IO.File]::Exists("$chocoInstallLog")) {
New-Item "$chocoInstallLog" -type file | out-null
#Start-Sleep 2
}
} catch {
Write-Error "Could not create `'$chocoInstallLog`': $($_.Exception.Message)"
}
}
function Delete-ExistingErrorLog {
param(
[string] $packageName
)
Write-Debug "Running 'Delete-ExistingErrorLog' for $packageName";
$chocTempDir = Join-Path $env:TEMP "chocolatey"
$tempDir = Join-Path $chocTempDir "$packageName"
$failureLog = Join-Path $tempDir 'failure.log'
Write-Debug "Looking for failure log at `'$failureLog`'"
if ([System.IO.File]::Exists($failureLog)) {
Write-Debug "Found the failure log. Deleting it..."
[System.IO.File]::Delete($failureLog)
}
}
function Generate-BinFile {
param(
[string] $name,
[string] $path,
[switch] $useStart,
[string] $command = ''
)
Write-Debug "Running 'Generate-BinFile' for $name with path:`'$path`'|`$useStart:$useStart|`$command:$command";
$packageBatchFileName = Join-Path $nugetExePath "$name.bat"
$packageBashFileName = Join-Path $nugetExePath "$name"
$packageShimFileName = Join-Path $nugetExePath "$name.exe"
if (Test-Path ($packageBatchFileName)) {Remove-Item $packageBatchFileName -force}
if (Test-Path ($packageBashFileName)) {Remove-Item $packageBashFileName -force}
$path = $path.ToLower().Replace($nugetPath.ToLower(), "..\").Replace("\\","\")
$ShimGenArgs = "-o `"$packageShimFileName`" -p `"$path`""
if ($command -ne $null -and $command -ne '') {
$ShimGenArgs +=" -c $command"
}
if ($useStart) {
$ShimGenArgs +=" -gui"
}
Write-Debug "Calling $ShimGen $ShimGenArgs"
if (Test-Path ("$ShimGen")) {
#Start-Process "$ShimGen" -ArgumentList "$ShimGenArgs" -Wait -WindowStyle Hidden
$process = New-Object System.Diagnostics.Process
$process.StartInfo = new-object System.Diagnostics.ProcessStartInfo($ShimGen, $ShimGenArgs)
$process.StartInfo.RedirectStandardOutput = $true
$process.StartInfo.RedirectStandardError = $true
$process.StartInfo.UseShellExecute = $false
$process.StartInfo.WindowStyle = [System.Diagnostics.ProcessWindowStyle]::Hidden
$process.Start() | Out-Null
$process.WaitForExit()
}
if (Test-Path ($packageShimFileName)) {
Write-Host "Added $packageShimFileName shim pointed to `'$path`'." -ForegroundColor $Note
} else {
Write-Warning "An error occurred generating shim, using old method."
$path = "%DIR%$($path)"
$pathBash = $path.Replace("%DIR%..\","`$DIR/../").Replace("\","/")
Write-Host "Adding $packageBatchFileName and pointing to `'$path`'." -ForegroundColor $Note
Write-Host "Adding $packageBashFileName and pointing to `'$path`'." -ForegroundColor $Note
if ($useStart) {
Write-Host "Setting up $name as a non-command line application." -ForegroundColor $Note
"@echo off
SET DIR=%~dp0%
start """" ""$path"" %*" | Out-File $packageBatchFileName -encoding ASCII
$sw = New-Object IO.StreamWriter "$packageBashFileName"
$sw.Write("#!/bin/sh`nDIR=`${0%/*}`n""$pathBash"" ""`$@"" &`n")
$sw.Close()
$sw.Dispose()
} else {
"@echo off
SET DIR=%~dp0%
cmd /c """"$path"" %*""
exit /b %ERRORLEVEL%" | Out-File $packageBatchFileName -encoding ASCII
$sw = New-Object IO.StreamWriter "$packageBashFileName"
$sw.Write("#!/bin/sh`nDIR=`${0%/*}`n""$pathBash"" ""`$@""`nexit `$?`n")
$sw.Close()
$sw.Dispose()
}
}
}
function Get-ChocolateyBins {
param(
[string] $packageFolder,
[switch] $uninstall
)
Write-Debug "Running 'Get-ChocolateyBins' for $packageFolder";
if ($packageFolder -notlike '') {
Write-Debug " __ Executable Links (*.exe) __"
@"
Looking for executables in folder: $packageFolder
Adding batch files for any executables found to a location on PATH. In other words the executable will be available from ANY command line/powershell prompt.
"@ | Write-Debug
$batchCreated = $false
try {
$files = get-childitem $packageFolder -include *.exe -recurse
if ($files -ne $null) { Write-Debug "Found $($files.Count) exe files to possibly generate." }
foreach ($file in $files) {
Write-Debug "Found '$file' for batch redirect"
if (!(test-path($file.FullName + '.ignore'))) {
if (test-path($file.FullName + '.gui')) {
if ($uninstall) {
Remove-BinFile $file.Name.Replace(".exe","").Replace(".EXE","") $file.FullName
} else {
Generate-BinFile $file.Name.Replace(".exe","").Replace(".EXE","") $file.FullName -useStart
}
} else {
if ($uninstall) {
Remove-BinFile $file.Name.Replace(".exe","").Replace(".EXE","") $file.FullName
} else {
Generate-BinFile $file.Name.Replace(".exe","").Replace(".EXE","") $file.FullName
}
}
$batchCreated = $true
}
}
}
catch {
#Write-Host 'There are no executables (that are not ignored) in the package.'
}
if (!($batchCreated)) {
Write-Debug 'There are no executables (that are not ignored) in the package.'
}
}
}
function Get-ConfigValue {
param(
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string] $configValue
)
Write-Debug "Running 'Get-ConfigValue' with configValue:`'$configValue`'";
$returnValue = Get-UserConfigValue $configValue
Write-Debug "After checking the user config the value of `'$configValue`' is `'$returnValue`'"
if ($returnValue -eq $null -or $returnValue -eq '') {
Write-Debug "Value not found in the user config file - checking the global config"
$returnValue = Get-GlobalConfigValue $configValue
Write-Debug "After checking the global config the value of `'$configValue`' is `'$returnValue`'"
}
if ($returnValue -eq $null) {
Write-Error "A configuration value for $configValue was not found"
}
$returnValue
}
function Get-GlobalConfigValue {
param(
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string] $configValue
)
Write-Debug "Running 'Get-GlobalConfigValue' with configValue:`'$configValue`'";
if ($globalConfig -eq $null -or $globalConfig -eq '') {
$globalConfigFile = Join-Path $nugetChocolateyPath chocolatey.config
$globalConfig = [xml] (Get-Content $globalConfigFile)
}
# append chocolatey
$configValue = "chocolatey.$configValue"
iex "`$globalConfig.$configValue"
}
function Get-LatestPackageVersion {
param(
$packageVersions = @()
)
$latestVersion = ''
if ($packageVersions -ne $null -and $packageVersions.GetEnumerator() -ne $null) {
$packageVersions = $packageVersions.GetEnumerator() | sort-object -property Name -descending
if ($packageVersions -is [Object[]]) {
$latestPackageVersion = $packageVersions.GetEnumerator() | Select-Object -First 1
Write-Debug "Using $($latestPackageVersion.Value) as the latest version (from multiple found versions)"
$latestVersion = $latestPackageVersion.Value
}
else {
Write-Debug "Using $($packageversions.value) as the latest version"
$latestversion=$packageversions.value
}
}
return $latestVersion
}
function Get-LongPackageVersion {
param(
[string] $packageVersion = ''
)
$longVersion = $packageVersion.Split('-')[0].Split('.') | %{('0' * (12 - $_.Length)) + $_}
$longVersionReturn = [System.String]::Join('.',$longVersion)
if ($packageVersion.Contains('-')) {
$prerelease = $packageVersion.Substring($packageVersion.IndexOf('-') + 1)
$longVersionReturn += ".$($prerelease)"
}
Write-Debug "Long version of $packageVersion is `'$longVersionReturn`'"
return $longVersionReturn
}
function Get-PackageFoldersForPackage {
param(
[string]$packageName = ''
)
return Get-ChildItem $nugetLibPath | ?{$_.name -match "^$packageName\.\d+"}
}
function Get-PackageFolderVersions {
param(
[string] $packageName = ''
)
$packageFolders = Get-PackageFoldersForPackage $packageName
$packageVersions = @()
foreach ($packageFolder in $packageFolders) {
$packageVersions = $packageVersions + $packageFolder.Name -replace "$packageName\."
}
return Get-VersionsForComparison $packageVersions
}
function Get-SourceArguments {
param(
[string] $source = ''
)
$srcArgs = ""
if ($source -ne '') {
$srcArgs = "-Source `"$source`""
}
else
{
$useNugetConfig = Get-ConfigValue 'useNuGetForSources'
if ($useNugetConfig -eq 'false') {
$srcArgs = '-Source "'
$sources = Get-Sources
$sources | foreach {
$srcUri = $_.value
$srcArgs += "$srcUri;"
}
$srcArgs += '"'
}
}
Write-Debug "Using `'$srcArgs`' as the source arguments"
return $srcArgs
}
function Get-Sources
{
$userSources = Get-UserConfigValue "sources"
$globalSources = Get-GlobalConfigValue "sources"
if( $userSources -eq $null -or $userSources -eq '')
{
Write-Debug "Using global sources"
$globalSources.selectNodes("//source")
}
else
{
Write-Debug "Combining global and user config sources"
$allSources = $userSources.selectNodes("//source") + $globalSources.selectNodes("//source")
# filter out all the empty and disabled sources
$allSources | Where-Object { $_.value -ne $null -and $_.value -ne ''} | Where-Object { $userSources.selectSingleNode("//disabled[@id='"+ $_.id + "']") -eq $null }
}
}
function Get-UserConfigValue {
param(
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string] $configValue
)
Write-Debug "Running 'Get-UserConfigValue' with configValue:`'$configValue`'";
if ($userConfig -eq $null -or $userConfig -eq '') {
#$env:USERPROFILE or $env:HOME
$userConfigFile = Join-Path $env:USERPROFILE chocolatey.config
if (-not(Test-Path($userConfigFile))) {
return $null
}
$userConfig = [xml] (Get-Content $userConfigFile)
}
# append chocolatey
$configValue = "chocolatey.$configValue"
iex "`$userConfig.$configValue"
}
function Get-VersionsForComparison {
param (
$packageVersions = @()
)
$versionsForComparison = @{}
foreach ($packageVersion in $packageVersions) {
$longVersion = Get-LongPackageVersion $packageVersion
if ($versionsForComparison.ContainsKey($longVersion) -ne $true) {
$versionsForComparison.Add($longVersion,$packageVersion)
}
}
return $versionsForComparison
}
function Move-BadInstall {
param(
[string] $packageName,
[string] $version = '',
[string] $packageFolder = ''
)
Write-Debug "Running 'Move-BadInstall' for $packageName version: `'$version`', packageFolder:`'$packageFolder`'";
#copy the bad stuff to a temp directory
$badPackageFolder = $badLibPath #Join-Path $badLibPath "$($installedPackageName).$($installedPackageVersion)"
try {
if ([System.IO.Directory]::Exists($badPackageFolder)) {
[System.IO.Directory]::Delete($badPackageFolder,$true) #| out-null
}
[System.IO.Directory]::CreateDirectory($badPackageFolder) | out-null
write-debug "Moving bad package `'$packageName v$version`' to `'$badPackageFolder`'."
#Get-Childitem "$badPackageFolder" -recurse | remove-item
Move-Item $packageFolder $badPackageFolder -force #| out-null
} catch {
Write-Error "Could not move bad package $packageName from `'$packageFolder`' to `'$badPackageFolder`': $($_.Exception.Message)"
}
}
function Remove-BinFile {
param(
[string] $name,
[string] $path
)
Write-Debug "Running 'Remove-BinFile' for $name with path:`'$path`'";
$packageBatchFileName = Join-Path $nugetExePath "$name.bat"
$packageBashFileName = Join-Path $nugetExePath "$name"
$packageShimFileName = Join-Path $nugetExePath "$name.exe"
$path = $path.ToLower().Replace($nugetPath.ToLower(), "%DIR%..\").Replace("\\","\")
$pathBash = $path.Replace("%DIR%..\","`$DIR/../").Replace("\","/")
Write-Debug "Attempting to remove the batch and bash shortcuts: $packageBatchFileName and $packageBashFileName"
if (Test-Path $packageBatchFileName) {
Write-Host "Removing batch file $packageBatchFileName which pointed to `'$path`'." -ForegroundColor $Note
Remove-Item $packageBatchFileName
}
else {
Write-Debug "Tried to remove batch file $packageBatchFileName but it was already removed."
}
if (Test-Path $packageBashFileName) {
Write-Host "Removing bash file $packageBashFileName which pointed to `'$path`'." -ForegroundColor $Note
Remove-Item $packageBashFileName
}
else {
Write-Debug "Tried to remove bash file $packageBashFileName but it was already removed."
}
Write-Debug "Attempting to remove the shim: $packageShimFileName"
if (Test-Path $packageShimFileName) {
Write-Host "Removing shim $packageShimFileName which pointed to `'$path`'." -ForegroundColor $Note
Remove-Item $packageShimFileName
}
else {
Write-Debug "Tried to remove shim $packageShimFileName but it was already removed."
}
}
function Remove-LastInstallLog{
param(
[string] $chocoInstallLog = ''
)
if ($chocoInstallLog -eq '') {
$chocoInstallLog = (Join-Path $nugetChocolateyPath 'chocolateyInstall.log')
}
Write-Debug "Running 'Remove-LastInstallLog' with chocoInstallLog:`'$chocoInstallLog`'";
try {
if ([System.IO.File]::Exists($chocoInstallLog)) {[System.IO.File]::Delete($chocoInstallLog)}
} catch {
Write-Error "Could not delete `'$chocoInstallLog`': $($_.Exception.Message)"
}
}
function Run-ChocolateyProcess {
param(
[string] $file,
[string] $arguments = $args,
[switch] $elevated
)
Write-Host "Running $file $arguments. This may take awhile and permissions may need to be elevated, depending on the package.";
$psi = new-object System.Diagnostics.ProcessStartInfo $file;
$psi.Arguments = $arguments;
#$psi.Verb = "runas";
# $psi.CreateNoWindow = $true
# $psi.RedirectStandardOutput = $true;
# $psi.RedirectStandardError = $true;
# $psi.UseShellExecute = $false;
$psi.WorkingDirectory = get-location;
$s = [System.Diagnostics.Process]::Start($psi);
$s.WaitForExit();
if ($s.ExitCode -ne 0) {
throw "[ERROR] Running $file with $arguments was not successful."
}
}
function Run-ChocolateyPS1 {
param(
[string] $packageFolder,
[string] $packageName,
[string] $action,
[string] $installerArguments = ''
)
Write-Debug "Running 'Run-ChocolateyPS1' for $packageName with packageFolder:`'$packageFolder`', action: `'$action`'";
switch ($action)
{
"install" { $actionFile = "chocolateyinstall.ps1"; }
"uninstall" {$actionFile = "chocolateyuninstall.ps1"; }
default { $actionFile = "chocolateyinstall.ps1";}
}
if ($packageFolder -notlike '') {
Write-Debug " __ PowerShell $action ($actionFile) __"
Write-Debug " Looking for $actionFile in folder `'$packageFolder`'. If $actionFile is found, it will be run."
$ps1 = Get-ChildItem $packageFolder -recurse | ?{$_.name -match $actionFile} | sort name -Descending | select -First 1
$installps1 = Get-ChildItem $packageFolder -recurse | ?{$_.name -match 'chocolateyinstall.ps1'} | sort name -Descending | select -First 1
Write-Debug "Action file is `'$ps1`'"
if ($ps1 -notlike '') {
$env:chocolateyPackageFolder ="$packageFolder"
$env:chocolateyInstallArguments = "$installerArguments"
$env:chocolateyInstallOverride = $null
if ($overrideArgs -eq $true) {
$env:chocolateyInstallOverride = $true
}
$ps1FullPath = $ps1.FullName
Write-Debug "Running `'$ps1FullPath`'";
& "$ps1FullPath"
$env:chocolateyInstallArguments = ''
$env:chocolateyInstallOverride = $null
# $importChocolateyHelpers = "";
# Get-ChildItem "$nugetChocolateyPath\helpers" -Filter *.psm1 | ForEach-Object { $importChocolateyHelpers = "& import-module -name `'$($_.FullName)`';$importChocolateyHelpers" };
# Run-ChocolateyProcess powershell "-NoProfile -ExecutionPolicy unrestricted -Command `"$importChocolateyHelpers & `'$ps1FullPath`'`"" -elevated
##testing Start-Process -FilePath "powershell.exe" -ArgumentList " -noexit `"$ps1FullPath`"" -Verb "runas" -Wait #-PassThru -UseNewEnvironment ##-RedirectStandardError $errorLog -WindowStyle Normal
#detect errors
$chocTempDir = Join-Path $env:TEMP "chocolatey"
$tempDir = Join-Path $chocTempDir "$packageName"
$failureLog = Join-Path $tempDir 'failure.log'
if ([System.IO.File]::Exists($failureLog)) {
#we have issues, time to throw an error
$errorContents = Get-Content $failureLog
if ($errorContents -ne '') {
foreach ($errorLine in $errorContents) {
Write-Host $errorLine -BackgroundColor Red -ForegroundColor White
}
throw $errorContents
}
}
}
if ($installps1 -notlike '' -and $ps1 -like '') {
Write-Host "This package has a chocolateyInstall.ps1 without a chocolateyUninstall.ps1. You will need to manually reverse whatever steps the installer did. Please ask the package maker to include a chocolateyUninstall.ps1 in the file to really remove the package." -ForegroundColor $Warning -BackgroundColor Black
}
}
}
function Run-NuGet {
param(
[string] $packageName,
[string] $source = '',
[string] $version = ''
)
Write-Debug "Running 'Run-NuGet' for $packageName with source: `'$source`', version:`'$version`'";
Write-Debug "___ NuGet ____"
$srcArgs = Get-SourceArguments $source
$packageArgs = "install $packageName -OutputDirectory `"$nugetLibPath`" $srcArgs -NonInteractive -NoCache"
if ($version -notlike '') {
$packageArgs = $packageArgs + " -Version $version";
}
if ($prerelease -eq $true) {
$packageArgs = $packageArgs + " -Prerelease";
}
$logFile = Join-Path $nugetChocolateyPath 'install.log'
$errorLogFile = Join-Path $nugetChocolateyPath 'error.log'
Write-Debug "Calling `'$nugetExe`' $packageArgs"
$process = New-Object System.Diagnostics.Process
$process.StartInfo = new-object System.Diagnostics.ProcessStartInfo($nugetExe, $packageArgs)
$process.StartInfo.RedirectStandardOutput = $true
$process.StartInfo.RedirectStandardError = $true
$process.StartInfo.UseShellExecute = $false
$process.StartInfo.CreateNoWindow = $true
$process.Start() | Out-Null
$process.WaitForExit()
$nugetOutput = $process.StandardOutput.ReadToEnd()
$errors = $process.StandardError.ReadToEnd()
$nugetOutput | Out-File $logFile
$errors | Out-File $errorLogFile
foreach ($line in $nugetOutput) {
if ($line -ne $null) {Write-Debug $line;}
}
if ($errors -ne '') {
Throw $errors
}
if (($nugetOutput -eq '' -or $nugetOutput -eq $null) -and ($errors -eq '' -or $errors -eq $null)) {
$noExecution = 'Execution of NuGet not detected. Please make sure you have .NET Framework 4.0 installed and are passing arguments to the install command.'
#write-host -BackgroundColor Red -ForegroundColor White
Throw $noExecution
}
return $nugetOutput
}
function Write-UserConfig ($writeOperation)
{
$userConfigFile = Join-Path $env:USERPROFILE chocolatey.config
# check to see if there is a user config file
if ( -not(Test-Path($userConfigFile)) )
{
# Create an empty user config file
New-Item $userConfigFile -ItemType file -Value '<?xml version="1.0"?><chocolatey><sources></sources></chocolatey>' | Out-Null
}
$userConfig = [xml] (Get-Content $userConfigFile)
$save = . $writeOperation $userConfig
if($save)
{
$userConfig.Save($userConfigFile)
}
}
function Get-BinRoot {
Write-Debug "Running 'Get-BinRoot'";
# Since CamelCase was decided upon when $env:ChocolateyInstall was first invented, whe should stick to this convention and use $env:ChocolateyBinRoot.
# I propose:
# 1) all occurances of $env:chocolatey_bin_root be replaced with $env:ChocolateyBinRoot;
# 2) Make the new Chocolatey Installer for new users explicitly set (if not exists) $env:ChocolateyInstall and $env:ChocolateyBinRoot as environment variables so users will smile and understand;
# 3) Make new Chocolatey convert old $env:chocolatey_bin_root to $env:ChocolateyBinRoot
# 4) If there is no bin root, we default to SystemDrive\tools
$binRoot = ''
# Clean up wrongfully set C:\
if ($env:ChocolateyBinRoot -eq $env:systemdrive) {
# Read but untested: Setting a variable = an empty string will remove it completely.
$env:ChocolateyBinRoot = ''
}
# For now, check old var first
if ($env:ChocolateyBinRoot -eq $null) { # If no value
if ($env:chocolatey_bin_root -eq $null) { # Try old var
$env:ChocolateyBinRoot = join-path $env:systemdrive 'tools'
}
else {
$env:ChocolateyBinRoot = $env:chocolatey_bin_root
}
}
# My ChocolateyBinRoot is C:\Common\bin, but looking at other packages, not everyone assumes ChocolateyBinRoot is prepended with a drive letter.
if (-not($env:ChocolateyBinRoot -imatch "^\w:")) {
# Add drive letter
$binRoot = join-path $env:systemdrive $env:ChocolateyBinRoot
}
else {
$binRoot = $env:ChocolateyBinRoot
}
# Now that we figured out the binRoot, let's store it as per proposal #3 line #7
if (-not($env:ChocolateyBinRoot -eq $binRoot)) {
Set-EnvironmentVariable -Name "ChocolateyBinRoot" -Value $binRoot -Scope User
# Note that user variables pose a problem when there are two admins on one computer. But this is what was decided upon.
}
return $binRoot
}
function Get-CheckSumValid {
param(
[string] $file,
[string] $checksum = '',
[string] $checksumType = 'md5'
)
Write-Debug "Running 'Get-CheckSumValid' with file:`'$file`', checksum: `'$checksum`', checksumType: `'$checksumType`'";
if ($checksum -eq '' -or $checksum -eq $null) { return }
if(!([System.IO.File]::Exists($file))) { throw "Unable to checksum a file that doesn't exist - Could not find file `'$file`'" }
if ($checksumType -ne 'sha1') { $checksumType = 'md5'}
Update-SessionEnvironment
# On first install, env:ChocolateyInstall might be null still - join-path has issues
$checksumExe = Join-Path "$env:ALLUSERSPROFILE" 'chocolatey\chocolateyinstall\tools\checksum.exe'
if ($env:ChocolateyInstall){
$checksumExe = Join-Path "$env:ChocolateyInstall" 'chocolateyinstall\tools\checksum.exe'
}
Write-Debug "Calling command [`'$checksumExe`' -c$checksum `"$file`"] to retrieve checksum"
$process = Start-Process "$checksumExe" -ArgumentList " -c=`"$checksum`" -t=`"$checksumType`" -f=`"$file`"" -Wait -WindowStyle Hidden -PassThru
# this is here for specific cases in Posh v3 where -Wait is not honored
try { if (!($process.HasExited)) { Wait-Process -Id $process.Id } } catch { }
Write-Debug "`'$checksumExe`' exited with $($process.ExitCode)"
if ($process.ExitCode -ne 0) {
throw "Checksum for `'$file'` did not meet `'$checksum`' for checksum type `'$checksumType`'."
}
#$fileCheckSumActual = $md5Output.Split(' ')[0]
# if ($fileCheckSumActual -ne $checkSum) {
# throw "CheckSum for `'$file'` did not meet `'$checkSum`'."
# }
}
function Get-ChocolateyUnzip {
<#
.SYNOPSIS
Unzips an archive file and returns the location for further processing.
.DESCRIPTION
This unzips files using the 7-zip standalone command line tool 7za.exe.
Supported archive formats are: 7z, lzma, cab, zip, gzip, bzip2, Z and tar.
.PARAMETER FileFullPath
This is the full path to your zip file.
.PARAMETER Destination
This is a directory where you would like the unzipped files to end up.
If it does not exist, it will be created.
.PARAMETER SpecificFolder
OPTIONAL - This is a specific directory within zip file to extract.
.PARAMETER PackageName
OPTIONAL - This will faciliate logging unzip activity for subsequent uninstall
.EXAMPLE
$scriptPath = (Split-Path -parent $MyInvocation.MyCommand.Definition)
Get-ChocolateyUnzip "c:\someFile.zip" $scriptPath somedirinzip\somedirinzip
.OUTPUTS
Returns the passed in $destination.
.NOTES
This helper reduces the number of lines one would have to write to unzip a file to 1 line.
If extraction fails, an exception is thrown.
#>
param(
[string] $fileFullPath,
[string] $destination,
[string] $specificFolder,
[string] $packageName
)
$zipfileFullPath=$fileFullPath
if ($specificfolder) {
$fileFullPath=join-path $fileFullPath $specificFolder
}
Write-Debug "Running 'Get-ChocolateyUnzip' with fileFullPath:`'$fileFullPath`'', destination: `'$destination`', specificFolder: `'$specificFolder``, packageName: `'$packageName`'";
if ($packageName) {
$packagelibPath=$env:chocolateyPackageFolder
if (!(Test-Path -path $packagelibPath)) {
New-Item $packagelibPath -type directory
}
$zipFilename=split-path $zipfileFullPath -Leaf
$zipExtractLogFullPath=join-path $packagelibPath $zipFilename`.txt
}
Write-Host "Extracting $fileFullPath to $destination..."
if (![System.IO.Directory]::Exists($destination)) {[System.IO.Directory]::CreateDirectory($destination)}
Update-SessionEnvironment
# On first install, env:ChocolateyInstall might be null still - join-path has issues
$7zip = Join-Path "$env:ALLUSERSPROFILE" 'chocolatey\chocolateyinstall\tools\7za.exe'
if ($env:ChocolateyInstall){
$7zip = Join-Path "$env:ChocolateyInstall" 'chocolateyinstall\tools\7za.exe'
}
# 32-bit 7za.exe would not find C:\Windows\System32\config\systemprofile\AppData\Local\Temp,
# because it gets translated to C:\Windows\SysWOW64\... by the WOW redirection layer.
# Replace System32 with sysnative, which does not get redirected.
if ([IntPtr]::Size -ne 4) {
$fileFullPath32 = $fileFullPath -ireplace ([regex]::Escape([Environment]::GetFolderPath('System'))),(Join-Path $Env:SystemRoot sysnative)
$destination32 = $destination -ireplace ([regex]::Escape([Environment]::GetFolderPath('System'))),(Join-Path $Env:SystemRoot sysnative)
} else {
$fileFullPath32 = $fileFullPath
$destination32 = $destination
}
$exitCode = -1
$unzipOps = {
param($7zip, $destination, $fileFullPath, [ref]$exitCodeRef)
$process = Start-Process $7zip -ArgumentList "x -o`"$destination`" -y `"$fileFullPath`"" -Wait -WindowStyle Hidden -PassThru
# this is here for specific cases in Posh v3 where -Wait is not honored
try { if (!($process.HasExited)) { Wait-Process -Id $process.Id } } catch { }
$exitCodeRef.Value = $process.ExitCode
}
if ($zipExtractLogFullPath) {
Write-Debug "wrapping 7za invocation with Write-FileUpdateLog"
Write-FileUpdateLog -logFilePath $zipExtractLogFullPath -locationToMonitor $destination -scriptToRun $unzipOps -argumentList $7zip,$destination32,$fileFullPath32,([ref]$exitCode)
} else {
Write-Debug "calling 7za directly"
Invoke-Command $unzipOps -ArgumentList $7zip,$destination32,$fileFullPath32,([ref]$exitCode)
}
Write-Debug "7za exit code: $exitCode"
switch ($exitCode) {
0 { break }
1 { throw 'Some files could not be extracted' } # this one is returned e.g. for access denied errors
2 { throw '7-Zip encountered a fatal error while extracting the files' }
7 { throw '7-Zip command line error' }
8 { throw '7-Zip out of memory' }
255 { throw 'Extraction cancelled by the user' }
default { throw "7-Zip signalled an unknown error (code $exitCode)" }
}
return $destination
}
function Get-ChocolateyWebFile {
<#
.SYNOPSIS
Downloads a file from the internets.
.DESCRIPTION
This will download a file from a url, tracking with a progress bar.
It returns the filepath to the downloaded file when it is complete.
.PARAMETER PackageName
The name of the package we want to download - this is arbitrary, call it whatever you want.
It's recommended you call it the same as your nuget package id.
.PARAMETER FileFullPath
This is the full path of the resulting file name.
.PARAMETER Url
This is the url to download the file from.
.PARAMETER Url64bit
OPTIONAL - If there is an x64 installer to download, please include it here. If not, delete this parameter
.PARAMETER Checksum
OPTIONAL (Right now) - This allows a checksum to be validated for files that are not local
.PARAMETER Checksum64
OPTIONAL (Right now) - This allows a checksum to be validated for files that are not local
.PARAMETER ChecksumType
OPTIONAL (Right now) - 'md5' or 'sha1' - defaults to 'md5'
.PARAMETER ChecksumType64
OPTIONAL (Right now) - 'md5' or 'sha1' - defaults to ChecksumType
.EXAMPLE
Get-ChocolateyWebFile '__NAME__' 'C:\somepath\somename.exe' 'URL' '64BIT_URL_DELETE_IF_NO_64BIT'
.NOTES
This helper reduces the number of lines one would have to write to download a file to 1 line.
There is no error handling built into this method.
.LINK
Install-ChocolateyPackage
#>
param(
[string] $packageName,
[string] $fileFullPath,
[string] $url,
[string] $url64bit = '',
[string] $checksum = '',
[string] $checksumType = '',
[string] $checksum64 = '',
[string] $checksumType64 = $checksumType
)
Write-Debug "Running 'Get-ChocolateyWebFile' for $packageName with url:`'$url`', fileFullPath:`'$fileFullPath`', url64bit:`'$url64bit`', checksum: `'$checksum`', checksumType: `'$checksumType`', checksum64: `'$checksum64`', checksumType64: `'$checksumType64`'";
$url32bit = $url;
$checksum32 = $checksum
$checksumType32 = $checksumType
$bitWidth = 32
if (Get-ProcessorBits 64) {
$bitWidth = 64
}
Write-Debug "CPU is $bitWidth bit"
$bitPackage = 32
if ($bitWidth -eq 64 -and $url64bit -ne $null -and $url64bit -ne '') {
Write-Debug "Setting url to '$url64bit' and bitPackage to $bitWidth"
$bitPackage = $bitWidth
$url = $url64bit;
# only set if urls are different
if ($url32bit -ne $url64bit) {
$checksum = $checksum64
}
$checksumType = $checksumType64
}
$forceX86 = $env:chocolateyForceX86;
if ($forceX86) {
Write-Debug "User specified -x86 so forcing 32 bit"
$bitPackage = 32
$url = $url32bit
$checksum = $checksum32
$checksumType = $checksumType32
}
$headers = @{}
if ($url.StartsWith('http')) {
try {
$headers = Get-WebHeaders $url
} catch {
if ($host.Version -lt (new-object 'Version' 3,0)) {
Write-Debug "Converting Security Protocol to SSL3 only for Powershell v2"
# this should last for the entire duration
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Ssl3
$headers = Get-WebHeaders $url
} else {
Write-Host "Attempt to get headers for $url failed.`n $($_.Exception.Message)"
}
}
$needsDownload = $true
if ($headers.Count -ne 0 -and $headers.ContainsKey("Content-Length")) {
$fi = new-object System.IO.FileInfo($fileFullPath)
# if the file already exists there is no reason to download it again.
if ($fi.Exists -and $fi.Length -eq $headers["Content-Length"]) {
Write-Debug "$($packageName)'s requested file has already been downloaded. Using cached copy at
`'$fileFullPath`'."
$needsDownload = $false
}
}
if ($needsDownload) {
Write-Host "Downloading $packageName $bitPackage bit
from `'$url`'"
Get-WebFile $url $fileFullPath
}
} elseif ($url.StartsWith('ftp')) {
Write-Host "Ftp-ing $packageName
from `'$url`'"
Get-FtpFile $url $fileFullPath
} else {
if ($url.StartsWith('file:')) { $url = ([uri] $url).LocalPath }
Write-Host "Copying $packageName
from `'$url`'"
Copy-Item $url -Destination $fileFullPath -Force
}
Start-Sleep 2 #give it a sec or two to finish up copying
$fi = new-object System.IO.FileInfo($fileFullPath)
# validate file exists
if (!($fi.Exists)) { throw "Chocolatey expected a file to be downloaded to `'$fileFullPath`' but nothing exists at that location." }
if ($headers.Count -ne 0) {
# validate length is what we expected
Write-Debug "Checking that `'$fileFullPath`' is the size we expect it to be."
if ($headers.ContainsKey("Content-Length") -and ($fi.Length -ne $headers["Content-Length"])) { throw "Chocolatey expected a file at `'$fileFullPath`' to be of length `'$($headers["Content-Length"])`' but the length was `'$($fi.Length)`'." }
if ($headers.ContainsKey("X-Checksum-Sha1")) {
$remoteChecksum = $headers["X-Checksum-Sha1"]
Write-Debug "Verifying remote checksum of `'$remoteChecksum`' for `'$fileFullPath`'."
Get-CheckSumValid -file $fileFullPath -checkSum $remoteChecksum -checksumType 'sha1'
}
}
Write-Debug "Verifying package provided checksum of `'$checksum`' for `'$fileFullPath`'."
Get-CheckSumValid -file $fileFullPath -checkSum $checksum -checksumType $checksumType
# Virus check is not able to be performed, must note that.
# $url is already set properly to the used location.
#Write-Debug "Verifying downloaded file is not known to contain viruses. FilePath: `'$fileFullPath`'."
#Get-VirusCheckValid -location $url -file $fileFullPath
}
function Get-EnvironmentVariable([string] $Name, [System.EnvironmentVariableTarget] $Scope) {
[Environment]::GetEnvironmentVariable($Name, $Scope)
}
function Get-EnvironmentVariableNames([System.EnvironmentVariableTarget] $Scope) {
switch ($Scope) {
'User' { Get-Item 'HKCU:\Environment' | Select-Object -ExpandProperty Property }
'Machine' { Get-Item 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' | Select-Object -ExpandProperty Property }
'Process' { Get-ChildItem Env:\ | Select-Object -ExpandProperty Key }
default { throw "Unsupported environment scope: $Scope" }
}
}
## Get-FtpFile
##############################################################################################################
## Downloads a file from ftp
## Some code from http://stackoverflow.com/questions/265339/whats-the-best-way-to-automate-secure-ftp-in-powershell
## Additional functionality emulated from http://poshcode.org/417 (Get-WebFile)
## Written by Stephen C. Austin, Pwnt & Co. http://pwnt.co
##############################################################################################################
function Get-FtpFile {
param(
$url = '', #(Read-Host "The URL to download"),
$fileName = $null,
$username = $null,
$password = $null,
[switch]$quiet
)
# Create a FTPWebRequest object to handle the connection to the ftp server
$ftprequest = [System.Net.FtpWebRequest]::create($url)
# set the request's network credentials for an authenticated connection
$ftprequest.Credentials =
New-Object System.Net.NetworkCredential($username,$password)
$ftprequest.Method = [System.Net.WebRequestMethods+Ftp]::DownloadFile
$ftprequest.UseBinary = $true
$ftprequest.KeepAlive = $false
# send the ftp request to the server
$ftpresponse = $ftprequest.GetResponse()
[int]$goal = $ftpresponse.ContentLength
# get a download stream from the server response
$reader = $ftpresponse.GetResponseStream()
# create the target file on the local system and the download buffer
$writer = New-Object IO.FileStream ($fileName,[IO.FileMode]::Create)
[byte[]]$buffer = New-Object byte[] 1024
[int]$total = [int]$count = 0
# loop through the download stream and send the data to the target file
do{
$count = $reader.Read($buffer, 0, $buffer.Length);
$writer.Write($buffer, 0, $count);
if(!$quiet) {
$total += $count
if($goal -gt 0) {
Write-Progress "Downloading $url to $fileName" "Saving $total of $goal" -id 0 -percentComplete (($total/$goal)*100)
} else {
Write-Progress "Downloading $url to $fileName" "Saving $total bytes..." -id 0 -Completed
}
if ($total -eq $goal) {
Write-Progress "Completed download of $url." "Completed a total of $total bytes of $fileName" -id 0 -Completed
}
}
} while ($count -ne 0)
$writer.Flush()
$writer.close()
}
function Get-ProcessorBits {
<#
.SYNOPSIS
Get the system architecture address width.
.DESCRIPTION
This will return the system architecture address width (probably 32 or 64 bit).
.PARAMETER compare
This optional parameter causes the function to return $True or $False, depending on wether or not the bitwidth matches.
.NOTES
When your installation script has to know what architecture it is run on, this simple function comes in handy.
#>
param(
$compare # You can optionally pass a value to compare the system architecture and receive $True or $False in stead of 32|64|nn
)
Write-Debug "Running 'Get-ProcessorBits'"
$bits = 64
if ([System.IntPtr]::Size -eq 4) {
$bits = 32
}
# Return bool|int
if ("$compare" -ne '' -and $compare -eq $bits) {
return $true
} elseif ("$compare" -ne '') {
return $false
} else {
return $bits
}
}
function Get-UACEnabled {
$uacRegPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
$uacRegValue = "EnableLUA"
$uacEnabled = $false
Write-Debug "Running 'Get-UACEnabled'";
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx
$osVersion = [Environment]::OSVersion.Version
if ($osVersion -ge [Version]'6.0')
{
$uacRegSetting = Get-ItemProperty -Path $uacRegPath
try {
$uacValue = $uacRegSetting.EnableLUA
if ($uacValue -eq 1) {
$uacEnabled = $true
}
} catch {
#regkey doesn't exist, so proceed with false
}
}
return $uacEnabled
}
function Get-VirusCheckValid {
param(
[string] $location,
[string] $file = ''
)
Write-Debug "Running 'Get-VirusCheckValid' with location:`'$location`', file: `'$file`'";
Write-Debug "Right now there is no virus checking built in."
#if ($settings:virusCheck) {
#}
#if virus check is invalid, throw here
}
# http://poshcode.org/417
## Get-WebFile (aka wget for PowerShell)
##############################################################################################################
## Downloads a file or page from the web
## History:
## v3.6 - Add -Passthru switch to output TEXT files
## v3.5 - Add -Quiet switch to turn off the progress reports ...
## v3.4 - Add progress report for files which don't report size
## v3.3 - Add progress report for files which report their size
## v3.2 - Use the pure Stream object because StreamWriter is based on TextWriter:
## it was messing up binary files, and making mistakes with extended characters in text
## v3.1 - Unwrap the filename when it has quotes around it
## v3 - rewritten completely using HttpWebRequest + HttpWebResponse to figure out the file name, if possible
## v2 - adds a ton of parsing to make the output pretty
## added measuring the scripts involved in the command, (uses Tokenizer)
##############################################################################################################
function Get-WebFile {
param(
$url = '', #(Read-Host "The URL to download"),
$fileName = $null,
$userAgent = 'chocolatey command line',
[switch]$Passthru,
[switch]$quiet
)
Write-Debug "Running 'Get-WebFile' for $fileName with url:`'$url`', userAgent: `'$userAgent`' ";
#if ($url -eq '' return)
$req = [System.Net.HttpWebRequest]::Create($url);
$defaultCreds = [System.Net.CredentialCache]::DefaultCredentials
if ($defaultCreds -ne $null) {
$req.Credentials = $defaultCreds
}
# check if a proxy is required
$webclient = new-object System.Net.WebClient
if ($defaultCreds -ne $null) {
$webClient.Credentials = $defaultCreds
}
if (!$webclient.Proxy.IsBypassed($url))
{
$creds = [net.CredentialCache]::DefaultCredentials
if ($creds -eq $null) {
Write-Debug "Default credentials were null. Attempting backup method"
$cred = get-credential
$creds = $cred.GetNetworkCredential();
}
$proxyaddress = $webclient.Proxy.GetProxy($url).Authority
Write-host "Using this proxyserver: $proxyaddress"
$proxy = New-Object System.Net.WebProxy($proxyaddress)
$proxy.credentials = $creds
$req.proxy = $proxy
}
$req.Accept = "*/*"
$req.AllowAutoRedirect = $true
$req.MaximumAutomaticRedirections = 20
#$req.KeepAlive = $true
#http://stackoverflow.com/questions/518181/too-many-automatic-redirections-were-attempted-error-message-when-using-a-httpw
$req.CookieContainer = New-Object System.Net.CookieContainer
if ($userAgent -ne $null) {
Write-Debug "Setting the UserAgent to `'$userAgent`'"
$req.UserAgent = $userAgent
}
$res = $req.GetResponse();
if($fileName -and !(Split-Path $fileName)) {
$fileName = Join-Path (Get-Location -PSProvider "FileSystem") $fileName
}
elseif((!$Passthru -and ($fileName -eq $null)) -or (($fileName -ne $null) -and (Test-Path -PathType "Container" $fileName)))
{
[string]$fileName = ([regex]'(?i)filename=(.*)$').Match( $res.Headers["Content-Disposition"] ).Groups[1].Value
$fileName = $fileName.trim("\/""'")
if(!$fileName) {
$fileName = $res.ResponseUri.Segments[-1]
$fileName = $fileName.trim("\/")
if(!$fileName) {
$fileName = Read-Host "Please provide a file name"
}
$fileName = $fileName.trim("\/")
if(!([IO.FileInfo]$fileName).Extension) {
$fileName = $fileName + "." + $res.ContentType.Split(";")[0].Split("/")[1]
}
}
$fileName = Join-Path (Get-Location -PSProvider "FileSystem") $fileName
}
if($Passthru) {
$encoding = [System.Text.Encoding]::GetEncoding( $res.CharacterSet )
[string]$output = ""
}
if($res.StatusCode -eq 200) {
[long]$goal = $res.ContentLength
$reader = $res.GetResponseStream()
if($fileName) {
$writer = new-object System.IO.FileStream $fileName, "Create"
}
[byte[]]$buffer = new-object byte[] 1048576
[long]$total = [long]$count = [long]$iterLoop =0
do
{
$count = $reader.Read($buffer, 0, $buffer.Length);
if($fileName) {
$writer.Write($buffer, 0, $count);
}
if($Passthru){
$output += $encoding.GetString($buffer,0,$count)
} elseif(!$quiet) {
$total += $count
if($goal -gt 0 -and ++$iterLoop%10 -eq 0) {
Write-Progress "Downloading $url to $fileName" "Saving $total of $goal" -id 0 -percentComplete (($total/$goal)*100)
}
if ($total -eq $goal) {
Write-Progress "Completed download of $url." "Completed a total of $total bytes of $fileName" -id 0 -Completed
}
}
} while ($count -gt 0)
$reader.Close()
if($fileName) {
$writer.Flush()
$writer.Close()
}
if($Passthru){
$output
}
}
$res.Close();
}
# this could be cleaned up with http://learn-powershell.net/2013/02/08/powershell-and-events-object-events/
function Get-WebHeaders {
param(
$url = '',
$userAgent = 'chocolatey command line'
)
Write-Debug "Running 'Get-WebHeaders' with url:`'$url`', userAgent: `'$userAgent`'";
if ($url -eq '') { return }
$request = [System.Net.HttpWebRequest]::Create($url);
$defaultCreds = [System.Net.CredentialCache]::DefaultCredentials
if ($defaultCreds -ne $null) {
$request.Credentials = $defaultCreds
}
#$request.Method = "HEAD"
# check if a proxy is required
$client = New-Object System.Net.WebClient
if ($defaultCreds -ne $null) {
$client.Credentials = $defaultCreds
}
if (!$client.Proxy.IsBypassed($url))
{
$creds = [Net.CredentialCache]::DefaultCredentials
if ($creds -eq $null) {
Write-Debug "Default credentials were null. Attempting backup method"
$cred = Get-Credential
$creds = $cred.GetNetworkCredential();
}
$proxyAddress = $client.Proxy.GetProxy($url).Authority
Write-Host "Using this proxyserver: $proxyAddress"
$proxy = New-Object System.Net.WebProxy($proxyAddress)
$proxy.credentials = $creds
$request.proxy = $proxy
}
$request.Accept = '*/*'
$request.AllowAutoRedirect = $true
$request.MaximumAutomaticRedirections = 20
#$request.KeepAlive = $true
$request.Timeout = 20000
#http://stackoverflow.com/questions/518181/too-many-automatic-redirections-were-attempted-error-message-when-using-a-httpw
$request.CookieContainer = New-Object System.Net.CookieContainer
if ($userAgent -ne $null) {
Write-Debug "Setting the UserAgent to `'$userAgent`'"
$request.UserAgent = $userAgent
}
Write-Debug "Request Headers:"
foreach ($key in $request.Headers) {
$value = $request.Headers[$key];
if ($value) {
Write-Debug " `'$key`':`'$value`'"
} else {
Write-Debug " `'$key`'"
}
}
$headers = @{}
try {
$response = $request.GetResponse();
Write-Debug "Response Headers:"
foreach ($key in $response.Headers) {
$value = $response.Headers[$key];
if ($value) {
$headers.Add("$key","$value")
Write-Debug " `'$key`':`'$value`'"
}
}
$response.Close();
}
catch {
$request.ServicePoint.MaxIdleTime = 0
$request.Abort();
# ruthlessly remove $request to ensure it isn't reused
Remove-Variable request
Start-Sleep 1
[GC]::Collect()
throw
}
$headers
}
function Install-ChocolateyDesktopLink {
param(
[string] $targetFilePath
)
Write-Debug "Running 'Install-ChocolateyDesktopLink' with targetFilePath:`'$targetFilePath`'";
if (test-path($targetFilePath)) {
$desktop = $([System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::DesktopDirectory))
$link = Join-Path $desktop "$([System.IO.Path]::GetFileName($targetFilePath)).lnk"
$workingDirectory = $([System.IO.Path]::GetDirectoryName($targetFilePath))
$wshshell = New-Object -ComObject WScript.Shell
$lnk = $wshshell.CreateShortcut($link )
$lnk.TargetPath = $targetFilePath
$lnk.WorkingDirectory = $workingDirectory
$lnk.Save()
Write-Host "`'$targetFilePath`' has been linked as a shortcut on your desktop"
} else {
$errorMessage = "`'$targetFilePath`' does not exist, not able to create a link"
Write-Error $errorMessage
throw $errorMessage
}
}
function Install-ChocolateyEnvironmentVariable {
<#
.SYNOPSIS
Creates a persistent environment variable
.DESCRIPTION
Install-ChocolateyEnvironmentVariable creates an environment variable
with the specified name and value. The variable is persistent and
will remain after reboots and accross multiple powershell and command
line sessions. The variable can be scoped either to the user or to
the machine. If machine level scoping is specified, the comand is
elevated to an administrative session.
.PARAMETER variableName
The name or key of the environment variable
.PARAMETER variableValue
A string value assigned to the above name.
.PARAMETER variableType
Specifies whether this variable is to be accesible at either the
individual user level or at the Machine level.
.EXAMPLE
Install-ChocolateyEnvironmentVariable "JAVA_HOME" "d:\oracle\jdk\bin"
Creates a User environmet variable "JAVA_HOME" pointing to
"d:\oracle\jdk\bin".
.EXAMPLE
Install-ChocolateyEnvironmentVariable "_NT_SYMBOL_PATH" "symsrv*symsrv.dll*f:\localsymbols*http://msdl.microsoft.com/download/symbols" Machine
Creates a User environmet variable "_NT_SYMBOL_PATH" pointing to
"symsrv*symsrv.dll*f:\localsymbols*http://msdl.microsoft.com/download/symbols".
The command will be elevated to admin priviledges.
#>
param(
[string] $variableName,
[string] $variableValue,
[System.EnvironmentVariableTarget] $variableType = [System.EnvironmentVariableTarget]::User
)
Write-Debug "Running 'Install-ChocolateyEnvironmentVariable' with variableName:`'$variableName`' and variableValue:`'$variableValue`'";
if ($variableType -eq [System.EnvironmentVariableTarget]::Machine) {
if (Test-ProcessAdminRights) {
Set-EnvironmentVariable -Name $variableName -Value $variableValue -Scope $variableType
} else {
$psArgs = "Install-ChocolateyEnvironmentVariable -variableName `'$variableName`' -variableValue `'$variableValue`' -variableType `'$variableType`'"
Start-ChocolateyProcessAsAdmin "$psArgs"
}
} else {
Set-EnvironmentVariable -Name $variableName -Value $variableValue -Scope $variableType
}
Set-Content env:\$variableName $variableValue
}
function Install-ChocolateyFileAssociation {
<#
.SYNOPSIS
Creates an association between a file extension and a executable
.DESCRIPTION
Install-ChocolateyFileAssociation can associate a file extension
with a downloaded application. Once this command has created an
association, all invocations of files with the specified extension
will be opened via the executable specified.
This command will run with elevated privileges.
.PARAMETER Extension
The file extension to be associated.
.PARAMETER Executable
The path to the application's executable to be associated.
.EXAMPLE
C:\PS>$sublimeDir = (Get-ChildItem $env:ALLUSERSPROFILE\chocolatey\lib\sublimetext* | select $_.last)
C:\PS>$sublimeExe = "$sublimeDir\tools\sublime_text.exe"
C:\PS>Install-ChocolateyFileAssociation ".txt" $sublimeExe
This will create an association between Sublime Text 2 and all .txt files. Any .txt file opened will by default open with Sublime Text 2.
#>
param(
[string] $extension,
[string] $executable
)
Write-Debug "Running 'Install-ChocolateyFileAssociation' associating $extension with `'$executable`'";
if(-not(Test-Path $executable)){
$errorMessage = "`'$executable`' does not exist, not able to create association"
Write-Error $errorMessage
throw $errorMessage
}
$extension=$extension.trim()
if(-not($extension.StartsWith("."))) {
$extension = ".$extension"
}
$fileType = Split-Path $executable -leaf
$fileType = $fileType.Replace(" ","_")
$elevated = "cmd /c 'assoc $extension=$fileType';cmd /c 'ftype $fileType=\`"$executable\`" \`"%1\`" \`"%*\`"'"
Start-ChocolateyProcessAsAdmin $elevated
Write-Host "`'$extension`' has been associated with `'$executable`'"
}
function Install-ChocolateyPackage {
<#
.SYNOPSIS
Installs a package
.DESCRIPTION
This will download a file from a url and install it on your machine.
.PARAMETER PackageName
The name of the package we want to download - this is arbitrary, call it whatever you want.
It's recommended you call it the same as your nuget package id.
.PARAMETER FileType
This is the extension of the file. This should be either exe or msi.
.PARAMETER SilentArgs
OPTIONAL - These are the parameters to pass to the native installer.
Try any of these to get the silent installer - /s /S /q /Q /quiet /silent /SILENT /VERYSILENT
With msi it is always /quiet. Please pass it in still but it will be overridden by chocolatey to /quiet.
If you don't pass anything it will invoke the installer with out any arguments. That means a nonsilent installer.
Please include the notSilent tag in your chocolatey nuget package if you are not setting up a silent package.
.PARAMETER Url
This is the url to download the file from.
.PARAMETER Url64bit
OPTIONAL - If there is an x64 installer to download, please include it here. If not, delete this parameter
.PARAMETER Checksum
OPTIONAL (Right now) - This allows a checksum to be validated for files that are not local
.PARAMETER Checksum64
OPTIONAL (Right now) - This allows a checksum to be validated for files that are not local
.PARAMETER ChecksumType
OPTIONAL (Right now) - 'md5' or 'sha1' - defaults to 'md5'
.PARAMETER ChecksumType64
OPTIONAL (Right now) - 'md5' or 'sha1' - defaults to ChecksumType
.EXAMPLE
Install-ChocolateyPackage '__NAME__' 'EXE_OR_MSI' 'SILENT_ARGS' 'URL' '64BIT_URL_DELETE_IF_NO_64BIT'
.OUTPUTS
None
.NOTES
This helper reduces the number of lines one would have to write to download and install a file to 1 line.
This method has error handling built into it.
.LINK
Get-ChocolateyWebFile
Install-ChocolateyInstallPackage
#>
param(
[string] $packageName,
[string] $fileType = 'exe',
[string] $silentArgs = '',
[string] $url,
[string] $url64bit = '',
$validExitCodes = @(0),
[string] $checksum = '',
[string] $checksumType = '',
[string] $checksum64 = '',
[string] $checksumType64 = ''
)
try {
Write-Debug "Running 'Install-ChocolateyPackage' for $packageName with url:`'$url`', args: `'$silentArgs`', fileType: `'$fileType`', url64bit: `'$url64bit`', checksum: `'$checksum`', checksumType: `'$checksumType`', checksum64: `'$checksum64`', checksumType64: `'$checksumType64`', validExitCodes: `'$validExitCodes`' ";
$chocTempDir = Join-Path $env:TEMP "chocolatey"
$tempDir = Join-Path $chocTempDir "$packageName"
if (![System.IO.Directory]::Exists($tempDir)) { [System.IO.Directory]::CreateDirectory($tempDir) | Out-Null }
$file = Join-Path $tempDir "$($packageName)Install.$fileType"
Get-ChocolateyWebFile $packageName $file $url $url64bit -checksum $checksum -checksumType $checksumType -checksum64 $checksum64 -checksumType64 $checksumType64
Install-ChocolateyInstallPackage $packageName $fileType $silentArgs $file -validExitCodes $validExitCodes
Write-ChocolateySuccess $packageName
} catch {
Write-ChocolateyFailure $packageName $($_.Exception.Message)
throw
}
}
function Install-ChocolateyPath {
param(
[string] $pathToInstall,
[System.EnvironmentVariableTarget] $pathType = [System.EnvironmentVariableTarget]::User
)
Write-Debug "Running 'Install-ChocolateyPath' with pathToInstall:`'$pathToInstall`'";
$originalPathToInstall = $pathToInstall
#get the PATH variable
$envPath = $env:PATH
if (!$envPath.ToLower().Contains($pathToInstall.ToLower()))
{
Write-Host "PATH environment variable does not have $pathToInstall in it. Adding..."
$actualPath = Get-EnvironmentVariable -Name 'Path' -Scope $pathType
$statementTerminator = ";"
#does the path end in ';'?
$hasStatementTerminator = $actualPath -ne $null -and $actualPath.EndsWith($statementTerminator)
# if the last digit is not ;, then we are adding it
If (!$hasStatementTerminator -and $actualPath -ne $null) {$pathToInstall = $statementTerminator + $pathToInstall}
if (!$pathToInstall.EndsWith($statementTerminator)) {$pathToInstall = $pathToInstall + $statementTerminator}
$actualPath = $actualPath + $pathToInstall
if ($pathType -eq [System.EnvironmentVariableTarget]::Machine) {
if (Test-ProcessAdminRights) {
Set-EnvironmentVariable -Name 'Path' -Value $actualPath -Scope $pathType
} else {
$psArgs = "Install-ChocolateyPath -pathToInstall `'$originalPathToInstall`' -pathType `'$pathType`'"
Start-ChocolateyProcessAsAdmin "$psArgs"
}
} else {
Set-EnvironmentVariable -Name 'Path' -Value $actualPath -Scope $pathType
}
#add it to the local path as well so users will be off and running
$envPSPath = $env:PATH
$env:Path = $envPSPath + $statementTerminator + $pathToInstall
}
}
function Install-ChocolateyPowershellCommand {
param(
[string] $packageName,
[string] $psFileFullPath,
[string] $url ='',
[string] $url64bit = '',
[string] $checksum = '',
[string] $checksumType = '',
[string] $checksum64 = '',
[string] $checksumType64 = ''
)
Write-Debug "Running 'Install-ChocolateyPowershellCommand' for $packageName with psFileFullPath:`'$psFileFullPath`', url: `'$url`', url64bit:`'$url64bit`', checkSum: `'$checksum`', checksumType: `'$checksumType`', checkSum64: `'$checksum64`', checksumType64: `'$checksumType64`' ";
try {
if ($url -ne '') {
Get-ChocolateyWebFile $packageName $psFileFullPath $url $url64bit -checksum $checksum -checksumType $checksumType -checksum64 $checksum64 -checksumType64 $checksumType64
}
$nugetPath = $(Split-Path -parent $(Split-Path -parent $helpersPath))
$nugetExePath = Join-Path $nuGetPath 'bin'
$cmdName = [System.IO.Path]::GetFileNameWithoutExtension($psFileFullPath)
$packageBatchFileName = Join-Path $nugetExePath "$($cmdName).bat"
Write-Host "Adding $packageBatchFileName and pointing it to powershell command $psFileFullPath"
"@echo off
powershell -NoProfile -ExecutionPolicy unrestricted -Command ""& `'$psFileFullPath`' %*"""| Out-File $packageBatchFileName -encoding ASCII
Write-ChocolateySuccess $packageName
} catch {
Write-ChocolateyFailure $packageName $($_.Exception.Message)
throw
}
}
function Install-ChocolateyVsixPackage {
<#
.SYNOPSIS
Downloads and installs a VSIX package for Visual Studio
.PARAMETER PackageName
The name of the package we want to download - this is
arbitrary, call it whatever you want. It's recommended
you call it the same as your nuget package id.
.PARAMETER VsixUrl
The URL of the package to be installed
.PARAMETER VsVersion
The Major version number of Visual Studio where the
package should be installed. This is optional. If not
specified, the most recent Visual Studio installation
will be targetted.
.PARAMETER Checksum
OPTIONAL (Right now) - This allows a checksum to be validated for files that are not local
.PARAMETER ChecksumType
OPTIONAL (Right now) - 'md5' or 'sha1' - defaults to 'md5'
.EXAMPLE
Install-ChocolateyVsixPackage "MyPackage" http://visualstudiogallery.msdn.microsoft.com/ea3a37c9-1c76-4628-803e-b10a109e7943/file/73131/1/AutoWrockTestable.vsix
This downloads the AutoWrockTestable VSIX from the Visual Studio Gallery and installs it to the latest version of VS.
.EXAMPLE
Install-ChocolateyVsixPackage "MyPackage" http://visualstudiogallery.msdn.microsoft.com/ea3a37c9-1c76-4628-803e-b10a109e7943/file/73131/1/AutoWrockTestable.vsix 11
This downloads the AutoWrockTestable VSIX from the Visual Studio Gallery and installs it to Visual Studio 2012 (v11.0).
.NOTES
VSIX packages are Extensions for the Visual Studio IDE.
The Visual Sudio Gallery at
http://visualstudiogallery.msdn.microsoft.com/ is the
public extension feed and hosts thousands of extensions.
You can locate a VSIX Url by finding the download link
of Visual Studio extensions on the Visual Studio Gallery.
#>
param(
[string]$packageName,
[string]$vsixUrl,
[int]$vsVersion=0,
[string] $checksum = '',
[string] $checksumType = ''
)
Write-Debug "Running 'Install-ChocolateyVsixPackage' for $packageName with vsixUrl:`'$vsixUrl`', vsVersion: `'$vsVersion`', checksum: `'$checksum`', checksumType: `'$checksumType`' ";
if($vsVersion -eq 0) {
$versions=(get-ChildItem HKLM:SOFTWARE\Wow6432Node\Microsoft\VisualStudio -ErrorAction SilentlyContinue | ? { ($_.PSChildName -match "^[0-9\.]+$") } | ? {$_.property -contains "InstallDir"} | sort {[int]($_.PSChildName)} -descending)
if($versions -and $versions.Length){
$version = $versions[0]
}elseif($versions){
$version = $versions
}
}
else {
$version=(get-ChildItem HKLM:SOFTWARE\Wow6432Node\Microsoft\VisualStudio -ErrorAction SilentlyContinue | ? { ($_.PSChildName.EndsWith("$vsVersion.0")) } | ? {$_.property -contains "InstallDir"})
}
if($version){
$vnum=$version.PSPath.Substring($version.PSPath.LastIndexOf('\')+1)
if($vnum -as [int] -lt 10) {
Write-ChocolateyFailure $packageName "This installed VS version, $vnum, does not support installing VSIX packages. Version 10 is the minimum acceptable version."
return
}
$dir=(get-itemProperty $version.PSPath "InstallDir").InstallDir
$installer = Join-Path $dir "VsixInstaller.exe"
}
if($installer) {
$download="$env:temp\$($packageName.Replace(' ','')).vsix"
try{
Get-ChocolateyWebFile $packageName $download $vsixUrl -checksum $checksum -checksumType $checksumType
}
catch {
Write-ChocolateyFailure $packageName "There were errors attempting to retrieve the vsix from $vsixUrl. The error message was '$_'."
return
}
Write-Debug "Installing VSIX using $installer"
$exitCode = Install-Vsix "$installer" "$download"
if($exitCode -gt 0 -and $exitCode -ne 1001) { #1001: Already installed
Write-ChocolateyFailure $packageName "There was an error installing '$packageName'. The exit code returned was $exitCode."
return
}
Write-ChocolateySuccess $packageName
}
else {
Write-ChocolateyFailure $packageName "Visual Studio is not installed or the specified version is not present."
}
}
function Install-Vsix($installer, $installFile) {
Write-Host "Installing $installFile using $installer"
$psi = New-Object System.Diagnostics.ProcessStartInfo
$psi.FileName=$installer
$psi.Arguments="/q $installFile"
$s = [System.Diagnostics.Process]::Start($psi)
$s.WaitForExit()
return $s.ExitCode
}
function Install-ChocolateyZipPackage {
<#
.SYNOPSIS
Downloads and unzips a package
.DESCRIPTION
This will download a file from a url and unzip it on your machine.
.PARAMETER PackageName
The name of the package we want to download - this is arbitrary, call it whatever you want.
It's recommended you call it the same as your nuget package id.
.PARAMETER Url
This is the url to download the file from.
.PARAMETER Url64bit
OPTIONAL - If there is an x64 installer to download, please include it here. If not, delete this parameter
.PARAMETER UnzipLocation
This is a location to unzip the contents to, most likely your script folder.
.PARAMETER Checksum
OPTIONAL (Right now) - This allows a checksum to be validated for files that are not local
.PARAMETER Checksum64
OPTIONAL (Right now) - This allows a checksum to be validated for files that are not local
.PARAMETER ChecksumType
OPTIONAL (Right now) - 'md5' or 'sha1' - defaults to 'md5'
.PARAMETER ChecksumType64
OPTIONAL (Right now) - 'md5' or 'sha1' - defaults to ChecksumType
.EXAMPLE
Install-ChocolateyZipPackage '__NAME__' 'URL' "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
.OUTPUTS
None
.NOTES
This helper reduces the number of lines one would have to write to download and unzip a file to 1 line.
This method has error handling built into it.
.LINK
Get-ChocolateyWebFile
Get-ChocolateyUnzip
#>
param(
[string] $packageName,
[string] $url,
[string] $unzipLocation,
[string] $url64bit = $url,
[string] $specificFolder ="",
[string] $checksum = '',
[string] $checksumType = '',
[string] $checksum64 = '',
[string] $checksumType64 = ''
)
Write-Debug "Running 'Install-ChocolateyZipPackage' for $packageName with url:`'$url`', unzipLocation: `'$unzipLocation`', url64bit: `'$url64bit`', specificFolder: `'$specificFolder`', checksum: `'$checksum`', checksumType: `'$checksumType`', checksum64: `'$checksum64`', checksumType64: `'$checksumType64`' ";
try {
$fileType = 'zip'
$chocTempDir = Join-Path $env:TEMP "chocolatey"
$tempDir = Join-Path $chocTempDir "$packageName"
if (![System.IO.Directory]::Exists($tempDir)) {[System.IO.Directory]::CreateDirectory($tempDir) | Out-Null}
$file = Join-Path $tempDir "$($packageName)Install.$fileType"
Get-ChocolateyWebFile $packageName $file $url $url64bit -checkSum $checkSum -checksumType $checksumType -checkSum64 $checkSum64 -checksumType64 $checksumType64
Get-ChocolateyUnzip "$file" $unzipLocation $specificFolder $packageName
Write-ChocolateySuccess $packageName
} catch {
Write-ChocolateyFailure $packageName $($_.Exception.Message)
throw
}
}
function Set-EnvironmentVariable([string] $Name, [string] $Value, [System.EnvironmentVariableTarget] $Scope) {
[Environment]::SetEnvironmentVariable($Name, $Value, $Scope)
}
function Start-ChocolateyProcessAsAdmin {
param(
[string] $statements,
[string] $exeToRun = 'powershell',
[switch] $minimized,
[switch] $noSleep,
$validExitCodes = @(0)
)
Write-Debug "Running 'Start-ChocolateyProcessAsAdmin' with exeToRun:`'$exeToRun`', statements: `'$statements`' ";
$wrappedStatements = $statements;
if ($exeToRun -eq 'powershell') {
$exeToRun = "$($env:windir)\System32\WindowsPowerShell\v1.0\powershell.exe"
if (!$statements.EndsWith(';')){$statements = $statements + ';'}
$importChocolateyHelpers = "";
Get-ChildItem "$helpersPath" -Filter *.psm1 | ForEach-Object { $importChocolateyHelpers = "& import-module -name `'$($_.FullName)`';$importChocolateyHelpers" };
$wrappedStatements = "-NoProfile -ExecutionPolicy unrestricted -Command `"$importChocolateyHelpers try{$statements start-sleep 6;}catch{write-error `'That was not sucessful`';start-sleep 8;throw;}`""
if ($noSleep) {
$wrappedStatements = "-NoProfile -ExecutionPolicy unrestricted -Command `"$importChocolateyHelpers try{$statements}catch{write-error `'That was not sucessful`';throw;}`""
}
}
@"
Elevating Permissions and running $exeToRun $wrappedStatements. This may take awhile, depending on the statements.
"@ | Write-Debug
$psi = new-object System.Diagnostics.ProcessStartInfo;
$psi.FileName = $exeToRun;
if ($wrappedStatements -ne '') {
$psi.Arguments = "$wrappedStatements";
}
if ([Environment]::OSVersion.Version -ge (new-object 'Version' 6,0)){
$psi.Verb = "runas";
}
$psi.WorkingDirectory = get-location;
if ($minimized) {
$psi.WindowStyle = [System.Diagnostics.ProcessWindowStyle]::Minimized;
}
$s = [System.Diagnostics.Process]::Start($psi);
$s.WaitForExit();
if ($validExitCodes -notcontains $s.ExitCode) {
$errorMessage = "[ERROR] Running $exeToRun with $statements was not successful. Exit code was `'$($s.ExitCode)`'."
Write-Error $errorMessage
throw $errorMessage
}
Write-Debug "Finishing 'Start-ChocolateyProcessAsAdmin'";
}
function Test-ProcessAdminRights {
<#
.SYNOPSIS
Tests whether the current process is running with administrative rights.
.DESCRIPTION
This function checks whether the current process has administrative rights
by checking if the current user identity is a member of the Administrators group.
It returns $true if the current process is running with administrative rights,
$false otherwise.
On Windows Vista and later, with UAC enabled, the returned value represents the
actual rights available to the process, i.e. if it returns $true, the process is
running elevated.
.OUTPUTS
System.Boolean
#>
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent([Security.Principal.TokenAccessLevels]'Query,Duplicate'))
$isAdmin = $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
Write-Debug "Test-ProcessAdminRights: returning $isAdmin"
return $isAdmin
}
function Uninstall-ChocolateyPackage {
<#
.SYNOPSIS
Uninstalls a package
.DESCRIPTION
This will uninstall a package on your machine.
.PARAMETER PackageName
The name of the package
.PARAMETER FileType
This is the extension of the file. This should be either exe or msi.
.PARAMETER SilentArgs
Please include the notSilent tag in your chocolatey nuget package if you are not setting up a silent package.
.PARAMETER File
The full path to the native uninstaller to run
.EXAMPLE
Uninstall-ChocolateyPackage '__NAME__' 'EXE_OR_MSI' 'SILENT_ARGS' 'FilePath'
.OUTPUTS
None
.NOTES
This helper reduces the number of lines one would have to write to run an uninstaller to 1 line.
There is no error handling built into this method.
.LINK
Uninstall-ChocolateyPackage
#>
param(
[string] $packageName,
[string] $fileType = 'exe',
[string] $silentArgs = '',
[string] $file,
$validExitCodes = @(0)
)
Write-Debug "Running 'Uninstall-ChocolateyPackage' for $packageName with fileType:`'$fileType`', silentArgs: `'$silentArgs`', file: `'$file`'";
$installMessage = "Uninstalling $packageName..."
write-host $installMessage
$additionalInstallArgs = $env:chocolateyInstallArguments;
if ($additionalInstallArgs -eq $null) { $additionalInstallArgs = ''; }
$overrideArguments = $env:chocolateyInstallOverride;
if ($fileType -like 'msi') {
$msiArgs = "/x"
if ($overrideArguments) {
$msiArgs = "$msiArgs $additionalInstallArgs";
write-host "Overriding package arguments with `'$additionalInstallArgs`'";
} else {
$msiArgs = "$msiArgs $silentArgs $additionalInstallArgs";
}
Start-ChocolateyProcessAsAdmin "$msiArgs" 'msiexec' -validExitCodes $validExitCodes
#Start-Process -FilePath msiexec -ArgumentList $msiArgs -Wait
}
if ($fileType -like 'exe') {
if ($overrideArguments) {
Start-ChocolateyProcessAsAdmin "$additionalInstallArgs" $file -validExitCodes $validExitCodes
write-host "Overriding package arguments with `'$additionalInstallArgs`'";
} else {
Start-ChocolateyProcessAsAdmin "$silentArgs $additionalInstallArgs" $file -validExitCodes $validExitCodes
}
}
write-host "$packageName has been uninstalled."
#cutStart-Sleep 3
}
function UnInstall-ChocolateyZipPackage {
<#
.SYNOPSIS
UnInstalls a previous installed zip package
.DESCRIPTION
This will uninstall a zip file if installed via Install-ChocolateyZipPackage
.PARAMETER PackageName
The name of the package the zip file is associated with
.PARAMETER ZipFileName
This is the zip filename originally installed.
.EXAMPLE
UnInstall-ChocolateyZipPackage '__NAME__' 'filename.zip'
.OUTPUTS
None
.NOTES
This helper reduces the number of lines one would have to remove the files extracted from a previously installed zip file.
This method has error handling built into it.
#>
param(
[string] $packageName,
[string] $zipFileName
)
Write-Debug "Running 'UnInstall-ChocolateyZipPackage' for $packageName $zipFileName "
try {
$packagelibPath=$env:chocolateyPackageFolder
$zipContentFile=(join-path $packagelibPath $zipFileName) + ".txt"
$zipContentFile
$zipContents=get-content $zipContentFile
foreach ($fileInZip in $zipContents) {
remove-item "$fileInZip" -ErrorAction SilentlyContinue
}
Write-ChocolateySuccess $packageName
} catch {
Write-ChocolateyFailure $packageName $($_.Exception.Message)
throw
}
}
function Update-SessionEnvironment {
<#
.SYNOPSIS
Updates the environment variables of the current powershell session with
any environment variable changes that may have occured during a chocolatey
package install.
.DESCRIPTION
When chocolatey installs a package, the package author may add or change
certain environment variables that will affect how the application runs
or how it is accessed. Often, these changes are not visible to the current
powershell session. This means the user needs to open a new powershell
session before these settings take effect which can render the installed
application unfunctional until that time.
Use the Update-SessionEnvironment command to refresh the current
powershell session with all environment settings possibly performed by
chocolatey package installs.
#>
#ordering is important here, $user comes after so we can override $machine
'Machine', 'User' |
% {
$scope = $_
Get-EnvironmentVariableNames -Scope $scope |
% {
Set-Item "Env:$($_)" -Value (Get-EnvironmentVariable -Scope $scope -Name $_)
}
}
#Path gets special treatment b/c it munges the two together
$paths = 'Machine', 'User' |
% {
(Get-EnvironmentVariable -Name 'PATH' -Scope $_) -split ';'
} |
Select -Unique
$Env:PATH = $paths -join ';'
}
function Write-ChocolateyFailure {
param(
[string] $packageName,
[string] $failureMessage
)
$chocTempDir = Join-Path $env:TEMP "chocolatey"
$tempDir = Join-Path $chocTempDir "$packageName"
if (![System.IO.Directory]::Exists($tempDir)) {[System.IO.Directory]::CreateDirectory($tempDir)}
$successLog = Join-Path $tempDir 'success.log'
try {
if ([System.IO.File]::Exists($successLog)) {
$oldSuccessLog = "$successLog".replace('.log','.log.old')
write-debug "Renaming `'$successLog`' to `'$oldSuccessLog`'"
Move-Item $successLog $oldSuccessLog -Force
#[System.IO.File]::Move($successLog,(Join-Path ($successLog) '.old'))
}
} catch {
Write-Error "Could not rename `'$successLog`' to `'$($successLog).old`': $($_.Exception.Message)"
}
$logFile = Join-Path $tempDir 'failure.log'
#Write-Host "Writing to $logFile"
$errorMessage = "$packageName did not finish successfully. Boo to the chocolatey gods!
-----------------------
[ERROR] $failureMessage
-----------------------"
$errorMessage | Out-File -FilePath $logFile -Force -Append
Write-Error $errorMessage
}
function Write-ChocolateySuccess {
param(
[string] $packageName
)
$chocTempDir = Join-Path $env:TEMP "chocolatey"
$tempDir = Join-Path $chocTempDir "$packageName"
if (![System.IO.Directory]::Exists($tempDir)) {[System.IO.Directory]::CreateDirectory($tempDir)}
$errorLog = Join-Path $tempDir 'failure.log'
try {
if ([System.IO.File]::Exists($errorLog)) {
$oldErrorLog = "$errorLog".replace('.log','.log.old')
write-debug "Renaming `'$errorLog`' to `'$olderrorLog`'"
Move-Item $errorLog $oldErrorLog -Force
#[System.IO.File]::Move($errorLog,(Join-Path ($errorLog) '.old'))
}
} catch {
Write-Error "Could not rename `'$errorLog`' to `'$($errorLog).old`': $($_.Exception.Message)"
}
$logFile = Join-Path $tempDir 'success.log'
#Write-Host "Writing to $logFile"
$successMessage = "$packageName has finished successfully! The chocolatey gods have answered your request!"
$successMessage | Out-File -FilePath $logFile -Force -Append
Write-Host $successMessage
}
function Write-Debug {
param(
[Parameter(Position=0,Mandatory=$false,ValueFromPipeline=$true)][object] $Message,
[Parameter()][switch] $NoNewLine,
[Parameter(Mandatory=$false)][ConsoleColor] $ForegroundColor,
[Parameter(Mandatory=$false)][ConsoleColor] $BackgroundColor,
[Parameter(Mandatory=$false)][Object] $Separator
)
$chocoPath = (Split-Path -parent $helpersPath)
$chocoInstallLog = Join-Path $chocoPath 'chocolateyInstall.log'
"$(get-date -format 'yyyyMMdd-HH:mm:ss') [DEBUG] $Message" | Out-File -FilePath $chocoInstallLog -Force -Append
$oc = Get-Command 'Write-Debug' -Module 'Microsoft.PowerShell.Utility'
#I owe this guy a drink - http://powershell.com/cs/blogs/tobias/archive/2011/08/03/clever-splatting-to-pass-optional-parameters.aspx
& $oc @PSBoundParameters
}
function Write-Error {
param(
[Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)][string] $Message='',
[Parameter(Mandatory=$false)][System.Management.Automation.ErrorCategory] $Category,
[Parameter(Mandatory=$false)][string] $ErrorId,
[Parameter(Mandatory=$false)][object] $TargetObject,
[Parameter(Mandatory=$false)][string] $CategoryActivity,
[Parameter(Mandatory=$false)][string] $CategoryReason,
[Parameter(Mandatory=$false)][string] $CategoryTargetName,
[Parameter(Mandatory=$false)][string] $CategoryTargetType,
[Parameter(Mandatory=$false)][string] $RecommendedAction
)
$chocoPath = (Split-Path -parent $helpersPath)
$chocoInstallLog = Join-Path $chocoPath 'chocolateyInstall.log'
"$(get-date -format 'yyyyMMdd-HH:mm:ss') [ERROR] $Message" | Out-File -FilePath $chocoInstallLog -Force -Append
$oc = Get-Command 'Write-Error' -Module 'Microsoft.PowerShell.Utility'
& $oc @PSBoundParameters
}
function Write-FileUpdateLog {
param (
[string] $logFilePath,
[string] $locationToMonitor,
[scriptblock] $scriptToRun,
[object[]] $argumentList
)
Write-Debug "Running 'Write-FileUpdateLog' with logFilePath:`'$logFilePath`'', locationToMonitor:$locationToMonitor, Operation: `'$scriptToRun`'";
Write-Debug "Tracking current state of `'$locationToMonitor`'"
$originalContents = Get-ChildItem -Recurse $locationToMonitor | Select-Object LastWriteTimeUTC,FullName,Length
Invoke-Command -ScriptBlock $scriptToRun -ArgumentList $argumentList
$newContents = Get-ChildItem -Recurse $locationToMonitor | Select-Object LastWriteTimeUTC,FullName,Length
if($originalContents -eq $null) {$originalContents = @()}
if($newContents -eq $null) {$newContents = @()}
$changedFiles = Compare-Object $originalContents $newContents -Property LastWriteTimeUtc,FullName,Length -PassThru | Group-Object FullName
#log modified files
$changedFiles | ? {$_.Count -gt 1} | % {$_.Name} | Add-Content $logFilePath
#log added files
$addOrDelete = $changedFiles | ? { $_.Count -eq 1 } | % {$_.Group}
$addOrDelete | ? {$_.SideIndicator -eq "=>"} | % {$_.FullName} | Add-Content $logFilePath
#log deleted files
#$addOrDelete | ? {$_.SideIndicator -eq "<="} | % {$_.FullName} | Add-Content $logFilePath
}
function Write-Host {
param(
[Parameter(Position=0,Mandatory=$false,ValueFromPipeline=$true, ValueFromRemainingArguments=$true)][object] $Object,
[Parameter()][switch] $NoNewLine,
[Parameter(Mandatory=$false)][ConsoleColor] $ForegroundColor,
[Parameter(Mandatory=$false)][ConsoleColor] $BackgroundColor,
[Parameter(Mandatory=$false)][Object] $Separator
)
$chocoPath = (Split-Path -parent $helpersPath)
$chocoInstallLog = Join-Path $chocoPath 'chocolateyInstall.log'
"$(get-date -format 'yyyyMMdd-HH:mm:ss') [CHOCO] $Object"| Out-File -FilePath $chocoInstallLog -Force -Append
$oc = Get-Command 'Write-Host' -Module 'Microsoft.PowerShell.Utility'
if($env:ChocolateyEnvironmentQuiet -eq 'true') {
$oc = {}
}
#I owe this guy a drink - http://powershell.com/cs/blogs/tobias/archive/2011/08/03/clever-splatting-to-pass-optional-parameters.aspx
& $oc @PSBoundParameters
}
Copyright 2011 - Present Rob Reynolds, the maintainers of Chocolatey, and RealDimensions Software, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
@echo off
::
:: RefreshEnv.cmd
::
:: Batch file to read environment variables from registry and
:: set session variables to these values.
::
:: With this batch file, there should be no need to reload command
:: environment every time you want environment changes to propagate
echo | set /p dummy="Reading environment variables from registry. Please wait... "
goto main
:: Set one environment variable from registry key
:SetFromReg
"%WinDir%\System32\Reg" QUERY "%~1" /v "%~2" > "%TEMP%\_envset.tmp" 2>NUL
for /f "usebackq skip=2 tokens=2,*" %%A IN ("%TEMP%\_envset.tmp") do (
echo/set %~3=%%B
)
goto :EOF
:: Get a list of environment variables from registry
:GetRegEnv
"%WinDir%\System32\Reg" QUERY "%~1" > "%TEMP%\_envget.tmp"
for /f "usebackq skip=2" %%A IN ("%TEMP%\_envget.tmp") do (
if /I not "%%~A"=="Path" (
call :SetFromReg "%~1" "%%~A" "%%~A"
)
)
goto :EOF
:main
echo/@echo off >"%TEMP%\_env.cmd"
:: Slowly generating final file
call :GetRegEnv "HKLM\System\CurrentControlSet\Control\Session Manager\Environment" >> "%TEMP%\_env.cmd"
call :GetRegEnv "HKCU\Environment">>"%TEMP%\_env.cmd" >> "%TEMP%\_env.cmd"
:: Special handling for PATH - mix both User and System
call :SetFromReg "HKLM\System\CurrentControlSet\Control\Session Manager\Environment" Path Path_HKLM >> "%TEMP%\_env.cmd"
call :SetFromReg "HKCU\Environment" Path Path_HKCU >> "%TEMP%\_env.cmd"
:: Caution: do not insert space-chars before >> redirection sign
echo/set Path=%%Path_HKLM%%;%%Path_HKCU%% >> "%TEMP%\_env.cmd"
:: Cleanup
del /f /q "%TEMP%\_envset.tmp" 2>nul
del /f /q "%TEMP%\_envget.tmp" 2>nul
:: Set these variables
call "%TEMP%\_env.cmd"
echo | set /p dummy="Done"
echo .
7-Zip Command line version
~~~~~~~~~~~~~~~~~~~~~~~~~~
License for use and distribution
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7-Zip Copyright (C) 1999-2010 Igor Pavlov.
7za.exe is distributed under the GNU LGPL license
Notes:
You can use 7-Zip on any computer, including a computer in a commercial
organization. You don't need to register or pay for 7-Zip.
GNU LGPL information
--------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You can receive a copy of the GNU Lesser General Public License from
http://www.gnu.org/
CheckSum is licensed as Apache v2 - https://raw.github.com/ferventcoder/checksum/master/LICENSE
Shim Generator - shimgen.exe
Copyright (C) 2013-Present RealDimensions Software, LLC ("RDS")
===================================================================
Grant of License
===================================================================
You may use Shim Generator ("shimgen.exe") only with the official chocolatey client.
The use of shimgen.exe for any other reason is strictly prohibited.
If you would like to use this software for any other reason, you must obtain a personal or commercial license to do so. To do that you must contact RDS at ferventcoder.com.
This software is not free to distribute. If you would like to distribute this software, you must receive written permission from the software owner.
===================================================================
End-User License Agreement
===================================================================
EULA - Shim Generator
IMPORTANT- READ CAREFULLY: This RealDimensions Software ("RDS") End-User License Agreement ("EULA") is a legal agreement between you("End User") and RDS for all RDS products, controls, source code, demos, intermediate files, media, printed materials, and "online" or electronic documentation ("SOFTWARE PRODUCT(S)") contained with this distribution.
RDS grants to you as an individual, a personal, nonexclusive license to install and use the SOFTWARE PRODUCT(S) for the sole purpose of use with the official chocolatey client. By installing, copying, or otherwise using the SOFTWARE PRODUCT(S), you agree to be bound by the terms of this EULA. If you do not agree to any part of the terms of this EULA, DO NOT INSTALL, USE, OR EVALUATE, ANY PART, FILE OR PORTION OF THE SOFTWARE PRODUCT(S).
ALL SOFTWARE PRODUCT(S) are licensed not sold. If you are an individual, you must acquire an individual license for the SOFTWARE PRODUCT(S) from RDS or its authorized resellers. If you are an entity, you must acquire an individual license for each Developer End User and each Build Machine Running the SOFTWARE PRODUCT(S) within your organization from RDS or its authorized resellers. Both Virtual and Physical Build Machines running the SOFTWARE PRODUCT(S) must be counted in the SOFTWARE PRODUCT(S) licenses quantity of the organization.
===================================================================
Commercial / Personal Licensing
===================================================================
Shim Generator (shimgen.exe) is also offered under personal and commercial licenses.
You can learn more about this option by contacting RDS at http://ferventcoder.com
$thisScriptFolder = (Split-Path -parent $MyInvocation.MyCommand.Definition)
$chocInstallVariableName = "ChocolateyInstall"
$sysDrive = $env:SystemDrive
function Initialize-Chocolatey {
<#
.DESCRIPTION
This will initialize the Chocolatey tool by
a) setting up the "nugetPath" (the location where all chocolatey nuget packages will be installed)
b) Installs chocolatey into the "nugetPath"
c) Instals .net 4.0 if needed
d) Adds chocolaty to the PATH environment variable so you have access to the chocolatey|cinst commands.
.PARAMETER NuGetPath
Allows you to override the default path of (C:\Chocolatey\) by specifying a directory chocolaty will install nuget packages.
.EXAMPLE
C:\PS> Initialize-Chocolatey
Installs chocolatey into the default C:\Chocolatey\ directory.
.EXAMPLE
C:\PS> Initialize-Chocolatey -nugetPath "D:\ChocolateyInstalledNuGets\"
Installs chocolatey into the custom directory D:\ChocolateyInstalledNuGets\
#>
param(
[Parameter(Mandatory=$false)][string]$chocolateyPath = ''
)
$installModule = Join-Path $thisScriptFolder 'chocolateyInstall\helpers\chocolateyInstaller.psm1'
Import-Module $installModule -Force
if ($chocolateyPath -eq '') {
$programData = [Environment]::GetFolderPath("CommonApplicationData")
$chocolateyPath = Join-Path "$programData" 'chocolatey'
}
#if we have an already environment variable path, use it.
$alreadyInitializedNugetPath = Get-ChocolateyInstallFolder
if($alreadyInitializedNugetPath -and $alreadyInitializedNugetPath -ne $chocolateyPath){
$chocolateyPath = $alreadyInitializedNugetPath
}
else {
Set-ChocolateyInstallFolder $chocolateyPath
}
Create-DirectoryIfNotExists $chocolateyPath
#set up variables to add
$chocolateyExePath = Join-Path $chocolateyPath 'bin'
$chocolateyLibPath = Join-Path $chocolateyPath 'lib'
$chocolateyInstallPath = Join-Path $chocolateyPath 'chocolateyinstall'
$yourPkgPath = [System.IO.Path]::Combine($chocolateyLibPath,"yourPackageName")
@"
We are setting up the Chocolatey repository for NuGet packages that should be at the machine level. Think executables/application packages, not library packages.
That is what Chocolatey NuGet goodness is for. The repository is set up at `'$chocolateyPath`'.
The packages themselves go to `'$chocolateyLibPath`' (i.e. $yourPkgPath).
A shim file for the command line goes to `'$chocolateyExePath`' and points to an executable in `'$yourPkgPath`'.
Creating Chocolatey NuGet folders if they do not already exist.
"@ | Write-Host
#create the base structure if it doesn't exist
Create-DirectoryIfNotExists $chocolateyExePath
Create-DirectoryIfNotExists $chocolateyLibPath
Create-DirectoryIfNotExists $chocolateyInstallPath
Install-ChocolateyFiles $chocolateyPath
$chocolateyExePathVariable = $chocolateyExePath.ToLower().Replace($chocolateyPath.ToLower(), "%DIR%..\").Replace("\\","\")
Install-ChocolateyBinFiles $chocolateyInstallPath $chocolateyExePath
Initialize-ChocolateyPath $chocolateyExePath $chocolateyExePathVariable
Process-ChocolateyBinFiles $chocolateyExePath $chocolateyExePathVariable
Install-DotNet4IfMissing $chocolateyInstallPath
$realModule = Join-Path $chocolateyInstallPath "helpers\chocolateyInstaller.psm1"
Import-Module "$realModule" -Force
@"
Chocolatey is now ready.
You can call chocolatey from anywhere, command line or powershell by typing choco.
Run choco /? for a list of functions.
You may need to shut down and restart powershell and/or consoles first prior to using chocolatey.
"@ | write-host
}
function Set-ChocolateyInstallFolder {
param(
[string]$folder
)
$environmentTarget = [System.EnvironmentVariableTarget]::User
if (Test-ProcessAdminRights) {
Write-Debug "Administrator installing so using Machine environment variable target instead of User."
$environmentTarget = [System.EnvironmentVariableTarget]::Machine
}
Write-Host "Creating $chocInstallVariableName as an Environment variable (targeting `'$environmentTarget`') and setting it to `'$folder`'"
Install-ChocolateyEnvironmentVariable -variableName "$chocInstallVariableName" -variableValue "$folder" -variableType $environmentTarget
}
function Get-ChocolateyInstallFolder(){
[Environment]::GetEnvironmentVariable($chocInstallVariableName)
}
function Create-DirectoryIfNotExists($folderName){
if (![System.IO.Directory]::Exists($folderName)) {[System.IO.Directory]::CreateDirectory($folderName) | Out-Null}
}
function Install-ChocolateyBinFiles {
param(
[string] $chocolateyInstallPath,
[string] $chocolateyExePath
)
$redirectsPath = Join-Path $chocolateyInstallPath 'redirects'
$exeFiles = Get-ChildItem "$redirectsPath" -include @("*.exe","*.cmd") -recurse
foreach ($exeFile in $exeFiles) {
$exeFilePath = $exeFile.FullName
$exeFileName = [System.IO.Path]::GetFileName("$exeFilePath")
$binFilePath = Join-Path $chocolateyExePath $exeFileName
$binFilePathRename = $binFilePath + '.old'
$batchFilePath = $binFilePath.Replace(".exe",".bat")
$bashFilePath = $binFilePath.Replace(".exe","")
if (Test-Path ($batchFilePath)) {Remove-Item $batchFilePath -force}
if (Test-Path ($bashFilePath)) {Remove-Item $bashFilePath -force}
if (Test-Path ($binFilePathRename)) {Remove-Item $binFilePathRename -force}
if (Test-Path ($binFilePath)) {Move-Item -path $binFilePath -destination $binFilePathRename -force}
Copy-Item -path $exeFilePath -destination $binFilePath -force
$commandShortcut = [System.IO.Path]::GetFileNameWithoutExtension("$exeFilePath")
Write-Debug "Added command $commandShortcut"
}
}
function Install-ChocolateyFiles {
param(
[string]$chocolateyPath
)
$chocInstallFolder = Join-Path $thisScriptFolder "chocolateyInstall"
Write-Host "Copying the contents of `'$chocInstallFolder`' to `'$chocolateyPath`'."
if(test-path "$chocolateyPath\chocolateyInstall\functions") {
Remove-Item "$chocolateyPath\chocolateyInstall\functions" -recurse -force
}
if(test-path "$chocolateyPath\chocolateyInstall\helpers") {
Remove-Item "$chocolateyPath\chocolateyInstall\helpers" -recurse -force
}
Copy-Item $chocInstallFolder $chocolateyPath -recurse -force
}
function Initialize-ChocolateyPath {
param(
[string]$chocolateyExePath = "$sysDrive\Chocolatey\bin",
[string]$chocolateyExePathVariable = "%$($chocInstallVariableName)%\bin"
)
$environmentTarget = [System.EnvironmentVariableTarget]::User
if (Test-ProcessAdminRights) {
Write-Debug "Administrator installing so using Machine environment variable target instead of User."
$environmentTarget = [System.EnvironmentVariableTarget]::Machine
}
Install-ChocolateyPath -pathToInstall "$chocolateyExePath" -pathType $environmentTarget
}
function Process-ChocolateyBinFiles {
param(
[string]$chocolateyExePath = "$($env:ALLUSERSPROFILE)\Chocolatey\bin",
[string]$chocolateyExePathVariable = "%$($chocInstallVariableName)%\bin"
)
$processedMarkerFile = Join-Path $chocolateyExePath '_processed.txt'
if (!(test-path $processedMarkerFile)) {
$files = get-childitem $chocolateyExePath -include *.bat -recurse
if ($files -ne $null -and $files.Count -gt 0) {
foreach ($file in $files) {
Write-Host "Processing $($file.Name) to make it portable"
$fileStream = [System.IO.File]::Open("$file", 'Open', 'Read', 'ReadWrite')
$reader = New-Object System.IO.StreamReader($fileStream)
$fileText = $reader.ReadToEnd()
$reader.Close()
$fileStream.Close()
$fileText = $fileText.ToLower().Replace("`"" + $chocolateyPath.ToLower(), "SET DIR=%~dp0%`n""%DIR%..\").Replace("\\","\")
Set-Content $file -Value $fileText -Encoding Ascii
}
}
Set-Content $processedMarkerFile -Value "$([System.DateTime]::Now.Date)" -Encoding Ascii
}
}
function Install-DotNet4IfMissing {
param(
[string]$chocolateyInstallPath
)
if([IntPtr]::Size -eq 8) {$fx="framework64"} else {$fx="framework"}
if(!(test-path "$env:windir\Microsoft.Net\$fx\v4.0.30319")) {
$NetFx4ClientUrl = 'http://download.microsoft.com/download/5/6/2/562A10F9-C9F4-4313-A044-9C94E0A8FAC8/dotNetFx40_Client_x86_x64.exe'
$NetFx4FullUrl = 'http://download.microsoft.com/download/9/5/A/95A9616B-7A37-4AF6-BC36-D6EA96C8DAAE/dotNetFx40_Full_x86_x64.exe'
Install-ChocolateyPackage "NetFx4.0" 'exe' -silentArgs "/q /norestart /repair /log `'$env:Temp\NetFx4Install.log`'" -url "$NetFx4ClientUrl" -url64bit "$NetFx4ClientUrl" -validExitCodes @(0, 3010)
}
}
Export-ModuleMember -function Initialize-Chocolatey;
param($installPath, $toolsPath, $package, $project)
$modules = Get-ChildItem $ToolsPath -Filter *.psm1
$modules | ForEach-Object { import-module -name $_.FullName }
@"
========================
Chocolatey
========================
Welcome to Chocolatey, your local machine repository built on the NuGet infrastructure. Chocolatey allows you to install application packages to your machine with the goodness of a #chocolatey #nuget combo.
Application executables get added to the path automatically so you can call them from anywhere (command line/powershell prompt), not just in Visual Studio.
Lets get Chocolatey!
----------
Visual Studio -
----------
Please run Initialize-Chocolatey one time per machine to set up the repository.
If you are upgrading, please remember to run Initialize-Chocolatey again.
After you have run Initiliaze-Chocolatey, you can safely uninstall the chocolatey package from your current Visual Studio solution.
----------
Alternative NuGet -
----------
If you are not using NuGet in Visual Studio, please navigate to the directory with the chocolateysetup.psm1 and run that in Powershell, followed by Initialize-Chocolatey.
Upgrade is the same, just run Initialize-Chocolatey again.
----------
Once you've run initialize or upgrade, you can uninstall this package from the local project without affecting your chocolatey repository.
========================
"@ | Write-Host
Log in or click on link to see number of positives.
- 7za.exe (c136b1467d66) - ## / 72
- checksum.exe (2115fe417587) - ## / 55
- NuGet.exe (a41fc507c9d6) - ## / 57
- chocolatey.0.9.8.29-alpha1.nupkg (978a6650c6c8) - ## / 57
- choco.exe (58a309867942) - ## / 55
- chocolatey.exe (f6b2032db030) - ## / 56
- cinst.exe (24a99812a92b) - ## / 55
- clist.exe (01197a2f3845) - ## / 56
- cpack.exe (a3fc414d9bf3) - ## / 56
- cpush.exe (b4a2ad46d7c7) - ## / 56
- cuninst.exe (ea1905c43a99) - ## / 56
- cup.exe (6243ff0dcbae) - ## / 56
- cver.exe (99ab0db7c70e) - ## / 56
- shimgen.exe (917d6b374cb7) - ## / 56
In cases where actual malware is found, the packages are subject to removal. Software sometimes has false positives. Moderators do not necessarily validate the safety of the underlying software, only that a package retrieves software from the official distribution point and/or validate embedded software against official distribution point (where distribution rights allow redistribution).
Chocolatey Pro provides runtime protection from possible malware.
Version | Downloads | Last Updated | Status |
---|---|---|---|
Chocolatey 2.4.1 | 2286456 | Wednesday, December 4, 2024 | Exempted |
Chocolatey 2.4.0 | 2424690 | Tuesday, November 12, 2024 | Approved |
Chocolatey 2.3.0 | 8988843 | Wednesday, June 5, 2024 | Approved |
Chocolatey 2.2.2 | 25330217 | Tuesday, August 8, 2023 | Approved |
Chocolatey 2.2.0 | 3347120 | Wednesday, July 26, 2023 | Exempted |
Chocolatey 2.1.0 | 6328513 | Thursday, June 29, 2023 | Exempted |
Chocolatey 2.1.0-alpha-20230614 | 2198 | Wednesday, June 14, 2023 | Exempted |
Chocolatey 2.1.0-alpha-20230608 | 999 | Thursday, June 8, 2023 | Exempted |
Chocolatey 2.0.0 | 9675565 | Wednesday, May 31, 2023 | Exempted |
Chocolatey 2.0.0-beta-20230426 | 4120 | Wednesday, April 26, 2023 | Exempted |
Chocolatey 2.0.0-beta-20230412 | 1751 | Wednesday, April 12, 2023 | Exempted |
Chocolatey 2.0.0-beta-20230321 | 2049 | Tuesday, March 21, 2023 | Exempted |
Chocolatey 2.0.0-alpha-20230307 | 1335 | Tuesday, March 7, 2023 | Exempted |
Chocolatey 2.0.0-alpha-20230221 | 1161 | Tuesday, February 21, 2023 | Exempted |
Chocolatey 2.0.0-alpha-20230124 | 1190 | Tuesday, January 24, 2023 | Exempted |
Chocolatey 1.4.1 | 39 | Wednesday, December 4, 2024 | Exempted |
Chocolatey 1.4.0 | 2809740 | Wednesday, May 10, 2023 | Exempted |
Chocolatey 1.3.1 | 5214512 | Tuesday, March 14, 2023 | Exempted |
Chocolatey 1.3.0 | 3246302 | Wednesday, February 15, 2023 | Exempted |
Chocolatey 1.2.1 | 6479208 | Tuesday, December 6, 2022 | Approved |
Chocolatey 1.2.0 | 1724727 | Wednesday, October 19, 2022 | Approved |
Chocolatey 1.1.0 | 8370914 | Wednesday, March 30, 2022 | Exempted |
Chocolatey 1.0.1 | 1055775 | Thursday, March 24, 2022 | Exempted |
Chocolatey 1.0.0 | 872791 | Monday, March 21, 2022 | Exempted |
Chocolatey 0.12.1 | 4191239 | Tuesday, January 25, 2022 | Exempted |
Chocolatey 0.12.0 | 1089174 | Tuesday, January 18, 2022 | Exempted |
Chocolatey 0.11.3 | 5643913 | Wednesday, October 27, 2021 | Exempted |
Chocolatey 0.11.2 | 6979568 | Thursday, September 23, 2021 | Exempted |
Chocolatey 0.11.1 | 3908017 | Thursday, September 2, 2021 | Exempted |
Chocolatey 0.10.16-beta-20200806 | 15152 | Thursday, August 6, 2020 | Approved |
Chocolatey 0.10.15 | 71782664 | Monday, June 3, 2019 | Approved |
Chocolatey 0.10.15-beta-20190531 | 1237 | Friday, May 31, 2019 | Approved |
Chocolatey 0.10.14 | 510588 | Thursday, May 30, 2019 | Approved |
Chocolatey 0.10.14-beta-20190418 | 5625 | Thursday, April 18, 2019 | Approved |
Chocolatey 0.10.14-beta-20190402 | 3089 | Tuesday, April 2, 2019 | Approved |
Chocolatey 0.10.14-beta-20190321 | 2616 | Friday, March 22, 2019 | Approved |
Chocolatey 0.10.13 | 7774259 | Friday, March 15, 2019 | Approved |
Chocolatey 0.10.12 | 152521 | Friday, March 15, 2019 | Approved |
Chocolatey 0.10.12-beta-20181011 | 15401 | Friday, October 12, 2018 | Approved |
Chocolatey 0.10.12-beta-20181009 | 945 | Tuesday, October 9, 2018 | Approved |
Chocolatey 0.10.11 | 29156050 | Friday, May 4, 2018 | Approved |
Chocolatey 0.10.10 | 2954436 | Thursday, April 12, 2018 | Approved |
Chocolatey 0.10.9 | 5427022 | Sunday, March 25, 2018 | Approved |
Chocolatey 0.10.9-beta-20180223 | 3795 | Friday, February 23, 2018 | Approved |
Chocolatey 0.10.8 | 24667003 | Wednesday, August 30, 2017 | Approved |
Chocolatey 0.10.8-beta-20170806 | 5290 | Monday, August 7, 2017 | Approved |
Chocolatey 0.10.7 | 18322144 | Thursday, June 8, 2017 | Approved |
Chocolatey 0.10.6.1 | 847886 | Saturday, June 3, 2017 | Approved |
Chocolatey 0.10.6 | 413356 | Thursday, June 1, 2017 | Approved |
Chocolatey 0.10.6-beta-20170531 | 1062 | Thursday, June 1, 2017 | Approved |
Chocolatey 0.10.6-beta-20170503 | 8283 | Wednesday, May 3, 2017 | Approved |
Chocolatey 0.10.5 | 18050513 | Thursday, March 30, 2017 | Approved |
Chocolatey 0.10.4 | 174335 | Thursday, March 30, 2017 | Approved |
Chocolatey 0.10.4-beta1-20170326 | 939 | Sunday, March 26, 2017 | Approved |
Chocolatey 0.10.4-beta1-20170323 | 792 | Thursday, March 23, 2017 | Approved |
Chocolatey 0.10.3 | 25541814 | Friday, October 7, 2016 | Approved |
Chocolatey 0.10.2 | 686085 | Friday, September 30, 2016 | Approved |
Chocolatey 0.10.1 | 2005661 | Monday, September 19, 2016 | Approved |
Chocolatey 0.10.0 | 3815932 | Thursday, August 11, 2016 | Approved |
Chocolatey 0.9.10.3 | 1920556 | Thursday, June 23, 2016 | Approved |
Chocolatey 0.9.10.2 | 3042 | Sunday, June 19, 2016 | Approved |
Chocolatey 0.9.10.1 | 968 | Saturday, June 18, 2016 | Approved |
Chocolatey 0.9.10 | 2436 | Friday, June 17, 2016 | Approved |
Chocolatey 0.9.10-rc1 | 717 | Monday, June 13, 2016 | Approved |
Chocolatey 0.9.10-beta-20160612 | 691 | Sunday, June 12, 2016 | Approved |
Chocolatey 0.9.10-beta-20160531 | 678 | Tuesday, May 31, 2016 | Approved |
Chocolatey 0.9.10-beta-20160528 | 642 | Saturday, May 28, 2016 | Approved |
Chocolatey 0.9.10-beta-20160527 | 721 | Friday, May 27, 2016 | Approved |
Chocolatey 0.9.10-beta-20160524 | 690 | Wednesday, May 25, 2016 | Approved |
Chocolatey 0.9.10-beta-20160509 | 795 | Monday, May 9, 2016 | Approved |
Chocolatey 0.9.10-beta-20160506 | 694 | Friday, May 6, 2016 | Approved |
Chocolatey 0.9.10-beta-20160505 | 647 | Thursday, May 5, 2016 | Approved |
Chocolatey 0.9.10-beta-20160503 | 679 | Tuesday, May 3, 2016 | Approved |
Chocolatey 0.9.10-beta-20160422 | 1057 | Friday, April 22, 2016 | Approved |
Chocolatey 0.9.10-beta-20160411 | 1213 | Monday, April 11, 2016 | Approved |
Chocolatey 0.9.10-beta-20160402 | 1126 | Saturday, April 2, 2016 | Approved |
Chocolatey 0.9.10-beta-20160330 | 693 | Thursday, March 31, 2016 | Exempted |
Chocolatey 0.9.10-beta-20160328 | 829 | Tuesday, March 29, 2016 | Approved |
Chocolatey 0.9.10-beta-20160325 | 855 | Friday, March 25, 2016 | Approved |
Chocolatey 0.9.10-beta-20160323 | 892 | Wednesday, March 23, 2016 | Approved |
Chocolatey 0.9.10-beta-20160322 | 658 | Wednesday, March 23, 2016 | Approved |
Chocolatey 0.9.10-beta-20160320 | 866 | Sunday, March 20, 2016 | Approved |
Chocolatey 0.9.10-beta-20160318 | 754 | Friday, March 18, 2016 | Approved |
Chocolatey 0.9.10-beta-20160314 | 898 | Monday, March 14, 2016 | Approved |
Chocolatey 0.9.10-beta-20160311 | 844 | Friday, March 11, 2016 | Approved |
Chocolatey 0.9.10-beta-20160302 | 1037 | Wednesday, March 2, 2016 | Approved |
Chocolatey 0.9.10-beta-20160215 | 1179 | Monday, February 15, 2016 | Approved |
Chocolatey 0.9.10-beta-20160212 | 984 | Friday, February 12, 2016 | Approved |
Chocolatey 0.9.10-beta-20160205 | 1086 | Friday, February 5, 2016 | Approved |
Chocolatey 0.9.9.12 | 387288 | Friday, March 18, 2016 | Approved |
Chocolatey 0.9.9.11 | 8574145 | Tuesday, October 6, 2015 | Approved |
Chocolatey 0.9.9.10 | 382235 | Saturday, October 3, 2015 | Approved |
Chocolatey 0.9.9.9 | 1252757 | Friday, October 2, 2015 | Approved |
Chocolatey 0.9.9.8 | 5627979 | Saturday, June 27, 2015 | Approved |
Chocolatey 0.9.9.7 | 194957 | Saturday, June 20, 2015 | Approved |
Chocolatey 0.9.9.6 | 831228 | Sunday, May 17, 2015 | Approved |
Chocolatey 0.9.9.5 | 547002 | Monday, April 20, 2015 | Approved |
Chocolatey 0.9.9.4 | 515994 | Monday, March 30, 2015 | Approved |
Chocolatey 0.9.9.3 | 3587 | Sunday, March 29, 2015 | Approved |
Chocolatey 0.9.9.2 | 25839 | Saturday, March 7, 2015 | Approved |
Chocolatey 0.9.9.1 | 8561 | Tuesday, March 3, 2015 | Approved |
Chocolatey 0.9.9 | 14653 | Tuesday, March 3, 2015 | Approved |
Chocolatey 0.9.9-rc9 | 882 | Saturday, February 28, 2015 | Approved |
Chocolatey 0.9.9-rc8 | 931 | Tuesday, February 24, 2015 | Approved |
Chocolatey 0.9.9-rc5 | 1113 | Monday, February 9, 2015 | Approved |
Chocolatey 0.9.9-rc4 | 789 | Sunday, February 8, 2015 | Approved |
Chocolatey 0.9.9-rc3 | 766 | Saturday, February 7, 2015 | Approved |
Chocolatey 0.9.9-rc2 | 732 | Friday, February 6, 2015 | Approved |
Chocolatey 0.9.9-rc1 | 758 | Wednesday, February 4, 2015 | Approved |
Chocolatey 0.9.9-beta3-20150204 | 709 | Wednesday, February 4, 2015 | Approved |
Chocolatey 0.9.9-beta2-20150202 | 772 | Monday, February 2, 2015 | Approved |
Chocolatey 0.9.9-beta-20150201 | 741 | Sunday, February 1, 2015 | Approved |
Chocolatey 0.9.9-alpha-20150201 | 744 | Sunday, February 1, 2015 | Approved |
Chocolatey 0.9.9-alpha-20150125 | 947 | Sunday, January 25, 2015 | Approved |
Chocolatey 0.9.8.33 | 1795261 | Wednesday, February 11, 2015 | Approved |
Chocolatey 0.9.8.32 | 263395 | Thursday, January 22, 2015 | Approved |
Chocolatey 0.9.8.31 | 190580 | Wednesday, January 7, 2015 | Approved |
Chocolatey 0.9.8.31-beta2 | 763 | Wednesday, January 7, 2015 | Approved |
Chocolatey 0.9.8.31-beta1 | 685 | Tuesday, January 6, 2015 | Approved |
Chocolatey 0.9.8.30-beta1 | 670 | Tuesday, January 6, 2015 | Approved |
Chocolatey 0.9.8.29 | 57047 | Friday, January 2, 2015 | Approved |
Chocolatey 0.9.8.29-beta2 | 685 | Friday, January 2, 2015 | Exempted |
Chocolatey 0.9.8.29-beta1 | 684 | Friday, January 2, 2015 | Exempted |
Chocolatey 0.9.8.29-alpha1 | 727 | Friday, January 2, 2015 | Exempted |
Chocolatey 0.9.8.28 | 812271 | Tuesday, November 4, 2014 | Approved |
Chocolatey 0.9.8.28-rc1 | 691 | Sunday, November 2, 2014 | Exempted |
Chocolatey 0.9.8.28-alpha3 | 1239 | Monday, October 6, 2014 | Approved |
Chocolatey 0.9.8.28-alpha2 | 1543 | Friday, August 1, 2014 | Approved |
Chocolatey 0.9.8.28-alpha1 | 773 | Wednesday, July 30, 2014 | Approved |
Chocolatey 0.9.8.27 | 1382148 | Monday, July 14, 2014 | Approved |
Chocolatey 0.9.8.27-beta1 | 705 | Sunday, July 13, 2014 | Approved |
Chocolatey 0.9.8.26 | 995 | Saturday, July 12, 2014 | Approved |
Chocolatey 0.9.8.26-alpha2 | 752 | Friday, July 11, 2014 | Approved |
Chocolatey 0.9.8.26-alpha1 | 769 | Friday, July 11, 2014 | Approved |
Chocolatey 0.9.8.25 | 39041 | Monday, July 7, 2014 | Approved |
Chocolatey 0.9.8.25-alpha1 | 788 | Saturday, July 5, 2014 | Approved |
Chocolatey 0.9.8.24 | 14032 | Thursday, July 3, 2014 | Approved |
Chocolatey 0.9.8.24-rc2 | 772 | Monday, June 30, 2014 | Approved |
Chocolatey 0.9.8.24-rc1 | 805 | Wednesday, June 25, 2014 | Approved |
Chocolatey 0.9.8.24-beta2 | 939 | Sunday, June 8, 2014 | Approved |
Chocolatey 0.9.8.24-beta1 | 1583 | Thursday, April 3, 2014 | Approved |
Chocolatey 0.9.8.24-alpha2 | 1017 | Sunday, March 2, 2014 | Approved |
Chocolatey 0.9.8.24-alpha1 | 874 | Tuesday, February 11, 2014 | Approved |
Chocolatey 0.9.8.23 | 525902 | Monday, November 11, 2013 | Approved |
Chocolatey 0.9.8.22 | 1505 | Monday, November 11, 2013 | Approved |
Chocolatey 0.9.8.22-alpha1 | 773 | Saturday, November 9, 2013 | Approved |
Chocolatey 0.9.8.21 | 4409 | Friday, November 8, 2013 | Approved |
Chocolatey 0.9.8.21-beta2 | 753 | Friday, November 8, 2013 | Approved |
Chocolatey 0.9.8.21-alpha7 | 1055 | Friday, August 23, 2013 | Approved |
Chocolatey 0.9.8.21-alpha6 | 751 | Thursday, August 22, 2013 | Approved |
Chocolatey 0.9.8.21-alpha5 | 734 | Wednesday, August 21, 2013 | Approved |
Chocolatey 0.9.8.21-alpha4 | 718 | Wednesday, August 21, 2013 | Approved |
Chocolatey 0.9.8.21-alpha3 | 894 | Tuesday, July 23, 2013 | Approved |
Chocolatey 0.9.8.21-alpha2 | 873 | Thursday, June 27, 2013 | Approved |
Chocolatey 0.9.8.21-alpha1 | 887 | Thursday, May 30, 2013 | Approved |
Chocolatey 0.9.8.20 | 331619 | Tuesday, December 11, 2012 | Approved |
Chocolatey 0.9.8.20-beta1 | 833 | Wednesday, December 5, 2012 | Approved |
Chocolatey 0.9.8.20-alpha3 | 847 | Friday, November 16, 2012 | Approved |
Chocolatey 0.9.8.20-alpha2 | 807 | Tuesday, October 16, 2012 | Approved |
Chocolatey 0.9.8.20-alpha1 | 846 | Sunday, September 16, 2012 | Approved |
Chocolatey 0.9.8.19 | 29999 | Monday, July 2, 2012 | Approved |
Chocolatey 0.9.8.19-alpha1 | 791 | Thursday, June 28, 2012 | Approved |
Chocolatey 0.9.8.18 | 2260 | Saturday, June 16, 2012 | Approved |
Chocolatey 0.9.8.17 | 1141 | Friday, June 15, 2012 | Approved |
Chocolatey 0.9.8.17-rc2 | 950 | Wednesday, June 13, 2012 | Approved |
Chocolatey 0.9.8.17-rc1 | 950 | Wednesday, June 13, 2012 | Approved |
Chocolatey 0.9.8.17-beta1 | 927 | Thursday, June 7, 2012 | Approved |
Chocolatey 0.9.8.16 | 7405 | Monday, February 27, 2012 | Approved |
Chocolatey 0.9.8.15 | 984 | Monday, February 27, 2012 | Approved |
Chocolatey 0.9.8.15-beta2 | 993 | Saturday, February 25, 2012 | Approved |
Chocolatey 0.9.8.14 | 2378 | Monday, February 6, 2012 | Approved |
Chocolatey 0.9.8.13 | 1936 | Sunday, January 8, 2012 | Approved |
Chocolatey 0.9.8.12 | 2100 | Sunday, November 20, 2011 | Approved |
Chocolatey 0.9.8.11 | 1948 | Friday, October 14, 2011 | Approved |
Chocolatey 0.9.8.10 | 1802 | Saturday, September 17, 2011 | Approved |
Chocolatey 0.9.8.9 | 1060 | Saturday, September 10, 2011 | Approved |
Chocolatey 0.9.8.8 | 918 | Saturday, September 10, 2011 | Approved |
Chocolatey 0.9.8.7 | 977 | Friday, September 2, 2011 | Approved |
Chocolatey 0.9.8.6 | 1814 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.8.5 | 964 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.8.4 | 1120 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.8.3 | 972 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.8.2 | 1174 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.8.1 | 972 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.8 | 4065 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.7.3 | 1043 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.7.2 | 1011 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.7.1 | 1001 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.7 | 1023 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.6.4 | 970 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.6.3 | 960 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.6.2 | 993 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.6.1 | 1013 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.6.0 | 987 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.5.0 | 1039 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.4.0 | 1066 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.3.0 | 1008 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.2.0 | 987 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.1.0 | 1044 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.0.0 | 997 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.8.0.0 | 1069 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.7.0.0 | 1395 | Tuesday, August 23, 2011 | Approved |
RealDimensions Software, LLC - 2011-Present
See all - https://github.com/chocolatey/chocolatey/blob/master/CHANGELOG.md
0.9.8.29:
FEATURES:
- Use icon of the executable with generated shim - https://github.com/chocolatey/chocolatey/issues/579
IMPROVEMENTS:
- Remove Kickstarter message.
0.9.8.28:
BREAKING CHANGES:
- You may need to update your saved API key for chocolatey, due to https://github.com/chocolatey/chocolatey/issues/599 we have switched push to ensure https.
BUG FIXES:
- Fix - Shim argument parsing needs fixed for quoting - https://github.com/chocolatey/shimgen/issues/1
- Fix - Forcing x86 does not use 32bit checksum - https://github.com/chocolatey/chocolatey/issues/535
- Fix - Powershell v2 fails to download SSLv3 files - https://github.com/chocolatey/chocolatey/issues/531
- Fix - Get-ChocolateyUnzip fails due to Wait-Process exception - https://github.com/chocolatey/chocolatey/issues/571
IMPROVEMENTS:
- Use default credentials for internet if available - https://github.com/chocolatey/chocolatey/issues/577
- Add moderation message on push - https://github.com/chocolatey/chocolatey/issues/600
- Restrict all calls to chocolatey.org to HTTPS - https://github.com/chocolatey/chocolatey/issues/599
- Batch fallback should quote path for spaces - https://github.com/chocolatey/chocolatey/issues/558
0.9.8.27:
BUG FIXES:
- Fix - Posh v3+ Ignores -Wait when run from cmd.exe - https://github.com/chocolatey/chocolatey/pull/516
0.9.8.26:
BUG FIXES:
- Fix - Allow spaces in arguments to chocolatey again - Regenerate chocolatey included shims to take advantage of shimgen fixes - https://github.com/chocolatey/chocolatey/issues/507
- Fix - Default path has changed, causing running without closing shell to have issues again - https://github.com/chocolatey/chocolatey/issues/510
- Fix - Working directory of shimgen generated files points to path target executable is in (GUI apps only) - https://github.com/chocolatey/chocolatey/issues/508
- Fix - cpack/cpush returns zero exit code even when error occurs - https://github.com/chocolatey/chocolatey/issues/256 and https://github.com/chocolatey/chocolatey/issues/384
- Fix - Install error throws another error due to true instead of $true - https://github.com/chocolatey/chocolatey/pull/514
- Fix - Posh v3+ Ignores -Wait when run from cmd.exe - https://github.com/chocolatey/chocolatey/pull/516
IMPROVEMENTS:
- Allow to pass shimgen specific parameters - https://github.com/chocolatey/chocolatey/issues/509
- Issue warning if user is not running an elevated shell - https://github.com/chocolatey/chocolatey/issues/519
0.9.8.25:
BUG FIXES:
- Fix - Shims that require admin may fail on UAC enforced machines (System.ComponentModel.Win32Exception: The requested operation requires elevation) - https://github.com/chocolatey/chocolatey/issues/505
- Fix - Do not check content-length if there isn't a content-length returned from Get-WebHeaders - https://github.com/chocolatey/chocolatey/issues/504
v0.9.8.24:
BREAKING CHANGES:
- Enhancement - Default install to C:\ProgramData - https://github.com/chocolatey/chocolatey/issues/452 and https://github.com/chocolatey/chocolatey/issues/494
- Don't allow $binroot to be set to c:\ - https://github.com/chocolatey/chocolatey/issues/434 - this is meant to be temporary while other pieces are fixed.
FEATURES:
- Checksum downloaded files - https://github.com/chocolatey/chocolatey/issues/427
- Replace Batch Redirector with Shims - https://github.com/chocolatey/chocolatey/issues/372
- New Helper - Get-UACEnabled - https://github.com/chocolatey/chocolatey/issues/451
- Enhancement - Install to Machine environment variable - https://github.com/chocolatey/chocolatey/issues/453
- Enhancement - Install the .NET Framework 4.0 requirement - https://github.com/chocolatey/chocolatey/issues/255
- Update environment using command (RefreshEnv) - https://github.com/chocolatey/chocolatey/issues/134
-quiet
parameter that silences almost all output / allow shutting off real write-host - https://github.com/chocolatey/chocolatey/pull/416 and https://github.com/chocolatey/chocolatey/issues/411- New Helpers - Test-ProcessAdminRights, Get-EnvironmentVariableNames, Get-EnvironmentVariable, Set-EnvironmentVariable - https://github.com/chocolatey/chocolatey/pull/486
BUG FIXES:
- Fix - Cannot bind argument to parameter 'Path' because it is an empty string - https://github.com/chocolatey/chocolatey/issues/371
- Fix - clist -source webpi doesn't prompt for admin access - https://github.com/chocolatey/chocolatey/issues/293
- Fix - Get-ChocolateyUnzip silently fails due to incorrect usage of System32 (File System Redirector Issues) - https://github.com/chocolatey/chocolatey/pull/476 and https://github.com/chocolatey/chocolatey/issues/455
- Fix - 7za.exe is subject to UAC file virtualization - https://github.com/chocolatey/chocolatey/issues/454
- Fix - "You cannot call a method on a null-valued expression" introduced somewhere. - https://github.com/chocolatey/chocolatey/issues/430
- Fix - Get-BinRoot defaulted to "C:" instead of "C:\tools" - https://github.com/chocolatey/chocolatey/pull/421
- Fix - Get-ProcessorBits doesn't return the bitness of the OperatingSystem - https://github.com/chocolatey/chocolatey/pull/396
- Fix - Fix Invoke for Install All from a Feed (DEPRECATED by #446 - in improvements below) - https://github.com/chocolatey/chocolatey/issues/381
- Fix - Upgrade to 0.9.8.24 produces cannot find Update-SessionEnvironment when using cmd.exe - https://github.com/chocolatey/chocolatey/issues/459
- Fix - Package depending on newer chocolatey version is installed using existing version of chocolatey - https://github.com/chocolatey/chocolatey/issues/460
- Fix - Bash improvements - https://github.com/chocolatey/chocolatey/pull/383
- Fix - Resolve issue with DISM "missing" or with the 32-bit DISM being called on a 64-bit system - https://github.com/chocolatey/chocolatey/pull/393
- Fix - Do NOT throw if missing a chocolateyuninstall.ps1 - https://github.com/chocolatey/chocolatey/issues/499
IMPROVEMENTS:
- Do not download if file already cached - https://github.com/chocolatey/chocolatey/issues/428 and https://github.com/chocolatey/chocolatey/pull/109
- If *.ignore file failes to create, do not fail the process - https://github.com/chocolatey/chocolatey/issues/380
- Validate downloaded file is the right size - https://github.com/chocolatey/chocolatey/issues/429
- Add perf to Chocolatey-List and allow to return as object - https://github.com/chocolatey/chocolatey/issues/426
- Chocolatey-List LocalOnly performance improvements - https://github.com/chocolatey/chocolatey/pull/425
- Chocolatey-Version Improvements - https://github.com/chocolatey/chocolatey/issues/445
- Remove Invoke-Chocolatey Function to improve handling - https://github.com/chocolatey/chocolatey/issues/446
- Don't create a window during Run-Nuget.ps1 - https://github.com/chocolatey/chocolatey/pull/450
- Generate _env.cmd file instead of bat file for consistency - https://github.com/chocolatey/chocolatey/pull/469
- Remove-BinFile removes shim.exes when installing a package - https://github.com/chocolatey/chocolatey/pull/449
- Remove annoying "Reading environment variables from registry. Please wait..." - https://github.com/chocolatey/chocolatey/pull/440
- Replace ascii cue to visual cue for "installing package" - https://github.com/chocolatey/chocolatey/pull/376
- Clean up the verbosity of chocolatey - https://github.com/chocolatey/chocolatey/issues/374
- Improve chocolatey setup as administrator - https://github.com/chocolatey/chocolatey/pull/486
- Simplify Chocolatey-Update - https://github.com/chocolatey/chocolatey/issues/493
- Update to Nuget.exe 2.8.2 - https://github.com/chocolatey/chocolatey/issues/379
This package has no dependencies.
Ground Rules:
- This discussion is only about Chocolatey and the Chocolatey package. If you have feedback for Chocolatey, please contact the Google Group.
- This discussion will carry over multiple versions. If you have a comment about a particular version, please note that in your comments.
- The maintainers of this Chocolatey Package will be notified about new comments that are posted to this Disqus thread, however, it is NOT a guarantee that you will get a response. If you do not hear back from the maintainers after posting a message below, please follow up by using the link on the left side of this page or follow this link to contact maintainers. If you still hear nothing back, please follow the package triage process.
- Tell us what you love about the package or Chocolatey, or tell us what needs improvement.
- Share your experiences with the package, or extra configuration or gotchas that you've found.
- If you use a url, the comment will be flagged for moderation until you've been whitelisted. Disqus moderated comments are approved on a weekly schedule if not sooner. It could take between 1-5 days for your comment to show up.