Add ToolsRoot so Chocolatey_Bin_Root is \tools
This commit is contained in:
		
							
								
								
									
										19
									
								
								ToolsRoot/ToolsRoot.nuspec
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								ToolsRoot/ToolsRoot.nuspec
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | ||||
| <?xml version="1.0"?> | ||||
| <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> | ||||
|     <metadata> | ||||
|         <id>toolsroot</id> | ||||
|         <version>0.1.0</version> | ||||
|         <title>Tools Root</title> | ||||
|         <authors>Ethan J. Brown</authors> | ||||
|         <owners>Ethan J. Brown</owners> | ||||
|         <!--<iconUrl></iconUrl>--> | ||||
|         <requireLicenseAcceptance>false</requireLicenseAcceptance> | ||||
|         <description>Set's the chocolatey_bin_root environment variable to a default value of '\tools' if not already set. This allows packages such as Ruby, Python etc. to install in \tools instead of the system root. | ||||
|         </description> | ||||
|         <summary>Sets the chocolatey_bin_root default value to \tools.</summary> | ||||
|         <tags>path</tags> | ||||
|         <!--<dependencies> | ||||
|       <dependency id="" version="" /> | ||||
|     </dependencies>--> | ||||
|   </metadata> | ||||
| </package> | ||||
							
								
								
									
										22
									
								
								ToolsRoot/tools/chocolateyInstall.ps1
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								ToolsRoot/tools/chocolateyInstall.ps1
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,22 @@ | ||||
| $packageName = 'ToolsRoot' | ||||
|  | ||||
| try | ||||
| { | ||||
|   $variableName = 'Chocolatey_Bin_Root' | ||||
|   if (!(Get-Item Env:$variableName -ErrorAction SilentlyContinue)) | ||||
|   { | ||||
|     $path = '\tools' | ||||
|     [Environment]::SetEnvironmentVariable($variableName, $path, 'User') | ||||
|     Set-Item Env:$variableName $path | ||||
|  | ||||
|     $binRoot = Join-Path $Env:SystemDrive $path | ||||
|     Write-Host "Configured $variableName as $binRoot" | ||||
|   } | ||||
|  | ||||
|   Write-ChocolateySuccess $package | ||||
| } | ||||
| catch | ||||
| { | ||||
|   Write-ChocolateyFailure $package "$($_.Exception.Message)" | ||||
|   throw | ||||
| } | ||||
							
								
								
									
										23
									
								
								ToolsRoot/tools/chocolateyUninstall.ps1
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								ToolsRoot/tools/chocolateyUninstall.ps1
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| $package = 'ToolsRoot' | ||||
|  | ||||
| try | ||||
| { | ||||
|   $variableName = 'Chocolatey_Bin_Root' | ||||
|   $binRoot = Get-Item Env:$variableName -ErrorAction SilentlyContinue | | ||||
|     Select -ExpandProperty Value -First 1 | ||||
|  | ||||
|   if ($binRoot) | ||||
|   { | ||||
|     [Environment]::SetEnvironmentVariable($variableName, '', 'User') | ||||
|     Set-Item Env:$variableName $null | ||||
|  | ||||
|     Write-Host "Removed $variableName [was $binRoot]" | ||||
|   } | ||||
|  | ||||
|   Write-ChocolateySuccess $package | ||||
| } | ||||
| catch | ||||
| { | ||||
|   Write-ChocolateyFailure $package "$($_.Exception.Message)" | ||||
|   throw | ||||
| } | ||||
		Reference in New Issue
	
	Block a user