iT邦幫忙

2017 iT 邦幫忙鐵人賽
DAY 30
0
自我挑戰組

全端工程師的日常挑戰三十日系列 第 31

Chocolatey 設定需驗證代理伺服器(proxy with authentication)

Chocolatey 設定需驗證代理伺服器(proxy with authentication)

身為一個 windows 開發人員是不是有時會想把 nuget 功能擴大到 Visual Studio 之外的地方呢?!像 NPM 一樣,只要有 command line 就可以安裝程式,還不限於 Visual Studio 的相關功能?!Chocolatey 就可以達到這個目標了!

#安裝

  1. commnad line(Cmd.exe)
    @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

  2. commnad line(Cmd.exe) behind proxy
    @powershell -NoProfile -ExecutionPolicy Bypass -Command "[System.Net.WebRequest]::DefaultWebProxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH="%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

  3. powershell
    下載 install.ps1, 執行安裝

設定

1.Command Line

```
choco config set proxy http://proxyserver:proxyport  
choco config set proxyUser UserName   
choco config set proxyPassword password
```

setting

2.PowerShell

  • 2-1. 開啟 PowerShell Commnand Line
  • 2-2. 依序設定
    $env:chocolateyProxyLocation='http://proxyserver:proxyport'
    $env:chocolateyProxyUser = 'AD\UserName'
    $env:chocolateyProxyPassword = 'password'

setting2

確認設定

1.Command Line

choco config get proxy
choco config get proxyUser
choco config get proxyPassword

get1

2.PowerShell

$env:chocolateyProxyLocation
$env:chocolateyProxyUser
$env:chocolateyProxyPassword

get2

解除設定

1.Command Line

choco config unset proxy
choco config unset proxyUser
choco config unset proxyPassword

unset1

2.PowerShell

$env:chocolateyProxyLocation=''
$env:chocolateyProxyUser=''
$env:chocolateyProxyPassword=''

unset2

參考資料

  1. 安裝
  2. GitHub Wiki
  3. Config Command
  4. Chocolatey packages

上一篇
TortoiseGit 設定需驗證代理伺服器(proxy with authentication)
系列文
全端工程師的日常挑戰三十日31

尚未有邦友留言

立即登入留言