windows下安装使用Chocolatey

Chocolatey是windows下的一种包管理器,它可以让我们体验到在linux系统下安装包一样方便快捷,可以用cmdpowershell安装。

安装

注意:下面方法都需要管理员权限下进行安装。

  1. cmd
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
  1. PowerShell
    这里要先运行下Get-ExecutionPolicy,如果返回Restricted,那么需要运行Set-ExecutionPolicy AllSigned或者Set-ExecutionPolicy Bypass -Scope Process
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

使用

# 查看版本
choco -V 
# 确认
choco -y, --yes, --confirm
# 更多查看帮助菜单的
choco -?, --help, -h
# 安装软件包
choco install package_name
choco install git
# 或者
cinst package_name
# 卸载软件包
choco uninstall package_name 
choco uninstall git
# 或者
cuninst package_name

# 升级
choco upgrade package_name

例子

choco install sysinternals
choco install notepadplusplus googlechrome atom 7zip
choco install notepadplusplus --force --force-dependencies
choco install notepadplusplus googlechrome atom 7zip -dvfy
choco install git -y --params="'/GitAndUnixToolsOnPath /NoAutoCrlf'"
choco install git -y --params="'/GitAndUnixToolsOnPath /NoAutoCrlf'" --install-args="'/DIR=C:\git'"
# Params are package parameters, passed to the package
# Install args are installer arguments, appended to the silentArgs
#  in the package for the installer itself
choco install nodejs.install --version 0.10.35
choco install git -s "'https://somewhere/out/there'"
choco install git -s "'https://somewhere/protected'" -u user -p pass

代理设置

$env:chocolateyProxyLocation = 'https://local/proxy/server'
#$env:chocolateyProxyUser = 'username'
#$env:chocolateyProxyPassword = 'password'
# install script

# 详情参考 https://chocolatey.org/docs/proxy-settings-for-chocolatey

更多用法直接查看 官方文档.

你可能感兴趣的:(开发工具)