Downloads:
346,065,373
Downloads of v 0.9.10-beta-20160302:
1,032
Last Update:
02 Mar 2016
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.10-beta-20160302 | Updated: 02 Mar 2016
- Software Specific:
- Software Site
- Software License
- Package Specific:
- Package outdated?
- Package broken?
- Contact Maintainers
- Contact Site Admins
- Software Vendor?
- Report Abuse
- Download
Downloads:
346,065,373
Downloads of v 0.9.10-beta-20160302:
1,032
Maintainer(s):
Software Author(s):
- Rob Reynolds
- The Chocolatey Team
Chocolatey 0.9.10-beta-20160302
This is a prerelease version of Chocolatey.
- 1
- 2
- 3
Some Checks Have Failed or Are Not Yet Complete
Not All Tests Have Passed
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 was approved as a trusted package on 02 Mar 2016.
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, with 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. Here are the most common:
- Help - choco -? or choco command -?
- Search - choco search something
- List - choco list -lo
- Config - choco config list
- Install - choco install baretail
- Pin - choco pin windirstat
- Outdated - choco outdated
- Upgrade - choco upgrade baretail
- Uninstall - choco uninstall baretail
Alternative installation sources:
- 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
For more advanced commands and switches, use choco -?
or choco command -h
. You can also look at 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! Wiki!
In that mess there is a link to the Helper Reference.
md5: BD99BBC30901512FC33BE1A7DE4384D6 | sha1: 4FE571355223E89654BF9D6E5D1CFE51761774B6 | sha256: 2C8B25127820C32BE1D4DDD6A4F31B11BD4EA1D1A3BBF8996235A6D43F891DB6 | sha512: 454E3D7E656BC669502C338B14244ADCCCE62BE134D6E82DBD3FC5D01FE05E2646FE0A3EDBD6C7789BC597FCCDF676919A575123F687686BE4A8542AF15E9F98
param(
[alias("ia","installArgs")][string] $installArguments = '',
[alias("o","override","overrideArguments","notSilent")]
[switch] $overrideArgs = $false,
[alias("x86")][switch] $forceX86 = $false,
[alias("params")][alias("parameters")][alias("pkgParams")][string]$packageParameters = '',
[string]$packageScript
)
$global:DebugPreference = "SilentlyContinue"
if ($env:ChocolateyEnvironmentDebug -eq 'true') { $global:DebugPreference = "Continue"; }
$global:VerbosePreference = "SilentlyContinue"
if ($env:ChocolateyEnvironmentVerbose -eq 'true') { $global:VerbosePreference = "Continue"; $verbosity = $true }
Write-Debug "Running 'ChocolateyScriptRunner' for $($env:packageName) v$($env:packageVersion) with packageScript `'$packageScript`', packageFolder:`'$($env:packageFolder)`', installArguments: `'$installArguments`', packageParameters: `'$packageParameters`',"
## Set the culture to invariant
$currentThread = [System.Threading.Thread]::CurrentThread;
$culture = [System.Globalization.CultureInfo]::InvariantCulture;
$currentThread.CurrentCulture = $culture;
$currentThread.CurrentUICulture = $culture;
$RunNote = "DarkCyan"
$Warning = "Magenta"
$ErrorColor = "Red"
$Note = "Green"
$version = $env:packageVersion
$packageName = $env:packageName
$packageVersion = $env:packageVersion
$packageFolder = $env:packageFolder
$helpersPath = (Split-Path -parent $MyInvocation.MyCommand.Definition);
$nugetChocolateyPath = (Split-Path -parent $helpersPath)
$nugetPath = $nugetChocolateyPath
$nugetExePath = Join-Path $nuGetPath 'bin'
$nugetLibPath = Join-Path $nuGetPath 'lib'
$badLibPath = Join-Path $nuGetPath 'lib-bad'
$extensionsPath = Join-Path $nugetPath 'extensions'
$chocInstallVariableName = "ChocolateyInstall"
$chocoTools = Join-Path $nuGetPath 'tools'
$nugetExe = Join-Path $chocoTools 'nuget.exe'
$7zip = Join-Path $chocoTools '7za.exe'
$ShimGen = Join-Path $chocoTools 'shimgen.exe'
$checksumExe = Join-Path $chocoTools 'checksum.exe'
Write-Debug "Running `'$packageScript`'";
& "$packageScript"
# Copyright © 2011 - Present 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.
Function Format-FileSize() {
Param ([double]$size)
Foreach ($unit in @('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB')) {
If ($size -lt 1024) {
return [string]::Format("{0:0.##} {1}", $size, $unit)
}
$size /= 1024
}
return [string]::Format("{0:0.##} YB", $size)
}
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
# 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.
function Get-ChecksumValid {
param(
[string] $file,
[string] $checksum = '',
[string] $checksumType = 'md5'
)
Write-Debug "Running 'Get-ChecksumValid' with file:`'$file`', checksum: `'$checksum`', checksumType: `'$checksumType`'";
if ($env:chocolateyIgnoreChecksums -eq 'true') {
Write-Warning "Ignoring checksums due to feature checksumFiles = false or config ignoreChecksums = true."
return
}
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' -and $checksumType -ne 'sha256' -and $checksumType -ne 'sha512' -and $checksumType -ne 'md5') {
Write-Debug 'Setting checksumType to md5 due to non-set value or type is not specified correctly.'
$checksumType = 'md5'
}
$checksumExe = Join-Path "$helpersPath" '..\tools\checksum.exe'
if (!([System.IO.File]::Exists($checksumExe))) {
Update-SessionEnvironment
$checksumExe = Join-Path "$env:ChocolateyInstall" 'tools\checksum.exe'
}
Write-Debug "checksum.exe found at `'$checksumExe`'"
$params = "-c=`"$checksum`" -t=`"$checksumType`" -f=`"$file`""
Write-Debug "Executing command ['$checksumExe' $params]"
$process = New-Object System.Diagnostics.Process
$process.StartInfo = New-Object System.Diagnostics.ProcessStartInfo($checksumExe, $params)
$process.StartInfo.UseShellExecute = $false
$process.StartInfo.WindowStyle = [System.Diagnostics.ProcessWindowStyle]::Hidden
$process.Start() | Out-Null
$process.WaitForExit()
$exitCode = $process.ExitCode
$process.Dispose()
Write-Debug "Command [`'$checksumExe`' $params] exited with `'$exitCode`'."
if ($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`'."
# }
}
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
# 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.
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)}
$7zip = Join-Path "$helpersPath" '..\tools\7za.exe'
if (!([System.IO.File]::Exists($7zip))) {
Update-SessionEnvironment
$7zip = Join-Path "$env:ChocolateyInstall" 'tools\7za.exe'
}
$7zip = [System.IO.Path]::GetFullPath($7zip)
Write-Debug "7zip found at `'$7zip`'"
# 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
}
$params = "x -aoa -o`"$destination`" -y `"$fileFullPath`""
Write-Debug "Executing command ['$7zip' $params]"
# Capture 7z's output into a StringBuilder and write it out in blocks, to improve I/O performance.
$global:zipFileList = New-Object System.Text.StringBuilder
$global:zipDestinationFolder = $destination
# Redirecting output slows things down a bit.
$writeOutput = {
if ($EventArgs.Data -ne $null) {
$line = $EventArgs.Data
Write-Verbose "$line"
if ($line.StartsWith("Extracting")) {
$global:zipFileList.AppendLine($global:zipDestinationFolder + "\" + $line.Substring(12))
}
}
}
$writeError = {
if ($EventArgs.Data -ne $null) {
Write-Error "$($EventArgs.Data)"
}
}
$process = New-Object System.Diagnostics.Process
$process.EnableRaisingEvents = $true
Register-ObjectEvent -InputObject $process -SourceIdentifier "LogOutput_ChocolateyZipProc" -EventName OutputDataReceived -Action $writeOutput | Out-Null
Register-ObjectEvent -InputObject $process -SourceIdentifier "LogErrors_ChocolateyZipProc" -EventName ErrorDataReceived -Action $writeError | Out-Null
$process.StartInfo = new-object System.Diagnostics.ProcessStartInfo($7zip, $params)
$process.StartInfo.RedirectStandardOutput = $true
$process.StartInfo.RedirectStandardError = $true
$process.StartInfo.UseShellExecute = $false
$process.StartInfo.WorkingDirectory = Get-Location
$process.StartInfo.WindowStyle = [System.Diagnostics.ProcessWindowStyle]::Hidden
[void] $process.Start()
if ($process.StartInfo.RedirectStandardOutput) { $process.BeginOutputReadLine() }
if ($process.StartInfo.RedirectStandardError) { $process.BeginErrorReadLine() }
$process.WaitForExit()
# 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_ChocolateyZipProc"
Unregister-Event -SourceIdentifier "LogErrors_ChocolateyZipProc"
$exitCode = $process.ExitCode
$process.Dispose()
Write-Debug "Command ['$7zip' $params] exited with `'$exitCode`'."
if ($zipExtractLogFullPath) {
Set-Content $zipExtractLogFullPath $global:zipFileList.ToString() -Encoding UTF8 -Force
}
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
}
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
# 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.
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', 'sha1', 'sha256' or 'sha512' - defaults to 'md5'
.PARAMETER ChecksumType64
OPTIONAL (Right now) - 'md5', 'sha1', 'sha256' or 'sha512' - defaults to ChecksumType
.PARAMETER options
OPTIONAL - Specify custom headers
Example:
--------
$options =
@{
Headers = @{
Accept = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
'Accept-Charset' = 'ISO-8859-1,utf-8;q=0.7,*;q=0.3';
'Accept-Language' = 'en-GB,en-US;q=0.8,en;q=0.6';
Cookie = 'requiredinfo=info';
Referer = 'https://somelocation.com/';
}
}
Get-ChocolateyWebFile 'package' 'https://somelocation.com/thefile.exe' -options $options
.PARAMETER GetOriginalFileName
OPTIONAL switch to allow Chocolatey to determine the original file name from the url
.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,
[hashtable] $options = @{Headers=@{}},
[switch]$getOriginalFileName
)
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 = ''
if ($url32bit -ne $url64bit -and $url64bit -ne $null -and $url64bit -ne '') { $bitPackage = '32 bit' }
if ($bitWidth -eq 64 -and $url64bit -ne $null -and $url64bit -ne '') {
Write-Debug "Setting url to '$url64bit' and bitPackage to $bitWidth"
$bitPackage = '64 bit'
$url = $url64bit;
# only set if urls are different
if ($url32bit -ne $url64bit) {
$checksum = $checksum64
if ($checkSumType64 -ne '') {
$checksumType = $checksumType64
}
}
}
$forceX86 = $env:chocolateyForceX86;
if ($forceX86) {
Write-Debug "User specified -x86 so forcing 32 bit"
if ($url32bit -ne $url64bit) { $bitPackage = '32 bit' }
$url = $url32bit
$checksum = $checksum32
$checksumType = $checksumType32
}
if ($getOriginalFileName) {
try {
$fileDirectory = [System.IO.Path]::GetDirectoryName($fileFullPath)
$originalFileName = [System.IO.Path]::GetFileName($fileFullPath)
$fileFullPath = Get-FileName -url $url -defaultName $originalFileName
$fileFullPath = Join-Path $fileDirectory $fileFullPath
$fileFullPath = [System.IO.Path]::GetFullPath($fileFullPath)
} catch {
Write-Host "Attempt to use original download file name failed for '$url'."
}
}
try {
$fileDirectory = $([System.IO.Path]::GetDirectoryName($fileFullPath))
if (!(Test-Path($fileDirectory))) {
[System.IO.Directory]::CreateDirectory($fileDirectory) | Out-Null
}
} catch {
Write-Host "Attempt to create directory failed for '$fileFullPath'."
}
$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
from `'$url`'"
Get-WebFile $url $fileFullPath -options $options
}
} 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." }
Get-VirusCheckValid -location $url -file $fileFullPath
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
return $fileFullPath
}
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
# 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.
function Get-EnvironmentVariable([string] $Name, [System.EnvironmentVariableTarget] $Scope) {
[Environment]::GetEnvironmentVariable($Name, $Scope)
}
# Some enhancements to think about here.
# $machinePath = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey("SYSTEM\CurrentControlSet\Control\Session Manager\Environment\").GetValue("PATH", "", [Microsoft.Win32.RegistryValueOptions]::DoNotExpandEnvironmentNames).ToString();
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
# 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.
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" }
}
}
# Copyright 2011 - Present 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.
#
# Based on http://stackoverflow.com/a/13571471/18475
function Get-FileName {
param(
[string]$url = '',
[string]$defaultName,
$userAgent = 'chocolatey command line'
)
Write-Debug "Running 'Get-FileName' to determine name with url:'$url', defaultName:'$defaultName'";
$originalFileName = $defaultName
$fileName = $null
$request = [System.Net.HttpWebRequest]::Create($url)
if ($request -eq $null) {
$request.Close()
return $originalFileName
}
$defaultCreds = [System.Net.CredentialCache]::DefaultCredentials
if ($defaultCreds -ne $null) {
$request.Credentials = $defaultCreds
}
$client = New-Object System.Net.WebClient
if ($defaultCreds -ne $null) {
$client.Credentials = $defaultCreds
}
# check if a proxy is required
$explicitProxy = $env:chocolateyProxyLocation
$explicitProxyUser = $env:chocolateyProxyUser
$explicitProxyPassword = $env:chocolateyProxyPassword
if ($explicitProxy -ne $null) {
# explicit proxy
$proxy = New-Object System.Net.WebProxy($explicitProxy, $true)
if ($explicitProxyPassword -ne $null) {
$passwd = ConvertTo-SecureString $explicitProxyPassword -AsPlainText -Force
$proxy.Credentials = New-Object System.Management.Automation.PSCredential ($explicitProxyUser, $passwd)
}
Write-Debug "Using explicit proxy server '$explicitProxy'."
$request.Proxy = $proxy
} elseif (!$client.Proxy.IsBypassed($url))
{
# system proxy (pass through)
$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-Debug "Using system proxy server '$proxyaddress'."
$proxy = New-Object System.Net.WebProxy($proxyAddress)
$proxy.Credentials = $creds
$request.Proxy = $proxy
}
$request.Method = "GET"
$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
$request.UserAgent = $userAgent
try
{
[System.Net.HttpWebResponse]$response = $request.GetResponse()
if ($response -eq $null) {
$response.Close()
return $originalFileName
}
[string]$header = $response.Headers['Content-Disposition']
[string]$headerLocation = $response.Headers['Location']
# start with content-disposition header
if ($header -ne '') {
$fileHeaderName = 'filename='
$index = $header.LastIndexOf($fileHeaderName, [StringComparison]::OrdinalIgnoreCase)
if ($index -gt -1) {
$fileName = $header.Substring($index + $fileHeaderName.Length).Replace('"', '')
}
}
# If empty, check location header next
if ($fileName -eq $null -or $fileName -eq '') {
if ($headerLocation -ne '') {
$fileName = [System.IO.Path]::GetFileName($headerLocation)
}
}
# Next comes using the response url value
if ($fileName -eq $null -or $fileName -eq '') {
$containsQuery = [System.IO.Path]::GetFileName($url).Contains('?')
$containsEquals = [System.IO.Path]::GetFileName($url).Contains('=')
$fileName = [System.IO.Path]::GetFileName($response.ResponseUri.ToString())
}
$response.Close()
$response.Dispose()
[System.Text.RegularExpressions.Regex]$containsABadCharacter = New-Object Regex("[" + [System.Text.RegularExpressions.Regex]::Escape([System.IO.Path]::GetInvalidFileNameChars()) + "]");
# when all else fails, default the name
if ($fileName -eq $null -or $fileName -eq '' -or $containsABadCharacter.IsMatch($fileName)) {
$fileName = $originalFileName
}
Write-Debug "File name determined from url is '$fileName'"
return $fileName
} catch
{
$request.ServicePoint.MaxIdleTime = 0
$request.Abort();
Write-Debug "Url request/response failed - file name will be '$originalFileName': $($_)"
return $originalFileName
}
}
## 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
$goalFormatted = Format-FileSize $goal
# 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
$totalFormatted = Format-FileSize $total
if($goal -gt 0) {
Write-Progress "Downloading $url to $fileName" "Saving $totalFormatted of $goalFormatted ($total/$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()
}
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
# 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.
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
}
}
# Copyright 2011 - Present 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.
function Get-ToolsLocation {
Write-Debug "Running 'Get-ToolsLocation'";
$invocation = $MyInvocation
if ($invocation -ne $null -and $invocation.InvocationName -ne $null -and $invocation.InvocationName.ToLower() -eq 'Get-BinRoot') {
Write-Host "Get-BinRoot is going to be deprecated in v1 and removed in v2. It is being replaced with Get-ToolsLocation, however many packages no longer require a special separate directory since package folders no longer have versions on them. Some do though and should continue to use Get-ToolsLocation."
}
$toolsLocation = $env:ChocolateyToolsLocation
if ($toolsLocation -eq $null) {
$binRoot = $env:ChocolateyBinRoot
$olderRoot = $env:chocolatey_bin_root
if ($binRoot -eq $null -and $olderRoot -eq $null) {
$toolsLocation = Join-Path $env:systemdrive 'tools'
} else {
if ($olderRoot -ne $null) {
if ($binRoot -eq $null) {
$binRoot = $olderRoot
}
Set-EnvironmentVariable -Name "chocolatey_bin_root" -Value '' -Scope User
}
$toolsLocation = $binRoot
Set-EnvironmentVariable -Name "ChocolateyBinRoot" -Value '' -Scope User
}
}
# Add a drive letter if one doesn't exist
if (-not($toolsLocation -imatch "^\w:")) {
$toolsLocation = join-path $env:systemdrive $toolsLocation
}
if (-not($env:ChocolateyToolsLocation -eq $toolsLocation)) {
Set-EnvironmentVariable -Name "ChocolateyToolsLocation" -Value $toolsLocation -Scope User
}
return $toolsLocation
}
Set-Alias Get-BinRoot Get-ToolsLocation -Force -Scope Global -Option AllScope
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
# 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.
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
}
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
# 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.
function Get-VirusCheckValid {
param(
[string] $url,
[string] $file = ''
)
Write-Debug "No virus checking built into FOSS Chocolatey."
#Write-Debug "Running 'Get-VirusCheckValid' with url:`'$url`', file: `'$file`'";
}
# 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,
[hashtable] $options = @{Headers=@{}}
)
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
}
$webclient = new-object System.Net.WebClient
if ($defaultCreds -ne $null) {
$webClient.Credentials = $defaultCreds
}
# check if a proxy is required
$explicitProxy = $env:chocolateyProxyLocation
$explicitProxyUser = $env:chocolateyProxyUser
$explicitProxyPassword = $env:chocolateyProxyPassword
if ($explicitProxy -ne $null) {
# explicit proxy
$proxy = New-Object System.Net.WebProxy($explicitProxy, $true)
if ($explicitProxyPassword -ne $null) {
$passwd = ConvertTo-SecureString $explicitProxyPassword -AsPlainText -Force
$proxy.Credentials = New-Object System.Management.Automation.PSCredential ($explicitProxyUser, $passwd)
}
Write-Host "Using explicit proxy server '$explicitProxy'."
$req.Proxy = $proxy
} elseif (!$webclient.Proxy.IsBypassed($url))
{
# system proxy (pass through)
$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 system proxy server '$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
}
if ($options.Headers.Count -gt 0) {
Write-Debug "Setting custom headers"
foreach ($item in $options.Headers.GetEnumerator()) {
$uri = (new-object system.uri $url)
Write-Debug($item.Key + ':' + $item.Value)
switch ($item.Key) {
'Accept' {$req.Accept = $item.Value}
'Cookie' {$req.CookieContainer.SetCookies($uri, $item.Value)}
'Referer' {$req.Referer = $item.Value}
'User-Agent' {$req.UserAgent = $item.Value}
Default {$req.Headers.Add($item.Key, $item.Value)}
}
}
}
$res = $req.GetResponse();
try {
$headers = @{}
foreach ($key in $res.Headers) {
$value = $res.Headers[$key];
if ($value) {
$headers.Add("$key","$value")
}
}
if ($headers.ContainsKey("Content-Type")) {
$contentType = $headers['Content-Type']
if ($contentType -ne $null) {
if ($contentType.ToLower().Contains("text/html") -or $contentType.ToLower().Contains("text/plain")) {
Write-Warning "$fileName is of content type $contentType"
Set-Content -Path "$fileName.istext" -Value "$fileName has content type $contentType" -Encoding UTF8 -Force
}
}
}
} catch {
# not able to get content-type header
Write-Debug "Error getting content type - $($_.Exception.Message)"
}
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
$goalFormatted = Format-FileSize $goal
$reader = $res.GetResponseStream()
if ($fileName) {
$fileDirectory = $([System.IO.Path]::GetDirectoryName($fileName))
if (!(Test-Path($fileDirectory))) {
[System.IO.Directory]::CreateDirectory($fileDirectory) | Out-Null
}
try {
$writer = new-object System.IO.FileStream $fileName, "Create"
} catch {
throw $_.Exception
}
}
[byte[]]$buffer = new-object byte[] 1048576
[long]$total = [long]$count = [long]$iterLoop =0
$originalEAP = $ErrorActionPreference
$ErrorActionPreference = 'Stop'
try {
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
$totalFormatted = Format-FileSize $total
if($goal -gt 0 -and ++$iterLoop%10 -eq 0) {
Write-Progress "Downloading $url to $fileName" "Saving $totalFormatted of $goalFormatted ($total/$goal)" -id 0 -percentComplete (($total/$goal)*100)
}
if ($total -eq $goal) {
Write-Progress "Completed download of $url." "Completed download of $fileName ($goalFormatted)." -id 0 -Completed
}
}
} while ($count -gt 0)
Write-Host ""
Write-Host "Download of $([System.IO.Path]::GetFileName($fileName)) ($goalFormatted) completed."
} catch {
throw $_.Exception
} finally {
$ErrorActionPreference = $originalEAP
}
$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/
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
# 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.
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"
$client = New-Object System.Net.WebClient
if ($defaultCreds -ne $null) {
$client.Credentials = $defaultCreds
}
# check if a proxy is required
$explicitProxy = $env:chocolateyProxyLocation
$explicitProxyUser = $env:chocolateyProxyUser
$explicitProxyPassword = $env:chocolateyProxyPassword
if ($explicitProxy -ne $null) {
# explicit proxy
$proxy = New-Object System.Net.WebProxy($explicitProxy, $true)
if ($explicitProxyPassword -ne $null) {
$passwd = ConvertTo-SecureString $explicitProxyPassword -AsPlainText -Force
$proxy.Credentials = New-Object System.Management.Automation.PSCredential ($explicitProxyUser, $passwd)
}
Write-Host "Using explicit proxy server '$explicitProxy'."
$request.Proxy = $proxy
} elseif (!$client.Proxy.IsBypassed($url))
{
# system proxy (pass through)
$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 system proxy server '$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
}
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
# 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.
function Install-BinFile {
param(
[string] $name,
[string] $path,
[switch] $useStart,
[string] $command = ''
)
Write-Debug "Running 'Install-BinFile' for $name with path:`'$path`'|`$useStart:$useStart|`$command:$command";
$nugetPath = [System.IO.Path]::GetFullPath((Join-Path "$helpersPath" '..\'))
$nugetExePath = Join-Path "$nugetPath" 'bin'
$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}
$originalPath = $path
$path = $path.ToLower().Replace($nugetPath.ToLower(), "..\").Replace("\\","\")
$ShimGenArgs = "-o `"$packageShimFileName`" -p `"$path`" -i `"$originalPath`""
if ($command -ne $null -and $command -ne '') {
$ShimGenArgs +=" -c $command"
}
if ($useStart) {
$ShimGenArgs +=" -gui"
}
if ($debug) {
$ShimGenArgs +=" -debug"
}
$ShimGen = Join-Path "$helpersPath" '..\tools\shimgen.exe'
if (!([System.IO.File]::Exists($ShimGen))) {
Update-SessionEnvironment
$ShimGen = Join-Path "$env:ChocolateyInstall" 'tools\shimgen.exe'
}
$ShimGen = [System.IO.Path]::GetFullPath($ShimGen)
Write-Debug "ShimGen found at `'$ShimGen`'"
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`'."
} 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`'."
Write-Host "Adding $packageBashFileName and pointing to `'$path`'."
if ($useStart) {
Write-Host "Setting up $name as a non-command line application."
"@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()
}
}
}
Set-Alias Generate-BinFile Install-BinFile
Set-Alias Add-BinFile Install-BinFile
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
# 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.
function Install-ChocolateyDesktopLink {
<#
.SYNOPSIS
This adds a shortcut on the desktop to the specified file path.
.PARAMETER TargetFilePath
This is the location to the application/executable file that you want to add a shortcut to on the desktop. This is mandatory.
.EXAMPLE
Install-ChocolateyDesktopLink -TargetFilePath "C:\tools\NHibernatProfiler\nhprof.exe"
This will create a new Desktop Shortcut pointing at the NHibernate Profiler exe.
#>
param(
[string] $targetFilePath
)
Write-Debug "Running 'Install-ChocolateyDesktopLink' with targetFilePath:`'$targetFilePath`'";
if(!$targetFilePath) {
throw "Install-ChocolateyDesktopLink - `$targetFilePath can not be null."
}
if(!(Test-Path($targetFilePath))) {
Write-Warning "'$targetFilePath' does not exist. If it is not created the shortcut will not be valid."
}
Write-Debug "Creating Shortcut..."
try {
$desktop = $([System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::DesktopDirectory))
if(!(Test-Path($desktop))) {
[System.IO.Directory]::CreateDirectory($desktop) | Out-Null
}
$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 "Desktop Shortcut created pointing at `'$targetFilePath`'."
}
catch {
Write-Warning "Unable to create desktop link. Error captured was $($_.Exception.Message)."
}
}
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
# 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.
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
}
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
# 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.
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" "%*"'
New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
Set-ItemProperty -Path "HKCR:\$fileType" -Name "(Default)" -Value "$fileType file" -ErrorAction Stop
"@
Start-ChocolateyProcessAsAdmin $elevated
Write-Host "`'$extension`' has been associated with `'$executable`'"
}
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
# 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.
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', 'sha1', 'sha256' or 'sha512' - defaults to 'md5'
.PARAMETER ChecksumType64
OPTIONAL (Right now) - 'md5', 'sha1', 'sha256' or 'sha512' - defaults to ChecksumType
.PARAMETER options
OPTIONAL - Specify custom headers
Example:
--------
$options =
@{
Headers = @{
Accept = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
'Accept-Charset' = 'ISO-8859-1,utf-8;q=0.7,*;q=0.3';
'Accept-Language' = 'en-GB,en-US;q=0.8,en;q=0.6';
Cookie = 'requiredinfo=info';
Referer = 'https://somelocation.com/';
}
}
Get-ChocolateyWebFile 'package' 'https://somelocation.com/thefile.exe' -options $options
.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,
[alias("installerType")][string] $fileType = 'exe',
[string] $silentArgs = '',
[string] $url,
[alias("url64")][string] $url64bit = '',
$validExitCodes = @(0),
[string] $checksum = '',
[string] $checksumType = '',
[string] $checksum64 = '',
[string] $checksumType64 = '',
[hashtable] $options = @{Headers=@{}}
)
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 = $env:TEMP
$tempDir = Join-Path $chocTempDir "$packageName"
if ($env:packageVersion -ne $null) {$tempDir = Join-Path $tempDir "$env:packageVersion"; }
if (![System.IO.Directory]::Exists($tempDir)) { [System.IO.Directory]::CreateDirectory($tempDir) | Out-Null }
$file = Join-Path $tempDir "$($packageName)Install.$fileType"
$filePath = Get-ChocolateyWebFile $packageName $file $url $url64bit -checksum $checksum -checksumType $checksumType -checksum64 $checksum64 -checksumType64 $checksumType64 -options $options -getOriginalFileName
Install-ChocolateyInstallPackage $packageName $fileType $silentArgs $filePath -validExitCodes $validExitCodes
}
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
# 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.
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
Update-SessionEnvironment
$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
}
}
# [System.Text.RegularExpressions.Regex]::Match($Path,[System.Text.RegularExpressions.Regex]::Escape('locationtoMatch') + '(?>;)?', '', [System.Text.RegularExpressions.RegexOptions]::IgnoreCase)
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
# 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.
function Install-ChocolateyPowershellCommand {
param(
[string] $packageName,
[string] $psFileFullPath,
[string] $url ='',
[alias("url64")][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`' ";
if ($url -ne '') {
Get-ChocolateyWebFile $packageName $psFileFullPath $url $url64bit -checksum $checksum -checksumType $checksumType -checksum64 $checksum64 -checksumType64 $checksumType64
}
$nugetPath = $(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
}
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
# 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.
function Install-ChocolateyShortcut {
<#
.SYNOPSIS
This adds a shortcut, at the specified location, with the option to specify
a number of additional properties for the shortcut, such as Working Directory,
Arguments, Icon Location, and Description.
.PARAMETER ShortcutFilePath
The full absolute path to where the shortcut should be created. This is mandatory.
.PARAMETER TargetPath
The full absolute path to the target for new shortcut. This is mandatory.
.PARAMETER WorkingDirectory
The full absolute path of the Working Directory that will be used by
the new shortcut. This is optional
.PARAMETER Arguments
Additonal arguments that should be passed along to the new shortcut. This
is optional.
.PARAMETER IconLocation
The full absolute path to an icon file to be used for the new shortcut. This
is optional.
.PARAMETER Description
A text description to be associated with the new description. This is optional.
.EXAMPLE
Install-ChocolateyShortcut -shortcutFilePath "C:\test.lnk" -targetPath "C:\test.exe"
This will create a new shortcut at the location of "C:\test.lnk" and link to the file
located at "C:\text.exe"
.EXAMPLE
Install-ChocolateyShortcut -shortcutFilePath "C:\notepad.lnk" -targetPath "C:\Windows\System32\notepad.exe" -workDirectory "C:\" -arguments "C:\test.txt" -iconLocation "C:\test.ico" -description "This is the description"
This will create a new shortcut at the location of "C:\notepad.lnk" and link to the
Notepad application. In addition, other properties are being set to specify the working
directoy, an icon to be used for the shortcut, along with a description and arguments.
#>
param(
[string] $shortcutFilePath,
[string] $targetPath,
[string] $workingDirectory,
[string] $arguments,
[string] $iconLocation,
[string] $description
)
Write-Debug "Running 'Install-ChocolateyShortcut' with parameters ShortcutFilePath: `'$shortcutFilePath`', TargetPath: `'$targetPath`', WorkingDirectory: `'$workingDirectory`', Arguments: `'$arguments`', IconLocation: `'$iconLocation`', Description: `'$description`'";
if(!$shortcutFilePath) {
throw "Install-ChocolateyShortcut - `$shortcutFilePath can not be null."
}
$shortcutDirectory = $([System.IO.Path]::GetDirectoryName($shortcutFilePath))
if (!(Test-Path($shortcutDirectory))) {
[System.IO.Directory]::CreateDirectory($shortcutDirectory) | Out-Null
}
if(!$targetPath) {
throw "Install-ChocolateyShortcut - `$targetPath can not be null."
}
if(!(Test-Path($targetPath))) {
Write-Warning "'$targetPath' does not exist. If it is not created the shortcut will not be valid."
}
if($iconLocation) {
if(!(Test-Path($iconLocation))) {
Write-Warning "'$iconLocation' does not exist. A default icon will be used."
}
}
if ($workingDirectory) {
if (!(Test-Path($workingDirectory))) {
[System.IO.Directory]::CreateDirectory($workingDirectory) | Out-Null
}
}
Write-Debug "Creating Shortcut..."
try {
$global:WshShell = New-Object -com "WScript.Shell"
$lnk = $global:WshShell.CreateShortcut($shortcutFilePath)
$lnk.TargetPath = $targetPath
$lnk.WorkingDirectory = $workingDirectory
$lnk.Arguments = $arguments
if($iconLocation) {
$lnk.IconLocation = $iconLocation
}
if ($description) {
$lnk.Description = $description
}
$lnk.Save()
Write-Debug "Shortcut created."
}
catch {
Write-Warning "Unable to create shortcut. Error captured was $($_.Exception.Message)."
}
}
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
# 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.
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', 'sha1', 'sha256' or 'sha512' - 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) {
if ([System.IntPtr]::Size -eq 4)
{
<# 32bits system case #>
$versions=(get-ChildItem HKLM:SOFTWARE\Microsoft\VisualStudio -ErrorAction SilentlyContinue | ? { ($_.PSChildName -match "^[0-9\.]+$") } | ? {$_.property -contains "InstallDir"} | sort {[int]($_.PSChildName)} -descending)
}
else
{
$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 {
if ([System.IntPtr]::Size -eq 4)
{
<# 32bits system case #>
$versions=(get-ChildItem HKLM:SOFTWARE\Microsoft\VisualStudio -ErrorAction SilentlyContinue | ? { ($_.PSChildName.EndsWith("$vsVersion.0")) } | ? {$_.property -contains "InstallDir"})
}
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) {
throw "This installed VS version, $vnum, does not support installing VSIX packages. Version 10 is the minimum acceptable version."
}
$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 {
throw "There were errors attempting to retrieve the vsix from $vsixUrl. The error message was '$_'."
}
Write-Debug "Installing VSIX using $installer"
$exitCode = Install-Vsix "$installer" "$download"
if($exitCode -gt 0 -and $exitCode -ne 1001) { #1001: Already installed
throw "There was an error installing '$packageName'. The exit code returned was $exitCode."
}
}
else {
throw "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
}
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
# 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.
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', 'sha1', 'sha256' or 'sha512' - defaults to 'md5'
.PARAMETER ChecksumType64
OPTIONAL (Right now) - 'md5', 'sha1', 'sha256' or 'sha512' - defaults to ChecksumType
.PARAMETER options
OPTIONAL - Specify custom headers
Example:
--------
$options =
@{
Headers = @{
Accept = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
'Accept-Charset' = 'ISO-8859-1,utf-8;q=0.7,*;q=0.3';
'Accept-Language' = 'en-GB,en-US;q=0.8,en;q=0.6';
Cookie = 'requiredinfo=info';
Referer = 'https://somelocation.com/';
}
}
Get-ChocolateyWebFile 'package' 'https://somelocation.com/thefile.exe' -options $options
.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,
[alias("url64")][string] $url64bit = '',
[string] $specificFolder ="",
[string] $checksum = '',
[string] $checksumType = '',
[string] $checksum64 = '',
[string] $checksumType64 = '',
[hashtable] $options = @{Headers=@{}}
)
Write-Debug "Running 'Install-ChocolateyZipPackage' for $packageName with url:`'$url`', unzipLocation: `'$unzipLocation`', url64bit: `'$url64bit`', specificFolder: `'$specificFolder`', checksum: `'$checksum`', checksumType: `'$checksumType`', checksum64: `'$checksum64`', checksumType64: `'$checksumType64`' ";
$fileType = 'zip'
$chocTempDir = $env:TEMP
$tempDir = Join-Path $chocTempDir "$packageName"
if ($env:packageVersion -ne $null) {$tempDir = Join-Path $tempDir "$env:packageVersion"; }
if (![System.IO.Directory]::Exists($tempDir)) {[System.IO.Directory]::CreateDirectory($tempDir) | Out-Null}
$file = Join-Path $tempDir "$($packageName)Install.$fileType"
$filePath = Get-ChocolateyWebFile $packageName $file $url $url64bit -checkSum $checkSum -checksumType $checksumType -checkSum64 $checkSum64 -checksumType64 $checksumType64 -options $options -getOriginalFileName
Get-ChocolateyUnzip "$filePath" $unzipLocation $specificFolder $packageName
}
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
# 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.
function Set-EnvironmentVariable([string] $Name, [string] $Value, [System.EnvironmentVariableTarget] $Scope) {
Write-Debug "Calling Set-EnvironmentVariable with `$Name = '$Name', `$Value = '$Value', `$Scope = '$Scope'"
[Environment]::SetEnvironmentVariable($Name, $Value, $Scope)
}
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
# 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.
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 ($wrappedStatements -eq $null) { $wrappedStatements = ''}
if ($exeToRun -eq 'powershell') {
$exeToRun = "$($env:windir)\System32\WindowsPowerShell\v1.0\powershell.exe"
$importChocolateyHelpers = ""
Get-ChildItem "$helpersPath" -Filter *.psm1 | ForEach-Object { $importChocolateyHelpers = "& import-module -name `'$($_.FullName)`';$importChocolateyHelpers" };
$block = @"
`$noSleep = `$$noSleep
$importChocolateyHelpers
try{
`$progressPreference="SilentlyContinue"
$statements
if(!`$noSleep){start-sleep 6}
}
catch{
if(!`$noSleep){start-sleep 8}
throw
}
"@
$encoded = [Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes($block))
$wrappedStatements = "-NoProfile -ExecutionPolicy bypass -EncodedCommand $encoded"
$dbgMessage = @"
Elevating Permissions and running powershell block:
$block
This may take a while, depending on the statements.
"@
}
else
{
$dbgMessage = @"
Elevating Permissions and running [`"$exeToRun`" $wrappedStatements]. This may take a while, depending on the statements.
"@
}
Write-Debug $dbgMessage
# Redirecting output slows things down a bit.
$writeOutput = {
if ($EventArgs.Data -ne $null) {
Write-Host "$($EventArgs.Data)"
}
}
$writeError = {
if ($EventArgs.Data -ne $null) {
Write-Error "$($EventArgs.Data)"
}
}
$process = New-Object System.Diagnostics.Process
$process.EnableRaisingEvents = $true
Register-ObjectEvent -InputObject $process -SourceIdentifier "LogOutput_ChocolateyProc" -EventName OutputDataReceived -Action $writeOutput | Out-Null
Register-ObjectEvent -InputObject $process -SourceIdentifier "LogErrors_ChocolateyProc" -EventName ErrorDataReceived -Action $writeError | Out-Null
#$process.StartInfo = New-Object System.Diagnostics.ProcessStartInfo($exeToRun, $wrappedStatements)
# in case empty args makes a difference, try to be compatible with the older
# version
$psi = New-Object System.Diagnostics.ProcessStartInfo
$psi.FileName = $exeToRun
if ($wrappedStatements -ne '') {
$psi.Arguments = "$wrappedStatements"
}
$process.StartInfo = $psi
# process start info
$process.StartInfo.RedirectStandardOutput = $true
$process.StartInfo.RedirectStandardError = $true
$process.StartInfo.UseShellExecute = $false
$process.StartInfo.WorkingDirectory = Get-Location
if ([Environment]::OSVersion.Version -ge (New-Object 'Version' 6,0)){
Write-Debug "Setting RunAs for elevation"
$process.StartInfo.Verb = "RunAs"
}
if ($minimized) {
$process.StartInfo.WindowStyle = [System.Diagnostics.ProcessWindowStyle]::Minimized
}
$process.Start() | Out-Null
if ($process.StartInfo.RedirectStandardOutput) { $process.BeginOutputReadLine() }
if ($process.StartInfo.RedirectStandardError) { $process.BeginErrorReadLine() }
$process.WaitForExit()
# 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_ChocolateyProc"
Unregister-Event -SourceIdentifier "LogErrors_ChocolateyProc"
$exitCode = $process.ExitCode
$process.Dispose()
Write-Debug "Command [`"$exeToRun`" $wrappedStatements] exited with `'$exitCode`'."
if ($validExitCodes -notcontains $exitCode) {
throw "Running [`"$exeToRun`" $statements] was not successful. Exit code was '$exitCode'. See log for possible error messages."
}
Write-Debug "Finishing 'Start-ChocolateyProcessAsAdmin'"
}
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
# 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.
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
}
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
# 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.
function Uninstall-BinFile {
param(
[string] $name,
[string] $path
)
Write-Debug "Running 'Uninstall-BinFile' for $name with path:`'$path`'";
$nugetPath = [System.IO.Path]::GetFullPath((Join-Path "$helpersPath" '..\'))
$nugetExePath = Join-Path "$nugetPath" 'bin'
$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`'."
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`'."
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`'."
Remove-Item $packageShimFileName
}
else {
Write-Debug "Tried to remove shim $packageShimFileName but it was already removed."
}
}
Set-Alias Remove-BinFile Uninstall-BinFile
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
# 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.
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,
[alias("installerType")][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) {
Write-Host "Overriding package arguments with `'$additionalInstallArgs`'";
Start-ChocolateyProcessAsAdmin "$additionalInstallArgs" $file -validExitCodes $validExitCodes
} else {
Start-ChocolateyProcessAsAdmin "$silentArgs $additionalInstallArgs" $file -validExitCodes $validExitCodes
}
}
write-host "$packageName has been uninstalled."
#cutStart-Sleep 3
}
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
# 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.
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 "
$packagelibPath=$env:chocolateyPackageFolder
$zipContentFile=(join-path $packagelibPath $zipFileName) + ".txt"
if ((Test-Path -path $zipContentFile)) {
$zipContentFile
$zipContents=get-content $zipContentFile
foreach ($fileInZip in $zipContents) {
remove-item -Path "$fileInZip" -ErrorAction SilentlyContinue -Recurse -Force
}
}
}
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
# 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.
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.
#>
Write-Debug "Running 'Update-SessionEnvironment' - Updating the environment variables for the session."
#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 ';'
}
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
# 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.
function Write-ChocolateyFailure {
param(
[string] $packageName,
[string] $failureMessage
)
Write-Warning "Write-ChocolateyFailure is deprecated. If you are the package maintainer, please use 'throw `$_.Exception' instead."
$error | %{ $_.Exception | fl * | Out-String }
throw "$failureMessage"
}
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
# 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.
function Write-ChocolateySuccess {
param(
[string] $packageName
)
Write-Warning "Write-ChocolateySuccess is deprecated. If you are the maintainer, please remove it from your package file."
}
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
# 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.
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
}
Copyright 2011 - Present 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.
md5: 176EADFA68012645344C661D4DE647CD | sha1: CCDE95F98DF5BDDB4DB9059D38C8305F2708456C | sha256: BC173E6A1B70C49FDBAA9D01FB59B352E1F7ED146AF9E1D025DAAB1A50FAFE67 | sha512: 55739C869D8B369103103067087C2D527DB1D8A0440C698937075B80031B86A53ABC4EE2B1EDAE04B65854BA5EDFF2ECB22F9F6C9559591A32DD2C16798601A3
md5: 2FECD47A079755D4E11B9AA7210C3609 | sha1: 3FAF880F07F2B1196AFFE7B3C76002A50927CC16 | sha256: CC40C8E70A4D81B321A5273BB387EE8A19E1FD1336731FE29C18A52E6F06907A | sha512: AB56B4FA796CF6F1473896F4538330637ACADA6B07761FF8760382C793EA6D51B4D86E5111524785DDFD5AC84E28FF83751C42A1A6DCD9D6067392830476CCB5
md5: 4F9D3AE7EB58E993C670185537108BD0 | sha1: D2C8085EBFBC5F4883C01C13D1C2B90BA0CD9ABE | sha256: 854CABA3A3CAE5C2F92B2F56703A86DC882CDA89B16CBB3244D65CA2DEFA1E63 | sha512: A10E15EC30E9ABD08FA695409B65DDB27A933D741C514334D8935F48CBD8C6F9EF6E38BB367D06A66DFCE1566E44EF99291F46B8C8B2C0BE35C493A89F7934EB
md5: E993A15D1ADB26EAE22B25EBB1A37B5A | sha1: 94FFCE41CC92116B3B25A89E27D015588EE36455 | sha256: BA17CA423F129F609234AE1888358F2F20C2CB89F9F5097BE06B403DE739B4D0 | sha512: 8DA78FD58A197EF6B37A0DC6EB3121A954E085131D665D0E94EE2801CBD4E75D32E256A4976C4A1D47DDBC5E0F09883439818456854004BB4221FE2D17382B7D
md5: 009E9F190F7633CE125E263A5312C303 | sha1: 0B3BA461AC9104FE3DF7627CE643685EA1463921 | sha256: 15CB5E2461E8BD1085183D073E76243026E54FCB84A2F0A1B2EBD5046B8956CE | sha512: BE6E0829F2F972693380C97C5C0E7CFDF6D22E5258B3098504B8320D7D8905B5EF25D2D921093DDAA125E28B5464D2CE5719BAE1709DA4B65B17DAB0A857396F
md5: 36D8F4F7CB59E950801CAD8E3E204E97 | sha1: 4617966F1B60D2F024359C25C37E8856256D5233 | sha256: CA648F83B29CB57A3DED0CAB66BACBCD617C76E9DFD83FD2DF323AD521F7DF58 | sha512: 06EBE998DEBBC3EBF79681FD6B9FB658D42155E136F6034DADF786FA9920C52C7F0FC12B9D0483FC966641231D3C6E7DFE2A9D1FF2A33640EB0FECD9347964FC
md5: 8AAB0639579D577D1970ED4D7FCF5B94 | sha1: C88E4109D66D115BF708C0C68BFAF9695650218D | sha256: BD4B5AE952B0BA2FA090A3FA1B14AA9172C3BC2B5C455E13C18312CAA9E6AF77 | sha512: 732423B8DC197F3A354F40F6A0D6249AD4296AA340657E160AD604696F39825A038AB4073C55F27A98449743C75D3E16CCA1E521B01D04755D5208FB53DAF0B1
md5: E44353BB4C4A1EFD210E24E9FF7BA89B | sha1: 2B0B3A8ABC628F41EE7D7935DF0A927C57562869 | sha256: 404E70ACC130C3C20A1C792E4DECF74B54A57CC752F9FCC7003BA6E2B4EFD16D | sha512: 8738FA380ABC10B6C869849D9EE4A7227732785182D7502574A7AA86E62ADC20BB193CA6E0D52061E643ADF6C9494E670DB2408AD710AF8E509B73DC8B73026B
md5: 16FC4F75CB5B1E27A168C4E7FCA412C7 | sha1: 1C05EFF3E2E48BE640D83D74DA93A686D7C1179B | sha256: 68438ABAB83675D77CF7910EF3615F19799A15FA9981A5325FBEA398CE647F3E | sha512: AC5BD5D3117E0758D3615522535724A53BFB1144C191CB3775ABF0937A8F94F640E7DCA9358BFFF9449263590EDE0644B192538488CB15A32134CB40E8F7BAFA
@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 .
md5: 42BADC1D2F03A8B1E4875740D3D49336 | sha1: CEE178DA1FB05F99AF7A3547093122893BD1EB46 | sha256: C136B1467D669A725478A6110EBAAAB3CB88A3D389DFA688E06173C066B76FCF | sha512: 6BC519A7368EE6BD8C8F69F2D634DD18799B4CA31FBC284D2580BA625F3A88B6A52D2BC17BEA0E75E63CA11C10356C47EE00C2C500294ABCB5141424FC5DC71C
7-Zip Extra
~~~~~~~~~~~
License for use and distribution
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Copyright (C) 1999-2015 Igor Pavlov.
7-Zip Extra files are under the GNU LGPL license.
Notes:
You can use 7-Zip Extra 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/
md5: 0AA5F736E619FDB8664C43779466DD14 | sha1: FE239546417500BA0B324E2C6F205865DE0DE7D8 | sha256: 69B22EE0C328DDE3D291E03170FAAB8A5C663685111CC4D201AB786994CE3EA5 | sha512: 5ECC9148243492BC7966403DD4433199A734996EB2F7C07781671EAAA726E4D6987231E4678D2DAA147875FFE13B3516B91A0778E2D218AF2C71BD3EC7F0A1A2
CheckSum is licensed as Apache v2 - https://raw.github.com/ferventcoder/checksum/master/LICENSE
md5: A471AC00B5B6FEC13A69790752712E27 | sha1: BE178BC1D80D291690B64C1AEBC46D474F121579 | sha256: E106E0A4D43BFA4030B5E1853DCC0B07EA0D4E07A85C7C9F1BAB4741F0989A27 | sha512: 57CB4C5C488D29E540AEDE29C96227DF5322DCC4E1961F4884C38659FA16834A8266A8F234A54BD33FD12371B9CA196612A66FC2565D85EB4B97EE538BCFE679
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
$tempDir = $env:TEMP
$defaultChocolateyPathOld = "$sysDrive\Chocolatey"
function Initialize-Chocolatey {
<#
.DESCRIPTION
This will initialize the Chocolatey tool by
a) setting up the "chocolateyPath" (the location where all chocolatey nuget packages will be installed)
b) Installs chocolatey into the "chocolateyPath"
c) Instals .net 4.0 if needed
d) Adds Chocolatey to the PATH environment variable so you have access to the choco commands.
.PARAMETER ChocolateyPath
Allows you to override the default path of (C:\ProgramData\chocolatey\) by specifying a directory chocolatey will install nuget packages.
.EXAMPLE
C:\PS> Initialize-Chocolatey
Installs chocolatey into the default C:\ProgramData\Chocolatey\ directory.
.EXAMPLE
C:\PS> Initialize-Chocolatey -chocolateyPath "D:\ChocolateyInstalledNuGets\"
Installs chocolatey into the custom directory D:\ChocolateyInstalledNuGets\
#>
param(
[Parameter(Mandatory=$false)][string]$chocolateyPath = ''
)
Write-Debug "Initialize-Chocolatey"
$installModule = Join-Path $thisScriptFolder 'chocolateyInstall\helpers\chocolateyInstaller.psm1'
Import-Module $installModule -Force
if ($chocolateyPath -eq '') {
$programData = [Environment]::GetFolderPath("CommonApplicationData")
$chocolateyPath = Join-Path "$programData" 'chocolatey'
}
# variable to allow insecure directory:
$allowInsecureRootInstall = $false
if ($env:ChocolateyAllowInsecureRootDirectory -eq 'true') { $allowInsecureRootInstall = $true }
# if we have an already environment variable path, use it.
$alreadyInitializedNugetPath = Get-ChocolateyInstallFolder
if ($alreadyInitializedNugetPath -and $alreadyInitializedNugetPath -ne $chocolateyPath -and ($allowInsecureRootInstall -or $alreadyInitializedNugetPath -ne $defaultChocolateyPathOld)){
$chocolateyPath = $alreadyInitializedNugetPath
}
else {
Set-ChocolateyInstallFolder $chocolateyPath
}
Create-DirectoryIfNotExists $chocolateyPath
Ensure-UserPermissions $chocolateyPath
#set up variables to add
$chocolateyExePath = Join-Path $chocolateyPath 'bin'
$chocolateyLibPath = Join-Path $chocolateyPath 'lib'
if ($tempDir -eq $null) {
$tempDir = Join-Path $chocolateyPath 'temp'
Create-DirectoryIfNotExists $tempDir
}
$yourPkgPath = [System.IO.Path]::Combine($chocolateyLibPath,"yourPackageName")
@"
We are setting up the Chocolatey package repository.
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 folders if they do not already exist.
"@ | Write-Output
Write-Warning "You can safely ignore errors related to missing log files when `n upgrading from a version of Chocolatey less than 0.9.9. `n 'Batch file could not be found' is also safe to ignore. `n 'The system cannot find the file specified' - also safe."
#create the base structure if it doesn't exist
Create-DirectoryIfNotExists $chocolateyExePath
Create-DirectoryIfNotExists $chocolateyLibPath
Install-ChocolateyFiles $chocolateyPath
Ensure-ChocolateyLibFiles $chocolateyLibPath
Install-ChocolateyBinFiles $chocolateyPath $chocolateyExePath
$chocolateyExePathVariable = $chocolateyExePath.ToLower().Replace($chocolateyPath.ToLower(), "%DIR%..\").Replace("\\","\")
Initialize-ChocolateyPath $chocolateyExePath $chocolateyExePathVariable
Process-ChocolateyBinFiles $chocolateyExePath $chocolateyExePathVariable
$realModule = Join-Path $chocolateyPath "helpers\chocolateyInstaller.psm1"
Import-Module "$realModule" -Force
if (-not $allowInsecureRootInstall -and (Test-Path($defaultChocolateyPathOld))) {
Upgrade-OldChocolateyInstall $defaultChocolateyPathOld $chocolateyPath
Install-ChocolateyBinFiles $chocolateyPath $chocolateyExePath
}
Install-DotNet4IfMissing
@"
Chocolatey (choco.exe) is now ready.
You can call choco 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 choco.
"@ | write-Output
if (-not $allowInsecureRootInstall) {
Remove-OldChocolateyInstall $defaultChocolateyPathOld
}
}
function Set-ChocolateyInstallFolder {
param(
[string]$folder
)
Write-Debug "Set-ChocolateyInstallFolder"
$environmentTarget = [System.EnvironmentVariableTarget]::User
# removing old variable
Install-ChocolateyEnvironmentVariable -variableName "$chocInstallVariableName" -variableValue $null -variableType $environmentTarget
if (Test-ProcessAdminRights) {
Write-Debug "Administrator installing so using Machine environment variable target instead of User."
$environmentTarget = [System.EnvironmentVariableTarget]::Machine
# removing old variable
Install-ChocolateyEnvironmentVariable -variableName "$chocInstallVariableName" -variableValue $null -variableType $environmentTarget
} else {
Write-Warning "Setting ChocolateyInstall Environment Variable on USER and not SYSTEM variables.`n This is due to either non-administrator install OR the process you are running is not being run as an Administrator."
}
Write-Output "Creating $chocInstallVariableName as an environment variable (targeting `'$environmentTarget`') `n Setting $chocInstallVariableName to `'$folder`'"
Write-Warning "It's very likely you will need to close and reopen your shell `n before you can use choco."
Install-ChocolateyEnvironmentVariable -variableName "$chocInstallVariableName" -variableValue "$folder" -variableType $environmentTarget
}
function Get-ChocolateyInstallFolder(){
Write-Debug "Get-ChocolateyInstallFolder"
[Environment]::GetEnvironmentVariable($chocInstallVariableName)
}
function Create-DirectoryIfNotExists($folderName){
Write-Debug "Create-DirectoryIfNotExists"
if (![System.IO.Directory]::Exists($folderName)) { [System.IO.Directory]::CreateDirectory($folderName) | Out-Null }
}
function Ensure-UserPermissions {
param(
[string]$folder
)
Write-Debug "Ensure-UserPermissions"
if (!(Test-ProcessAdminRights)) {
Write-Warning "User is not running elevated, cannot set user permissions."
return
}
$currentEA = $ErrorActionPreference
$ErrorActionPreference = 'Stop'
try {
# get current user
$currentUser = [Security.Principal.WindowsIdentity]::GetCurrent()
# get current acl
$acl = Get-Acl $folder
# define rule to set
$rights = "Modify"
$userAccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule($currentUser.Name, $rights, "Allow")
# this is idempotent
Write-Output "Adding Modify permission for current user to '$folder'"
$acl.SetAccessRuleProtection($false,$true)
$acl.SetAccessRule($userAccessRule)
Set-Acl $folder $acl
} catch {
Write-Warning "Not able to set permissions for user."
}
$ErrorActionPreference = $currentEA
}
function Upgrade-OldChocolateyInstall {
param(
[string]$chocolateyPathOld = "$sysDrive\Chocolatey",
[string]$chocolateyPath = "$($env:ALLUSERSPROFILE)\chocolatey"
)
Write-Debug "Upgrade-OldChocolateyInstall"
if (Test-Path $chocolateyPathOld) {
Write-Output "Attempting to upgrade `'$chocolateyPathOld`' to `'$chocolateyPath`'."
Write-Warning "Copying the contents of `'$chocolateyPathOld`' to `'$chocolateyPath`'. `n This step may fail if you have anything in this folder running or locked."
Write-Output 'If it fails, just manually copy the rest of the items out and then delete the folder.'
Write-Warning "!!!! ATTN: YOU WILL NEED TO CLOSE AND REOPEN YOUR SHELL !!!!"
#-ForegroundColor Magenta -BackgroundColor Black
$chocolateyExePathOld = Join-Path $chocolateyPathOld 'bin'
'Machine', 'User' |
% {
$path = Get-EnvironmentVariable -Name 'PATH' -Scope $_
$updatedPath = [System.Text.RegularExpressions.Regex]::Replace($path,[System.Text.RegularExpressions.Regex]::Escape($chocolateyExePathOld) + '(?>;)?', '', [System.Text.RegularExpressions.RegexOptions]::IgnoreCase)
if ($updatedPath -ne $path) {
Write-Output "Updating `'$_`' PATH to reflect removal of '$chocolateyPathOld'."
try {
Set-EnvironmentVariable -Name 'Path' -Value $updatedPath -Scope $_ -ErrorAction Stop
} catch {
Write-Warning "Was not able to remove the old environment variable from PATH. You will need to do this manually"
}
}
}
Copy-Item "$chocolateyPathOld\lib\*" "$chocolateyPath\lib" -force -recurse
$from = "$chocolateyPathOld\bin"
$to = "$chocolateyPath\bin"
$exclude = @("choco.exe", "chocolatey.exe", "cinst.exe", "clist.exe", "cpack.exe", "cpush.exe", "cuninst.exe", "cup.exe", "cver.exe", "RefreshEnv.cmd")
Get-ChildItem -Path $from -recurse -Exclude $exclude |
% {
Write-Debug "Copying $_ `n to $to"
if ($_.PSIsContainer) {
Copy-Item $_ -Destination (Join-Path $to $_.Parent.FullName.Substring($from.length)) -Force -ErrorAction SilentlyContinue
} else {
$fileToMove = (Join-Path $to $_.FullName.Substring($from.length))
try {
Copy-Item $_ -Destination $fileToMove -Exclude $exclude -Force -ErrorAction Stop
}
catch {
Write-Warning "Was not able to move `'$fileToMove`'. You may need to reinstall the shim"
}
}
}
}
}
function Remove-OldChocolateyInstall {
param(
[string]$chocolateyPathOld = "$sysDrive\Chocolatey"
)
Write-Debug "Remove-OldChocolateyInstall"
if (Test-Path $chocolateyPathOld) {
Write-Warning "This action will result in Log Errors, you can safely ignore those. `n You may need to finish removing '$chocolateyPathOld' manually."
try {
Get-ChildItem -Path "$chocolateyPathOld" | % {
if (Test-Path $_.FullName) {
Write-Debug "Removing $_ unless matches .log"
Remove-Item $_.FullName -exclude *.log -recurse -force -ErrorAction SilentlyContinue
}
}
Write-Output "Attempting to remove `'$chocolateyPathOld`'. This may fail if something in the folder is being used or locked."
Remove-Item "$($chocolateyPathOld)" -force -recurse -ErrorAction Stop
}
catch {
Write-Warning "Was not able to remove `'$chocolateyPathOld`'. You will need to manually remove it."
}
}
}
function Install-ChocolateyFiles {
param(
[string]$chocolateyPath
)
Write-Debug "Install-ChocolateyFiles"
Write-Debug "Removing install files in chocolateyInstall, helpers, redirects, and tools"
"$chocolateyPath\chocolateyInstall", "$chocolateyPath\helpers", "$chocolateyPath\redirects", "$chocolateyPath\tools" | % {
#Write-Debug "Checking path $_"
if (Test-Path $_) {
Get-ChildItem -Path "$_" | % {
#Write-Debug "Checking child path $_ ($($_.FullName))"
if (Test-Path $_.FullName) {
Write-Debug "Removing $_ unless matches .log"
Remove-Item $_.FullName -exclude *.log -recurse -force -ErrorAction SilentlyContinue
}
}
}
}
Write-Debug "Attempting to move choco.exe to choco.exe.old so we can place the new version here."
# rename the currently running process / it will be locked if it exists
$chocoExe = Join-Path $chocolateyPath 'choco.exe'
if (Test-Path ($chocoExe)) {
Write-Debug "Renaming '$chocoExe' to '$chocoExe.old'"
try {
Remove-Item "$chocoExe.old" -force -ErrorAction SilentlyContinue
Move-Item $chocoExe "$chocoExe.old" -force -ErrorAction SilentlyContinue
}
catch {
Write-Warning "Was not able to rename `'$chocoExe`' to `'$chocoExe.old`'."
}
}
Write-Debug "Unpacking files required for Chocolatey."
$chocInstallFolder = Join-Path $thisScriptFolder "chocolateyInstall"
$chocoExe = Join-Path $chocInstallFolder 'choco.exe'
$chocoExeDest = Join-Path $chocolateyPath 'choco.exe'
Copy-Item $chocoExe $chocoExeDest -force
Write-Debug "Copying the contents of `'$chocInstallFolder`' to `'$chocolateyPath`'."
Copy-Item $chocInstallFolder\* $chocolateyPath -recurse -force
}
function Ensure-ChocolateyLibFiles {
param(
[string]$chocolateyLibPath
)
Write-Debug "Ensure-ChocolateyLibFiles"
$chocoPkgDirectory = Join-Path $chocolateyLibPath 'chocolatey'
Create-DirectoryIfNotExists $chocoPkgDirectory
if (!(Test-Path("$chocoPkgDirectory\chocolatey.nupkg"))) {
Write-Output "chocolatey.nupkg file not installed in lib.`n Attempting to locate it from bootstrapper."
$chocoZipFile = Join-Path $tempDir "chocolatey\chocInstall\chocolatey.zip"
Write-Debug "First the zip file at '$chocoZipFile'."
Write-Debug "Then from a neighboring chocolatey.*nupkg file '$thisScriptFolder/../../'."
if (Test-Path("$chocoZipFile")) {
Write-Debug "Copying '$chocoZipFile' to '$chocoPkgDirectory\chocolatey.nupkg'."
Copy-Item "$chocoZipFile" "$chocoPkgDirectory\chocolatey.nupkg" -Force -ErrorAction SilentlyContinue
}
if (!(Test-Path("$chocoPkgDirectory\chocolatey.nupkg"))) {
$chocoPkg = Get-ChildItem "$thisScriptFolder/../../" | ?{$_.name -match "^chocolatey.*nupkg" } | Sort name -Descending | Select -First 1
if ($chocoPkg -ne '') { $chocoPkg = $chocoPkg.FullName }
"$chocoZipFile", "$chocoPkg" | % {
if ($_ -ne $null -and $_ -ne '') {
if (Test-Path $_) {
Write-Debug "Copying '$_' to '$chocoPkgDirectory\chocolatey.nupkg'."
Copy-Item $_ "$chocoPkgDirectory\chocolatey.nupkg" -Force -ErrorAction SilentlyContinue
}
}
}
}
}
}
function Install-ChocolateyBinFiles {
param(
[string] $chocolateyPath,
[string] $chocolateyExePath
)
Write-Debug "Install-ChocolateyBinFiles"
Write-Debug "Installing the bin file redirects"
$redirectsPath = Join-Path $chocolateyPath 'redirects'
if (!(Test-Path "$redirectsPath")) {
Write-Warning "$redirectsPath does not exist"
return
}
$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 -ErrorAction SilentlyContinue }
if (Test-Path ($bashFilePath)) { Remove-Item $bashFilePath -force -ErrorAction SilentlyContinue }
if (Test-Path ($binFilePathRename)) {
try {
Write-Debug "Attempting to remove $binFilePathRename"
Remove-Item $binFilePathRename -force -ErrorAction Stop
}
catch {
Write-Warning "Was not able to remove `'$binFilePathRename`'. This may cause errors."
}
}
if (Test-Path ($binFilePath)) {
try {
Write-Debug "Attempting to rename $binFilePath to $binFilePathRename"
Move-Item -path $binFilePath -destination $binFilePathRename -force -ErrorAction Stop
}
catch {
Write-Warning "Was not able to rename `'$binFilePath`' to `'$binFilePathRename`'."
}
}
try {
Write-Debug "Attempting to copy $exeFilePath to $binFilePath"
Copy-Item -path $exeFilePath -destination $binFilePath -force -ErrorAction Stop
}
catch {
Write-Warning "Was not able to replace `'$binFilePath`' with `'$exeFilePath`'. You may need to do this manually."
}
$commandShortcut = [System.IO.Path]::GetFileNameWithoutExtension("$exeFilePath")
Write-Debug "Added command $commandShortcut"
}
}
function Initialize-ChocolateyPath {
param(
[string]$chocolateyExePath = "$($env:ALLUSERSPROFILE)\chocolatey\bin",
[string]$chocolateyExePathVariable = "%$($chocInstallVariableName)%\bin"
)
Write-Debug "Initialize-ChocolateyPath"
Write-Debug "Initializing Chocolatey Path if required"
$environmentTarget = [System.EnvironmentVariableTarget]::User
if (Test-ProcessAdminRights) {
Write-Debug "Administrator installing so using Machine environment variable target instead of User."
$environmentTarget = [System.EnvironmentVariableTarget]::Machine
} else {
Write-Warning "Setting ChocolateyInstall Path on USER PATH and not SYSTEM Path.`n This is due to either non-administrator install OR the process you are running is not being run as an Administrator."
}
Install-ChocolateyPath -pathToInstall "$chocolateyExePath" -pathType $environmentTarget
}
function Process-ChocolateyBinFiles {
param(
[string]$chocolateyExePath = "$($env:ALLUSERSPROFILE)\chocolatey\bin",
[string]$chocolateyExePathVariable = "%$($chocInstallVariableName)%\bin"
)
Write-Debug "Process-ChocolateyBinFiles"
$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) {
Write-Debug "Processing Bin files"
foreach ($file in $files) {
Write-Output "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
}
}
$netFx4InstallTries = 0
function Install-DotNet4IfMissing {
param(
$forceFxInstall = $false
)
# we can't take advantage of any chocolatey module functions, because they
# haven't been unpacked because they require .NET Framework 4.0
Write-Debug "Install-DotNet4IfMissing"
if ([IntPtr]::Size -eq 8) {$fx="framework64"} else {$fx="framework"}
$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'
$NetFx4Url = $NetFx4FullUrl
$NetFx4Path = "$tempDir"
$NetFx4InstallerFile = 'dotNetFx40_Full_x86_x64.exe'
$NetFx4Installer = Join-Path $NetFx4Path $NetFx4InstallerFile
if(!(test-path "$env:windir\Microsoft.Net\$fx\v4.0.30319") -or $forceFxInstall) {
if (!(Test-Path $NetFx4Path)) {
Write-Output "Creating folder `'$NetFx4Path`'"
$null = New-Item -Path "$NetFx4Path" -ItemType Directory
}
$netFx4InstallTries += 1
if (!(Test-Path $NetFx4Installer)) {
Write-Output "Downloading `'$NetFx4Url`' to `'$NetFx4Installer`' - the installer is 40+ MBs, so this could take a while on a slow connection."
(New-Object Net.WebClient).DownloadFile("$NetFx4Url","$NetFx4Installer")
}
$psi = New-Object System.Diagnostics.ProcessStartInfo
$psi.WorkingDirectory = "$NetFx4Path"
$psi.FileName = "$NetFx4InstallerFile"
# https://msdn.microsoft.com/library/ee942965(v=VS.100).aspx#command_line_options
# http://blogs.msdn.com/b/astebner/archive/2010/05/12/10011664.aspx
# For the actual setup.exe (if you want to unpack first) - /repair /x86 /x64 /ia64 /parameterfolder Client /q /norestart
$psi.Arguments = "/q /norestart /repair"
Write-Output "Installing `'$NetFx4Installer`' - this may take awhile with no output."
$s = [System.Diagnostics.Process]::Start($psi);
$s.WaitForExit();
if ($s.ExitCode -ne 0 -and $s.ExitCode -ne 3010) {
if ($netFx4InstallTries -eq 2) {
Write-Error ".NET Framework install failed with exit code `'$($s.ExitCode)`'. `n This will cause the rest of the install to fail."
throw "Error installing .NET Framework 4.0 (exit code $($s.ExitCode)). `n Please install the .NET Framework 4.0 manually and then try to install Chocolatey again. `n Download at `'$NetFx4Url`'"
} else {
Write-Warning "First try of .NET framework install failed with exit code `'$($s.ExitCode)`'. Trying again."
Install-DotNet4IfMissing $true
}
}
}
}
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.
- checksum.exe (69b22ee0c328) - ## / 68
- 7za.exe (c136b1467d66) - ## / 72
- chocolatey.0.9.10-beta-20160302.nupkg (4385e6e90b4b) - ## / 57
- choco.exe (bc173e6a1b70) - ## / 57
- chocolatey.exe (cc40c8e70a4d) - ## / 57
- cinst.exe (854caba3a3ca) - ## / 57
- clist.exe (ba17ca423f12) - ## / 57
- cpack.exe (15cb5e2461e8) - ## / 57
- cpush.exe (ca648f83b29c) - ## / 54
- cuninst.exe (bd4b5ae952b0) - ## / 57
- cup.exe (404e70acc130) - ## / 57
- cver.exe (68438abab836) - ## / 57
- shimgen.exe (e106e0a4d43b) - ## / 57
- choco.exe (2c8b25127820) - ## / 57
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.0 | 2314069 | Tuesday, November 12, 2024 | Approved |
Chocolatey 2.3.0 | 8916831 | Wednesday, June 5, 2024 | Approved |
Chocolatey 2.2.2 | 25327839 | Tuesday, August 8, 2023 | Approved |
Chocolatey 2.2.0 | 3347095 | Wednesday, July 26, 2023 | Exempted |
Chocolatey 2.1.0 | 6328466 | Thursday, June 29, 2023 | Exempted |
Chocolatey 2.1.0-alpha-20230614 | 2196 | Wednesday, June 14, 2023 | Exempted |
Chocolatey 2.1.0-alpha-20230608 | 995 | Thursday, June 8, 2023 | Exempted |
Chocolatey 2.0.0 | 9675385 | Wednesday, May 31, 2023 | Exempted |
Chocolatey 2.0.0-beta-20230426 | 4117 | Wednesday, April 26, 2023 | Exempted |
Chocolatey 2.0.0-beta-20230412 | 1751 | Wednesday, April 12, 2023 | Exempted |
Chocolatey 2.0.0-beta-20230321 | 2044 | Tuesday, March 21, 2023 | Exempted |
Chocolatey 2.0.0-alpha-20230307 | 1329 | Tuesday, March 7, 2023 | Exempted |
Chocolatey 2.0.0-alpha-20230221 | 1156 | Tuesday, February 21, 2023 | Exempted |
Chocolatey 2.0.0-alpha-20230124 | 1187 | Tuesday, January 24, 2023 | Exempted |
Chocolatey 1.4.0 | 2792261 | Wednesday, May 10, 2023 | Exempted |
Chocolatey 1.3.1 | 5214482 | Tuesday, March 14, 2023 | Exempted |
Chocolatey 1.3.0 | 3246283 | Wednesday, February 15, 2023 | Exempted |
Chocolatey 1.2.1 | 6479178 | Tuesday, December 6, 2022 | Approved |
Chocolatey 1.2.0 | 1723892 | Wednesday, October 19, 2022 | Approved |
Chocolatey 1.1.0 | 8370645 | Wednesday, March 30, 2022 | Exempted |
Chocolatey 1.0.1 | 1055718 | Thursday, March 24, 2022 | Exempted |
Chocolatey 1.0.0 | 872778 | Monday, March 21, 2022 | Exempted |
Chocolatey 0.12.1 | 4191222 | Tuesday, January 25, 2022 | Exempted |
Chocolatey 0.12.0 | 1089168 | Tuesday, January 18, 2022 | Exempted |
Chocolatey 0.11.3 | 5643835 | Wednesday, October 27, 2021 | Exempted |
Chocolatey 0.11.2 | 6979553 | Thursday, September 23, 2021 | Exempted |
Chocolatey 0.11.1 | 3908014 | Thursday, September 2, 2021 | Exempted |
Chocolatey 0.10.16-beta-20200806 | 15142 | Thursday, August 6, 2020 | Approved |
Chocolatey 0.10.15 | 71778099 | Monday, June 3, 2019 | Approved |
Chocolatey 0.10.15-beta-20190531 | 1229 | Friday, May 31, 2019 | Approved |
Chocolatey 0.10.14 | 510580 | Thursday, May 30, 2019 | Approved |
Chocolatey 0.10.14-beta-20190418 | 5620 | Thursday, April 18, 2019 | Approved |
Chocolatey 0.10.14-beta-20190402 | 3083 | Tuesday, April 2, 2019 | Approved |
Chocolatey 0.10.14-beta-20190321 | 2612 | Friday, March 22, 2019 | Approved |
Chocolatey 0.10.13 | 7774130 | Friday, March 15, 2019 | Approved |
Chocolatey 0.10.12 | 152519 | Friday, March 15, 2019 | Approved |
Chocolatey 0.10.12-beta-20181011 | 15391 | Friday, October 12, 2018 | Approved |
Chocolatey 0.10.12-beta-20181009 | 939 | Tuesday, October 9, 2018 | Approved |
Chocolatey 0.10.11 | 29155870 | Friday, May 4, 2018 | Approved |
Chocolatey 0.10.10 | 2954433 | Thursday, April 12, 2018 | Approved |
Chocolatey 0.10.9 | 5427016 | Sunday, March 25, 2018 | Approved |
Chocolatey 0.10.9-beta-20180223 | 3790 | Friday, February 23, 2018 | Approved |
Chocolatey 0.10.8 | 24666989 | Wednesday, August 30, 2017 | Approved |
Chocolatey 0.10.8-beta-20170806 | 5287 | Monday, August 7, 2017 | Approved |
Chocolatey 0.10.7 | 18322139 | Thursday, June 8, 2017 | Approved |
Chocolatey 0.10.6.1 | 847880 | Saturday, June 3, 2017 | Approved |
Chocolatey 0.10.6 | 413351 | Thursday, June 1, 2017 | Approved |
Chocolatey 0.10.6-beta-20170531 | 1056 | Thursday, June 1, 2017 | Approved |
Chocolatey 0.10.6-beta-20170503 | 8275 | Wednesday, May 3, 2017 | Approved |
Chocolatey 0.10.5 | 18050507 | Thursday, March 30, 2017 | Approved |
Chocolatey 0.10.4 | 174326 | Thursday, March 30, 2017 | Approved |
Chocolatey 0.10.4-beta1-20170326 | 937 | Sunday, March 26, 2017 | Approved |
Chocolatey 0.10.4-beta1-20170323 | 789 | Thursday, March 23, 2017 | Approved |
Chocolatey 0.10.3 | 25541806 | Friday, October 7, 2016 | Approved |
Chocolatey 0.10.2 | 686080 | Friday, September 30, 2016 | Approved |
Chocolatey 0.10.1 | 2005653 | Monday, September 19, 2016 | Approved |
Chocolatey 0.10.0 | 3815928 | Thursday, August 11, 2016 | Approved |
Chocolatey 0.9.10.3 | 1920551 | Thursday, June 23, 2016 | Approved |
Chocolatey 0.9.10.2 | 3036 | Sunday, June 19, 2016 | Approved |
Chocolatey 0.9.10.1 | 963 | Saturday, June 18, 2016 | Approved |
Chocolatey 0.9.10 | 2402 | Friday, June 17, 2016 | Approved |
Chocolatey 0.9.10-rc1 | 714 | Monday, June 13, 2016 | Approved |
Chocolatey 0.9.10-beta-20160612 | 689 | Sunday, June 12, 2016 | Approved |
Chocolatey 0.9.10-beta-20160531 | 675 | Tuesday, May 31, 2016 | Approved |
Chocolatey 0.9.10-beta-20160528 | 639 | Saturday, May 28, 2016 | Approved |
Chocolatey 0.9.10-beta-20160527 | 717 | Friday, May 27, 2016 | Approved |
Chocolatey 0.9.10-beta-20160524 | 689 | Wednesday, May 25, 2016 | Approved |
Chocolatey 0.9.10-beta-20160509 | 789 | Monday, May 9, 2016 | Approved |
Chocolatey 0.9.10-beta-20160506 | 688 | Friday, May 6, 2016 | Approved |
Chocolatey 0.9.10-beta-20160505 | 641 | Thursday, May 5, 2016 | Approved |
Chocolatey 0.9.10-beta-20160503 | 675 | Tuesday, May 3, 2016 | Approved |
Chocolatey 0.9.10-beta-20160422 | 1051 | Friday, April 22, 2016 | Approved |
Chocolatey 0.9.10-beta-20160411 | 1208 | Monday, April 11, 2016 | Approved |
Chocolatey 0.9.10-beta-20160402 | 1119 | Saturday, April 2, 2016 | Approved |
Chocolatey 0.9.10-beta-20160330 | 692 | Thursday, March 31, 2016 | Exempted |
Chocolatey 0.9.10-beta-20160328 | 822 | Tuesday, March 29, 2016 | Approved |
Chocolatey 0.9.10-beta-20160325 | 847 | Friday, March 25, 2016 | Approved |
Chocolatey 0.9.10-beta-20160323 | 890 | Wednesday, March 23, 2016 | Approved |
Chocolatey 0.9.10-beta-20160322 | 653 | Wednesday, March 23, 2016 | Approved |
Chocolatey 0.9.10-beta-20160320 | 861 | Sunday, March 20, 2016 | Approved |
Chocolatey 0.9.10-beta-20160318 | 752 | Friday, March 18, 2016 | Approved |
Chocolatey 0.9.10-beta-20160314 | 892 | Monday, March 14, 2016 | Approved |
Chocolatey 0.9.10-beta-20160311 | 841 | Friday, March 11, 2016 | Approved |
Chocolatey 0.9.10-beta-20160302 | 1032 | Wednesday, March 2, 2016 | Approved |
Chocolatey 0.9.10-beta-20160215 | 1177 | Monday, February 15, 2016 | Approved |
Chocolatey 0.9.10-beta-20160212 | 979 | Friday, February 12, 2016 | Approved |
Chocolatey 0.9.10-beta-20160205 | 1080 | Friday, February 5, 2016 | Approved |
Chocolatey 0.9.9.12 | 387280 | Friday, March 18, 2016 | Approved |
Chocolatey 0.9.9.11 | 8574140 | Tuesday, October 6, 2015 | Approved |
Chocolatey 0.9.9.10 | 382234 | Saturday, October 3, 2015 | Approved |
Chocolatey 0.9.9.9 | 1252751 | Friday, October 2, 2015 | Approved |
Chocolatey 0.9.9.8 | 5627979 | Saturday, June 27, 2015 | Approved |
Chocolatey 0.9.9.7 | 194954 | Saturday, June 20, 2015 | Approved |
Chocolatey 0.9.9.6 | 831228 | Sunday, May 17, 2015 | Approved |
Chocolatey 0.9.9.5 | 546998 | Monday, April 20, 2015 | Approved |
Chocolatey 0.9.9.4 | 515989 | Monday, March 30, 2015 | Approved |
Chocolatey 0.9.9.3 | 3580 | Sunday, March 29, 2015 | Approved |
Chocolatey 0.9.9.2 | 25833 | Saturday, March 7, 2015 | Approved |
Chocolatey 0.9.9.1 | 8558 | Tuesday, March 3, 2015 | Approved |
Chocolatey 0.9.9 | 14646 | Tuesday, March 3, 2015 | Approved |
Chocolatey 0.9.9-rc9 | 878 | Saturday, February 28, 2015 | Approved |
Chocolatey 0.9.9-rc8 | 927 | Tuesday, February 24, 2015 | Approved |
Chocolatey 0.9.9-rc5 | 1112 | Monday, February 9, 2015 | Approved |
Chocolatey 0.9.9-rc4 | 787 | Sunday, February 8, 2015 | Approved |
Chocolatey 0.9.9-rc3 | 763 | Saturday, February 7, 2015 | Approved |
Chocolatey 0.9.9-rc2 | 729 | Friday, February 6, 2015 | Approved |
Chocolatey 0.9.9-rc1 | 755 | Wednesday, February 4, 2015 | Approved |
Chocolatey 0.9.9-beta3-20150204 | 705 | Wednesday, February 4, 2015 | Approved |
Chocolatey 0.9.9-beta2-20150202 | 770 | Monday, February 2, 2015 | Approved |
Chocolatey 0.9.9-beta-20150201 | 737 | Sunday, February 1, 2015 | Approved |
Chocolatey 0.9.9-alpha-20150201 | 739 | Sunday, February 1, 2015 | Approved |
Chocolatey 0.9.9-alpha-20150125 | 946 | Sunday, January 25, 2015 | Approved |
Chocolatey 0.9.8.33 | 1795256 | Wednesday, February 11, 2015 | Approved |
Chocolatey 0.9.8.32 | 263391 | Thursday, January 22, 2015 | Approved |
Chocolatey 0.9.8.31 | 190576 | Wednesday, January 7, 2015 | Approved |
Chocolatey 0.9.8.31-beta2 | 756 | Wednesday, January 7, 2015 | Approved |
Chocolatey 0.9.8.31-beta1 | 681 | Tuesday, January 6, 2015 | Approved |
Chocolatey 0.9.8.30-beta1 | 666 | Tuesday, January 6, 2015 | Approved |
Chocolatey 0.9.8.29 | 57042 | Friday, January 2, 2015 | Approved |
Chocolatey 0.9.8.29-beta2 | 682 | Friday, January 2, 2015 | Exempted |
Chocolatey 0.9.8.29-beta1 | 681 | Friday, January 2, 2015 | Exempted |
Chocolatey 0.9.8.29-alpha1 | 727 | Friday, January 2, 2015 | Exempted |
Chocolatey 0.9.8.28 | 812268 | Tuesday, November 4, 2014 | Approved |
Chocolatey 0.9.8.28-rc1 | 687 | Sunday, November 2, 2014 | Exempted |
Chocolatey 0.9.8.28-alpha3 | 1234 | Monday, October 6, 2014 | Approved |
Chocolatey 0.9.8.28-alpha2 | 1541 | Friday, August 1, 2014 | Approved |
Chocolatey 0.9.8.28-alpha1 | 771 | Wednesday, July 30, 2014 | Approved |
Chocolatey 0.9.8.27 | 1382145 | Monday, July 14, 2014 | Approved |
Chocolatey 0.9.8.27-beta1 | 701 | Sunday, July 13, 2014 | Approved |
Chocolatey 0.9.8.26 | 992 | Saturday, July 12, 2014 | Approved |
Chocolatey 0.9.8.26-alpha2 | 747 | Friday, July 11, 2014 | Approved |
Chocolatey 0.9.8.26-alpha1 | 764 | Friday, July 11, 2014 | Approved |
Chocolatey 0.9.8.25 | 39041 | Monday, July 7, 2014 | Approved |
Chocolatey 0.9.8.25-alpha1 | 785 | Saturday, July 5, 2014 | Approved |
Chocolatey 0.9.8.24 | 14028 | Thursday, July 3, 2014 | Approved |
Chocolatey 0.9.8.24-rc2 | 767 | Monday, June 30, 2014 | Approved |
Chocolatey 0.9.8.24-rc1 | 803 | Wednesday, June 25, 2014 | Approved |
Chocolatey 0.9.8.24-beta2 | 936 | Sunday, June 8, 2014 | Approved |
Chocolatey 0.9.8.24-beta1 | 1578 | Thursday, April 3, 2014 | Approved |
Chocolatey 0.9.8.24-alpha2 | 1013 | Sunday, March 2, 2014 | Approved |
Chocolatey 0.9.8.24-alpha1 | 868 | Tuesday, February 11, 2014 | Approved |
Chocolatey 0.9.8.23 | 525897 | Monday, November 11, 2013 | Approved |
Chocolatey 0.9.8.22 | 1505 | Monday, November 11, 2013 | Approved |
Chocolatey 0.9.8.22-alpha1 | 771 | Saturday, November 9, 2013 | Approved |
Chocolatey 0.9.8.21 | 4406 | Friday, November 8, 2013 | Approved |
Chocolatey 0.9.8.21-beta2 | 749 | Friday, November 8, 2013 | Approved |
Chocolatey 0.9.8.21-alpha7 | 1051 | Friday, August 23, 2013 | Approved |
Chocolatey 0.9.8.21-alpha6 | 749 | Thursday, August 22, 2013 | Approved |
Chocolatey 0.9.8.21-alpha5 | 732 | Wednesday, August 21, 2013 | Approved |
Chocolatey 0.9.8.21-alpha4 | 712 | Wednesday, August 21, 2013 | Approved |
Chocolatey 0.9.8.21-alpha3 | 889 | Tuesday, July 23, 2013 | Approved |
Chocolatey 0.9.8.21-alpha2 | 869 | Thursday, June 27, 2013 | Approved |
Chocolatey 0.9.8.21-alpha1 | 881 | Thursday, May 30, 2013 | Approved |
Chocolatey 0.9.8.20 | 331614 | Tuesday, December 11, 2012 | Approved |
Chocolatey 0.9.8.20-beta1 | 829 | Wednesday, December 5, 2012 | Approved |
Chocolatey 0.9.8.20-alpha3 | 845 | Friday, November 16, 2012 | Approved |
Chocolatey 0.9.8.20-alpha2 | 805 | Tuesday, October 16, 2012 | Approved |
Chocolatey 0.9.8.20-alpha1 | 841 | Sunday, September 16, 2012 | Approved |
Chocolatey 0.9.8.19 | 29993 | Monday, July 2, 2012 | Approved |
Chocolatey 0.9.8.19-alpha1 | 786 | Thursday, June 28, 2012 | Approved |
Chocolatey 0.9.8.18 | 2256 | Saturday, June 16, 2012 | Approved |
Chocolatey 0.9.8.17 | 1136 | Friday, June 15, 2012 | Approved |
Chocolatey 0.9.8.17-rc2 | 940 | Wednesday, June 13, 2012 | Approved |
Chocolatey 0.9.8.17-rc1 | 949 | Wednesday, June 13, 2012 | Approved |
Chocolatey 0.9.8.17-beta1 | 921 | Thursday, June 7, 2012 | Approved |
Chocolatey 0.9.8.16 | 7400 | Monday, February 27, 2012 | Approved |
Chocolatey 0.9.8.15 | 978 | Monday, February 27, 2012 | Approved |
Chocolatey 0.9.8.15-beta2 | 986 | Saturday, February 25, 2012 | Approved |
Chocolatey 0.9.8.14 | 2376 | Monday, February 6, 2012 | Approved |
Chocolatey 0.9.8.13 | 1932 | Sunday, January 8, 2012 | Approved |
Chocolatey 0.9.8.12 | 2094 | Sunday, November 20, 2011 | Approved |
Chocolatey 0.9.8.11 | 1944 | Friday, October 14, 2011 | Approved |
Chocolatey 0.9.8.10 | 1797 | Saturday, September 17, 2011 | Approved |
Chocolatey 0.9.8.9 | 1058 | Saturday, September 10, 2011 | Approved |
Chocolatey 0.9.8.8 | 914 | Saturday, September 10, 2011 | Approved |
Chocolatey 0.9.8.7 | 975 | Friday, September 2, 2011 | Approved |
Chocolatey 0.9.8.6 | 1811 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.8.5 | 959 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.8.4 | 1116 | 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 | 968 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.8 | 4063 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.7.3 | 1042 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.7.2 | 1007 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.7.1 | 1000 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.7 | 1020 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.6.4 | 967 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.6.3 | 958 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.6.2 | 993 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.6.1 | 1009 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.6.0 | 985 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.5.0 | 1038 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.4.0 | 1062 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.3.0 | 1007 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.2.0 | 983 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.1.0 | 1035 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.0.0 | 988 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.8.0.0 | 1067 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.7.0.0 | 1391 | Tuesday, August 23, 2011 | Approved |
RealDimensions Software, LLC - 2011-Present
See all - https://github.com/chocolatey/choco/blob/stable/CHANGELOG.md
0.9.10
What will be highlighted:
- Alternative sources (webpi, windowsfeature, cygwin, etc) are back (finally, right?)!
- Use an internal PowerShell host to take advantage of quite a few improvements!
- Introduce managing package templates, reintroduce extensions.
- Talk about using original download file name
- Talk about the improvements in search information
- Talk a little about what's coming with pro
BREAKING CHANGES
- Only fail automation scripts (chocolateyInstall.ps1) if the script returns non-zero exit code - see #445
- Fix - Force reinstall, force upgrade, and uninstall should delete the download cache - see #590
For 445 - the 0.9.8 series would only fail a package with terminating errors. The 0.9.9 series took that a bit further and started failing packages if anything wrote to stderr. It turns out that is a bad idea. Only when PowerShell exits with non-zero (which comes with terminating errors) should the package fail due to this. If you need the old behavior of the 0.9.9 series, you can get it back with a switch (--fail-on-standard-error
and its aliases) and/or a feature flip (failOnStandardError
).
For 590 - if you set a custom cache directory for downloads, it will no longer use a "chocolatey" subdirectory under that. You may need to make any adjustments if this is going to affect you.
KNOWN ISSUES
- Known Issues
- [POSH Host] The handle is invalid - when output is being redirected and a package attempts to write to a filestream - see #572
FEATURES
- Alternative Sources - see #14
- [POSH Host] Use Internal PowerShell Host - see #8
- Manage package templates with a specially named package and special package folder - see #542
- Use the actual download file name instead of providing one - see #435
- Support for custom headers - see #332
- [Security] Show moderation-related information in search results - see #493
- New Helper - Get-ToolsLocation helper (replacement for Get-BinRoot) - see #631
BUG FIXES
- [Security] Fix - Only load the Chocolatey PowerShell module from a known location - see #560
- [Security] Fix - Package source authentication at http://location/path doesn't also use http://location/ (base url) - see #466
- [Security] Fix - When defining a proxy without credentials - proxy password is shown in plain text - see #503
- Fix - Force should set allow-downgrade to true - see #585
- Fix - Do not use NuGet package cache - see #479
- Fix - Pack doesn't include chocolatey-specific metadata - see #607
- Fix - TEMP environment variable is 8.3 Path on some systems - see #532
- Fix -
$packageName
should be present for zip uninstalls in uninstall script template - see #534 - Fix - Debug/Verbose messages not logged in automation scripts (chocolateyInstall.ps1) - see #520
- Fix - Escape log output for variables that have data from external sources - see #565
- Fix - Choco new silentargs can't pass in args in the param=value format - see #510
- Fix - Exception if no source is enabled - see #490
- Fix - Chocolatey command help output written to standard error instead of standard out - see #468
- Fix - Logger doesn't clear cached NullLoggers - see #516
- Fix - DISM "/All" argument in the wrong position - see #480
- Fix - Pro - Installing/uninstalling extensions should rename files in use - see #594
- Fix - Running Get-FileName in PowerShell 5 fails and sometimes causes package errors - see #603
- Fix - Merging assemblies on a machine running .Net 4.5 or higher produces binaries incompatible with .Net 4 - see #392
- Fix - API - Incorrect log4net version in chocolatey.lib dependencies - see #390
- [POSH Host] Fix - Message after Download progress is on the same line sometimes - see #525
- [POSH Host] Fix - PowerShell internal process - "The handle is invalid." - see #526
- Fix - Verbose shows in output on debug switch - see #611
- Fix: Get-ChocolateyUnzip captures files that don't belong to the package - see #616
- Fix: Package succeeds but software install silently fails when Install-ChocolateyInstallPackage has the wrong arguments - see #629
IMPROVEMENTS
- AutoUninstaller is on by default - see #308
- Unset Configuration Values - see #551
- Ability to run "choco upgrade all" ignoring specific packages - see #293
- Extensions enhancements - see #588
- Show human-readable file sizes when downloading - see #363
- [Security] Warn about environment changes - see #563
- Warn when execution timeout has elapsed - see #561
- Update nuspec to make it easier to get started - see #535
- Suppress verbose output to verbose - like with 7-zip - see #476
- Choco push moderation message only on push to dot org - see #601
- Allow tools/bin root to be root of the drive again - see #628
- Pro - Also check for license in User Profile location - see #606
- Pro - Set download cache information if available - see #562
- Pro - Allow commands to be added - see #583
- Pro - Load/Provide hooks for licensed version - see #584
- Pro - On valid license, add pro/business source automatically - see #604
- API - Add the ability to retrieve package count for a Source - see #431
- API - Chocolatey Lib still marks vital package information as internal - see #433
- API - Add paging to list command - see #427
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.