Downloads:
348,561,652
Downloads of v 0.9.10-beta-20160212:
984
Last Update:
12 Feb 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-20160212 | Updated: 12 Feb 2016
- Software Specific:
- Software Site
- Software License
- Package Specific:
- Package outdated?
- Package broken?
- Contact Maintainers
- Contact Site Admins
- Software Vendor?
- Report Abuse
- Download
Downloads:
348,561,652
Downloads of v 0.9.10-beta-20160212:
984
Maintainer(s):
Software Author(s):
- Rob Reynolds
- The Chocolatey Team
Chocolatey 0.9.10-beta-20160212
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 12 Feb 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: 8F20A1CE1209BF9F12DC6F6DFD59943F | sha1: D2AD1BCDB5262F41C9FA712F2F5317AE86A2D4D9 | sha256: C366EB48FC9CE314AD10CFEC8F27CABCAB85B2DD57CC5C280E5B94E667C53E31 | sha512: 79043AC1182C316E33E31C43000BBFBA7B9C74BEFCE7107AB78EC3CD3EFB77723AFCF7FFF4C5DEE16243663D9811DBE0A6A8997D580A22646CFFC8F03E68DD55
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 = 32
if ($bitWidth -eq 64 -and $url64bit -ne $null -and $url64bit -ne '') {
Write-Debug "Setting url to '$url64bit' and bitPackage to $bitWidth"
$bitPackage = $bitWidth
$url = $url64bit;
# only set if urls are different
if ($url32bit -ne $url64bit) {
$checksum = $checksum64
if ($checkSumType64 -ne '') {
$checksumType = $checksumType64
}
}
}
$forceX86 = $env:chocolateyForceX86;
if ($forceX86) {
Write-Debug "User specified -x86 so forcing 32 bit"
$bitPackage = 32
$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 bit
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();
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: 5E8B1F21584079E900245585ED3F126D | sha1: EA630F6189BE18F00611B8A0A39EC21081824F06 | sha256: 5B7D746BE695B0DED61ABEEC31E85EA07CD3EFEAB2CAFB9A786F8FC57F189C41 | sha512: CD68CD520384D031169C3C31D31F957FDEA913670E9826242A6FC49B65E3147AF66B883999D0AF2F61BD17084B261FAFD36886E10ED348606D1BACE65352877F
md5: 5032AA9E2916CFD432A2ACF3CFAE7C68 | sha1: 809A309651AB5879E62620112F3D852652F64190 | sha256: 813ABF87EB71B58873FC2399563A0840191C032EB791B6509FD83C67E981CFA9 | sha512: D2B08E71262D9D4C8C5810E0DB804961092B98B7A5B02B7B736392F562CDD9B81C4674DDCB73770F9F3C6CCADD8AB0C7FB99B2C28E462C86A4FC2978EDA241F9
md5: EE5A4885ACF64550A9138A03DD8C72F6 | sha1: 314DF7BDC96F039F4E2F1FC5DE3D1C84C1452558 | sha256: A934ABD9613740403CCB498D45150F0BBA5B56D71D375BDF8DD7BC962D4EFEFA | sha512: 22330E85384268AA7D73F0D01A8F61799EA9D8A20ECC7921CF631B2DD273A6819B3C4FBBF896A6583776A6DD307862913FFD99D1860E50A52577B793F70FC398
md5: E06E3F081E37533C7915D94C85E117FF | sha1: C3AD89EE21E9D039BA795817B38A7DAC9E7FE830 | sha256: 8054E61031D13760310A217B88F548387F188FD1C0E10DD221114B9B5FED018F | sha512: 91B2F601BD0799587DFA07FC188BDE3DA3D248DEB1E5BB1878FCCD12B67BD7D91469168B2616664EAD38D8B0266A09E05D0931C6559A1209200CEB14966FC62E
md5: 1B011799F987B8C57332FC582833998A | sha1: 250C03D431150BAD04D26C2BB6B1C2DC356EB394 | sha256: E954DF0EBAFF40AD798A0F546100591FB840412E5F680E5E5A981B5B76EAD71E | sha512: 603DAB2ABA2E27513DB39B827258F4075F6C1F8AE0F77A6A399E4676F7E896E34B07BA3CAE582B3CA1AD0CA3AB4305458E7E57364246865DB2894F72FD2D197B
md5: 6BD3213936F0CDA6CCD17DBF4DEA345E | sha1: D52F928174E5579A13C948D8F64CBB534EB91218 | sha256: 1A524AE602F604DAF580D302A43B8E280C30EC515FDD0736AB1E6F610444A1B8 | sha512: 76E909861A3942F2D3CD02D4ACDE13AA284F279327E807D01541BC790FA21CC4241E3011AC9C6F0D93DC104DB9121FF8FF497E8EA41C05669DB4A4931EADB6FA
md5: 9F47F8A73159BAEC52169FEB2EA169FC | sha1: 8425326C9A9A5E1705A6FEBC215A3A56D7FF4E64 | sha256: 66E7EF5EE18E20C37905EAD289836D17232B17C5902388719D61F50A4AB98A4E | sha512: 75E87BB20A2FBC5E7B62F1D485EE4C5CDE5C8945CE2B445F7856E532A4FE01E71174822BDB38D7ABB2CC21817D4FA973B5EE7AFF22CDEA7391CA10727D315301
md5: 7652FCD7C0CBC556743D008A041F3513 | sha1: DC5D613D61144C776E81987F6276E5BD09B73D86 | sha256: 0001FAE6C0E80C3A9C1CAA18F513AA34F2EB5423EABADF90D85C5708FE1615DD | sha512: 15ECDE398D4ED7707963CE91CD824CC9F239AB45F9F875F5EAEB27823BDBCA5E56EE0A8F4911B50C8AC6FA34762CD97DF63C213AADAABA920CA67BDCD2287CFF
md5: A4859D16E178CE253AEFB73C2EE55A64 | sha1: BF638672DCF21F5C260D457CC12D04473E0ABFDB | sha256: 71150D734CFF89D993F13ABB084A50AF08FE98867E4C35856CCFF36DCA0BA217 | sha512: A3F006E296A85191C766404E85A3D039B05ED3BCFDFBAFB10991EBAFD1F19A80521A4D685D506A861C1325EB2B0A1166916ABFB2799AB8EE004B6DCDE254EE94
@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: EEF0CB5CB3887B8B50A0FDAF5DA57572 | sha1: 2235CC0AD8DDC5196F908E04722995FABB6AFB9D | sha256: F4A1DCE9F4945DC4914AD9F8F93F2B667C200D9026392E3FA77E4110E0308047 | sha512: 297395E7FE128B89E13FFD6BFAD521CE553FA0A8DF8EEFBA06941E01172B393889E54CF2B1B4358E3357EFB78C237A2F83CD98CE5DFE2E06AC2C6BB90F507BF5
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
- choco.exe (5b7d746be695) - ## / 55
- chocolatey.exe (813abf87eb71) - ## / 56
- cinst.exe (a934abd96137) - ## / 57
- clist.exe (8054e61031d1) - ## / 57
- cpack.exe (e954df0ebaff) - ## / 57
- cpush.exe (1a524ae602f6) - ## / 57
- cuninst.exe (66e7ef5ee18e) - ## / 56
- cup.exe (0001fae6c0e8) - ## / 57
- cver.exe (71150d734cff) - ## / 57
- shimgen.exe (f4a1dce9f494) - ## / 55
- chocolatey.0.9.10-beta-20160212.nupkg (c57e5f0edad7) - ## / 57
- choco.exe (c366eb48fc9c) - ## / 56
In cases where actual malware is found, the packages are subject to removal. Software sometimes has false positives. Moderators do not necessarily validate the safety of the underlying software, only that a package retrieves software from the official distribution point and/or validate embedded software against official distribution point (where distribution rights allow redistribution).
Chocolatey Pro provides runtime protection from possible malware.
Version | Downloads | Last Updated | Status |
---|---|---|---|
Chocolatey 2.4.1 | 2286456 | Wednesday, December 4, 2024 | Exempted |
Chocolatey 2.4.0 | 2424690 | Tuesday, November 12, 2024 | Approved |
Chocolatey 2.3.0 | 8988843 | Wednesday, June 5, 2024 | Approved |
Chocolatey 2.2.2 | 25330217 | Tuesday, August 8, 2023 | Approved |
Chocolatey 2.2.0 | 3347120 | Wednesday, July 26, 2023 | Exempted |
Chocolatey 2.1.0 | 6328513 | Thursday, June 29, 2023 | Exempted |
Chocolatey 2.1.0-alpha-20230614 | 2198 | Wednesday, June 14, 2023 | Exempted |
Chocolatey 2.1.0-alpha-20230608 | 999 | Thursday, June 8, 2023 | Exempted |
Chocolatey 2.0.0 | 9675565 | Wednesday, May 31, 2023 | Exempted |
Chocolatey 2.0.0-beta-20230426 | 4120 | Wednesday, April 26, 2023 | Exempted |
Chocolatey 2.0.0-beta-20230412 | 1751 | Wednesday, April 12, 2023 | Exempted |
Chocolatey 2.0.0-beta-20230321 | 2049 | Tuesday, March 21, 2023 | Exempted |
Chocolatey 2.0.0-alpha-20230307 | 1335 | Tuesday, March 7, 2023 | Exempted |
Chocolatey 2.0.0-alpha-20230221 | 1161 | Tuesday, February 21, 2023 | Exempted |
Chocolatey 2.0.0-alpha-20230124 | 1190 | Tuesday, January 24, 2023 | Exempted |
Chocolatey 1.4.1 | 39 | Wednesday, December 4, 2024 | Exempted |
Chocolatey 1.4.0 | 2809740 | Wednesday, May 10, 2023 | Exempted |
Chocolatey 1.3.1 | 5214512 | Tuesday, March 14, 2023 | Exempted |
Chocolatey 1.3.0 | 3246302 | Wednesday, February 15, 2023 | Exempted |
Chocolatey 1.2.1 | 6479208 | Tuesday, December 6, 2022 | Approved |
Chocolatey 1.2.0 | 1724727 | Wednesday, October 19, 2022 | Approved |
Chocolatey 1.1.0 | 8370914 | Wednesday, March 30, 2022 | Exempted |
Chocolatey 1.0.1 | 1055775 | Thursday, March 24, 2022 | Exempted |
Chocolatey 1.0.0 | 872791 | Monday, March 21, 2022 | Exempted |
Chocolatey 0.12.1 | 4191239 | Tuesday, January 25, 2022 | Exempted |
Chocolatey 0.12.0 | 1089174 | Tuesday, January 18, 2022 | Exempted |
Chocolatey 0.11.3 | 5643913 | Wednesday, October 27, 2021 | Exempted |
Chocolatey 0.11.2 | 6979568 | Thursday, September 23, 2021 | Exempted |
Chocolatey 0.11.1 | 3908017 | Thursday, September 2, 2021 | Exempted |
Chocolatey 0.10.16-beta-20200806 | 15152 | Thursday, August 6, 2020 | Approved |
Chocolatey 0.10.15 | 71782664 | Monday, June 3, 2019 | Approved |
Chocolatey 0.10.15-beta-20190531 | 1237 | Friday, May 31, 2019 | Approved |
Chocolatey 0.10.14 | 510588 | Thursday, May 30, 2019 | Approved |
Chocolatey 0.10.14-beta-20190418 | 5625 | Thursday, April 18, 2019 | Approved |
Chocolatey 0.10.14-beta-20190402 | 3089 | Tuesday, April 2, 2019 | Approved |
Chocolatey 0.10.14-beta-20190321 | 2616 | Friday, March 22, 2019 | Approved |
Chocolatey 0.10.13 | 7774259 | Friday, March 15, 2019 | Approved |
Chocolatey 0.10.12 | 152521 | Friday, March 15, 2019 | Approved |
Chocolatey 0.10.12-beta-20181011 | 15401 | Friday, October 12, 2018 | Approved |
Chocolatey 0.10.12-beta-20181009 | 945 | Tuesday, October 9, 2018 | Approved |
Chocolatey 0.10.11 | 29156050 | Friday, May 4, 2018 | Approved |
Chocolatey 0.10.10 | 2954436 | Thursday, April 12, 2018 | Approved |
Chocolatey 0.10.9 | 5427022 | Sunday, March 25, 2018 | Approved |
Chocolatey 0.10.9-beta-20180223 | 3795 | Friday, February 23, 2018 | Approved |
Chocolatey 0.10.8 | 24667003 | Wednesday, August 30, 2017 | Approved |
Chocolatey 0.10.8-beta-20170806 | 5290 | Monday, August 7, 2017 | Approved |
Chocolatey 0.10.7 | 18322144 | Thursday, June 8, 2017 | Approved |
Chocolatey 0.10.6.1 | 847886 | Saturday, June 3, 2017 | Approved |
Chocolatey 0.10.6 | 413356 | Thursday, June 1, 2017 | Approved |
Chocolatey 0.10.6-beta-20170531 | 1062 | Thursday, June 1, 2017 | Approved |
Chocolatey 0.10.6-beta-20170503 | 8283 | Wednesday, May 3, 2017 | Approved |
Chocolatey 0.10.5 | 18050513 | Thursday, March 30, 2017 | Approved |
Chocolatey 0.10.4 | 174335 | Thursday, March 30, 2017 | Approved |
Chocolatey 0.10.4-beta1-20170326 | 939 | Sunday, March 26, 2017 | Approved |
Chocolatey 0.10.4-beta1-20170323 | 792 | Thursday, March 23, 2017 | Approved |
Chocolatey 0.10.3 | 25541814 | Friday, October 7, 2016 | Approved |
Chocolatey 0.10.2 | 686085 | Friday, September 30, 2016 | Approved |
Chocolatey 0.10.1 | 2005661 | Monday, September 19, 2016 | Approved |
Chocolatey 0.10.0 | 3815932 | Thursday, August 11, 2016 | Approved |
Chocolatey 0.9.10.3 | 1920556 | Thursday, June 23, 2016 | Approved |
Chocolatey 0.9.10.2 | 3042 | Sunday, June 19, 2016 | Approved |
Chocolatey 0.9.10.1 | 968 | Saturday, June 18, 2016 | Approved |
Chocolatey 0.9.10 | 2436 | Friday, June 17, 2016 | Approved |
Chocolatey 0.9.10-rc1 | 717 | Monday, June 13, 2016 | Approved |
Chocolatey 0.9.10-beta-20160612 | 691 | Sunday, June 12, 2016 | Approved |
Chocolatey 0.9.10-beta-20160531 | 678 | Tuesday, May 31, 2016 | Approved |
Chocolatey 0.9.10-beta-20160528 | 642 | Saturday, May 28, 2016 | Approved |
Chocolatey 0.9.10-beta-20160527 | 721 | Friday, May 27, 2016 | Approved |
Chocolatey 0.9.10-beta-20160524 | 690 | Wednesday, May 25, 2016 | Approved |
Chocolatey 0.9.10-beta-20160509 | 795 | Monday, May 9, 2016 | Approved |
Chocolatey 0.9.10-beta-20160506 | 694 | Friday, May 6, 2016 | Approved |
Chocolatey 0.9.10-beta-20160505 | 647 | Thursday, May 5, 2016 | Approved |
Chocolatey 0.9.10-beta-20160503 | 679 | Tuesday, May 3, 2016 | Approved |
Chocolatey 0.9.10-beta-20160422 | 1057 | Friday, April 22, 2016 | Approved |
Chocolatey 0.9.10-beta-20160411 | 1213 | Monday, April 11, 2016 | Approved |
Chocolatey 0.9.10-beta-20160402 | 1126 | Saturday, April 2, 2016 | Approved |
Chocolatey 0.9.10-beta-20160330 | 693 | Thursday, March 31, 2016 | Exempted |
Chocolatey 0.9.10-beta-20160328 | 829 | Tuesday, March 29, 2016 | Approved |
Chocolatey 0.9.10-beta-20160325 | 855 | Friday, March 25, 2016 | Approved |
Chocolatey 0.9.10-beta-20160323 | 892 | Wednesday, March 23, 2016 | Approved |
Chocolatey 0.9.10-beta-20160322 | 658 | Wednesday, March 23, 2016 | Approved |
Chocolatey 0.9.10-beta-20160320 | 866 | Sunday, March 20, 2016 | Approved |
Chocolatey 0.9.10-beta-20160318 | 754 | Friday, March 18, 2016 | Approved |
Chocolatey 0.9.10-beta-20160314 | 898 | Monday, March 14, 2016 | Approved |
Chocolatey 0.9.10-beta-20160311 | 844 | Friday, March 11, 2016 | Approved |
Chocolatey 0.9.10-beta-20160302 | 1037 | Wednesday, March 2, 2016 | Approved |
Chocolatey 0.9.10-beta-20160215 | 1179 | Monday, February 15, 2016 | Approved |
Chocolatey 0.9.10-beta-20160212 | 984 | Friday, February 12, 2016 | Approved |
Chocolatey 0.9.10-beta-20160205 | 1086 | Friday, February 5, 2016 | Approved |
Chocolatey 0.9.9.12 | 387288 | Friday, March 18, 2016 | Approved |
Chocolatey 0.9.9.11 | 8574145 | Tuesday, October 6, 2015 | Approved |
Chocolatey 0.9.9.10 | 382235 | Saturday, October 3, 2015 | Approved |
Chocolatey 0.9.9.9 | 1252757 | Friday, October 2, 2015 | Approved |
Chocolatey 0.9.9.8 | 5627979 | Saturday, June 27, 2015 | Approved |
Chocolatey 0.9.9.7 | 194957 | Saturday, June 20, 2015 | Approved |
Chocolatey 0.9.9.6 | 831228 | Sunday, May 17, 2015 | Approved |
Chocolatey 0.9.9.5 | 547002 | Monday, April 20, 2015 | Approved |
Chocolatey 0.9.9.4 | 515994 | Monday, March 30, 2015 | Approved |
Chocolatey 0.9.9.3 | 3587 | Sunday, March 29, 2015 | Approved |
Chocolatey 0.9.9.2 | 25839 | Saturday, March 7, 2015 | Approved |
Chocolatey 0.9.9.1 | 8561 | Tuesday, March 3, 2015 | Approved |
Chocolatey 0.9.9 | 14653 | Tuesday, March 3, 2015 | Approved |
Chocolatey 0.9.9-rc9 | 882 | Saturday, February 28, 2015 | Approved |
Chocolatey 0.9.9-rc8 | 931 | Tuesday, February 24, 2015 | Approved |
Chocolatey 0.9.9-rc5 | 1113 | Monday, February 9, 2015 | Approved |
Chocolatey 0.9.9-rc4 | 789 | Sunday, February 8, 2015 | Approved |
Chocolatey 0.9.9-rc3 | 766 | Saturday, February 7, 2015 | Approved |
Chocolatey 0.9.9-rc2 | 732 | Friday, February 6, 2015 | Approved |
Chocolatey 0.9.9-rc1 | 758 | Wednesday, February 4, 2015 | Approved |
Chocolatey 0.9.9-beta3-20150204 | 709 | Wednesday, February 4, 2015 | Approved |
Chocolatey 0.9.9-beta2-20150202 | 772 | Monday, February 2, 2015 | Approved |
Chocolatey 0.9.9-beta-20150201 | 741 | Sunday, February 1, 2015 | Approved |
Chocolatey 0.9.9-alpha-20150201 | 744 | Sunday, February 1, 2015 | Approved |
Chocolatey 0.9.9-alpha-20150125 | 947 | Sunday, January 25, 2015 | Approved |
Chocolatey 0.9.8.33 | 1795261 | Wednesday, February 11, 2015 | Approved |
Chocolatey 0.9.8.32 | 263395 | Thursday, January 22, 2015 | Approved |
Chocolatey 0.9.8.31 | 190580 | Wednesday, January 7, 2015 | Approved |
Chocolatey 0.9.8.31-beta2 | 763 | Wednesday, January 7, 2015 | Approved |
Chocolatey 0.9.8.31-beta1 | 685 | Tuesday, January 6, 2015 | Approved |
Chocolatey 0.9.8.30-beta1 | 670 | Tuesday, January 6, 2015 | Approved |
Chocolatey 0.9.8.29 | 57047 | Friday, January 2, 2015 | Approved |
Chocolatey 0.9.8.29-beta2 | 685 | Friday, January 2, 2015 | Exempted |
Chocolatey 0.9.8.29-beta1 | 684 | Friday, January 2, 2015 | Exempted |
Chocolatey 0.9.8.29-alpha1 | 727 | Friday, January 2, 2015 | Exempted |
Chocolatey 0.9.8.28 | 812271 | Tuesday, November 4, 2014 | Approved |
Chocolatey 0.9.8.28-rc1 | 691 | Sunday, November 2, 2014 | Exempted |
Chocolatey 0.9.8.28-alpha3 | 1239 | Monday, October 6, 2014 | Approved |
Chocolatey 0.9.8.28-alpha2 | 1543 | Friday, August 1, 2014 | Approved |
Chocolatey 0.9.8.28-alpha1 | 773 | Wednesday, July 30, 2014 | Approved |
Chocolatey 0.9.8.27 | 1382148 | Monday, July 14, 2014 | Approved |
Chocolatey 0.9.8.27-beta1 | 705 | Sunday, July 13, 2014 | Approved |
Chocolatey 0.9.8.26 | 995 | Saturday, July 12, 2014 | Approved |
Chocolatey 0.9.8.26-alpha2 | 752 | Friday, July 11, 2014 | Approved |
Chocolatey 0.9.8.26-alpha1 | 769 | Friday, July 11, 2014 | Approved |
Chocolatey 0.9.8.25 | 39041 | Monday, July 7, 2014 | Approved |
Chocolatey 0.9.8.25-alpha1 | 788 | Saturday, July 5, 2014 | Approved |
Chocolatey 0.9.8.24 | 14032 | Thursday, July 3, 2014 | Approved |
Chocolatey 0.9.8.24-rc2 | 772 | Monday, June 30, 2014 | Approved |
Chocolatey 0.9.8.24-rc1 | 805 | Wednesday, June 25, 2014 | Approved |
Chocolatey 0.9.8.24-beta2 | 939 | Sunday, June 8, 2014 | Approved |
Chocolatey 0.9.8.24-beta1 | 1583 | Thursday, April 3, 2014 | Approved |
Chocolatey 0.9.8.24-alpha2 | 1017 | Sunday, March 2, 2014 | Approved |
Chocolatey 0.9.8.24-alpha1 | 874 | Tuesday, February 11, 2014 | Approved |
Chocolatey 0.9.8.23 | 525902 | Monday, November 11, 2013 | Approved |
Chocolatey 0.9.8.22 | 1505 | Monday, November 11, 2013 | Approved |
Chocolatey 0.9.8.22-alpha1 | 773 | Saturday, November 9, 2013 | Approved |
Chocolatey 0.9.8.21 | 4409 | Friday, November 8, 2013 | Approved |
Chocolatey 0.9.8.21-beta2 | 753 | Friday, November 8, 2013 | Approved |
Chocolatey 0.9.8.21-alpha7 | 1055 | Friday, August 23, 2013 | Approved |
Chocolatey 0.9.8.21-alpha6 | 751 | Thursday, August 22, 2013 | Approved |
Chocolatey 0.9.8.21-alpha5 | 734 | Wednesday, August 21, 2013 | Approved |
Chocolatey 0.9.8.21-alpha4 | 718 | Wednesday, August 21, 2013 | Approved |
Chocolatey 0.9.8.21-alpha3 | 894 | Tuesday, July 23, 2013 | Approved |
Chocolatey 0.9.8.21-alpha2 | 873 | Thursday, June 27, 2013 | Approved |
Chocolatey 0.9.8.21-alpha1 | 887 | Thursday, May 30, 2013 | Approved |
Chocolatey 0.9.8.20 | 331619 | Tuesday, December 11, 2012 | Approved |
Chocolatey 0.9.8.20-beta1 | 833 | Wednesday, December 5, 2012 | Approved |
Chocolatey 0.9.8.20-alpha3 | 847 | Friday, November 16, 2012 | Approved |
Chocolatey 0.9.8.20-alpha2 | 807 | Tuesday, October 16, 2012 | Approved |
Chocolatey 0.9.8.20-alpha1 | 846 | Sunday, September 16, 2012 | Approved |
Chocolatey 0.9.8.19 | 29999 | Monday, July 2, 2012 | Approved |
Chocolatey 0.9.8.19-alpha1 | 791 | Thursday, June 28, 2012 | Approved |
Chocolatey 0.9.8.18 | 2260 | Saturday, June 16, 2012 | Approved |
Chocolatey 0.9.8.17 | 1141 | Friday, June 15, 2012 | Approved |
Chocolatey 0.9.8.17-rc2 | 950 | Wednesday, June 13, 2012 | Approved |
Chocolatey 0.9.8.17-rc1 | 950 | Wednesday, June 13, 2012 | Approved |
Chocolatey 0.9.8.17-beta1 | 927 | Thursday, June 7, 2012 | Approved |
Chocolatey 0.9.8.16 | 7405 | Monday, February 27, 2012 | Approved |
Chocolatey 0.9.8.15 | 984 | Monday, February 27, 2012 | Approved |
Chocolatey 0.9.8.15-beta2 | 993 | Saturday, February 25, 2012 | Approved |
Chocolatey 0.9.8.14 | 2378 | Monday, February 6, 2012 | Approved |
Chocolatey 0.9.8.13 | 1936 | Sunday, January 8, 2012 | Approved |
Chocolatey 0.9.8.12 | 2100 | Sunday, November 20, 2011 | Approved |
Chocolatey 0.9.8.11 | 1948 | Friday, October 14, 2011 | Approved |
Chocolatey 0.9.8.10 | 1802 | Saturday, September 17, 2011 | Approved |
Chocolatey 0.9.8.9 | 1060 | Saturday, September 10, 2011 | Approved |
Chocolatey 0.9.8.8 | 918 | Saturday, September 10, 2011 | Approved |
Chocolatey 0.9.8.7 | 977 | Friday, September 2, 2011 | Approved |
Chocolatey 0.9.8.6 | 1814 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.8.5 | 964 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.8.4 | 1120 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.8.3 | 972 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.8.2 | 1174 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.8.1 | 972 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.8 | 4065 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.7.3 | 1043 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.7.2 | 1011 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.7.1 | 1001 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.7 | 1023 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.6.4 | 970 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.6.3 | 960 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.6.2 | 993 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.6.1 | 1013 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.6.0 | 987 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.5.0 | 1039 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.4.0 | 1066 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.3.0 | 1008 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.2.0 | 987 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.1.0 | 1044 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.9.0.0 | 997 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.8.0.0 | 1069 | Tuesday, August 23, 2011 | Approved |
Chocolatey 0.7.0.0 | 1395 | Tuesday, August 23, 2011 | Approved |
RealDimensions Software, LLC - 2011-Present
See all - https://github.com/chocolatey/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.