Month: February 2013

NuGet and chocolatey behind a proxy

NuGet historically didn’t handle company proxies, a common enough issue, which has led to a lot of guidance on the ‘net that is now out of date on how to deal with a proxy that isn’t playing nicely with your default credentials. Here are two tips: the first will let you get chocolatey installed and the second will let you configure NuGet so that chocolatey can do its goodness.

install chocolatey with windows auth proxy

The above gist will let you install chocolatey from a PowerShell command line. I used the normal download URL like this:

Set-ExecutionPolicy -ExecutionPolicy Unrestricted;$a=new-object net.webclient;$a.proxy.credentials=[system.net.credentialcache]::defaultnetworkcredentials;$a.downloadstring('https://chocolatey.org/install.ps1')|iex

NuGet configuration settings

From the linked configuration settings above I added:

.\nuget config -Set http_proxy=company-proxy:8080
.\nuget config -Set http_proxy.user=mylogin
.\nuget config -Set http_proxy.password=secret

Note that the password is encrypted in your NuGet.config so you can’t edit it directly.

Now I can use chocolatey without seeing:

Please provide proxy credentials:
UserName: Cannot prompt for input in non-interactive mode.

I believe that PowerShell and NuGet are trying to present the default web credentials rather than the default network credentials and in our case the proxy we lurk behind isn’t satisfied with that, thus the need to be explicit. It’s possible that NuGet was failing to present any credentials; I could investigate with Fiddler but these fixes have solved it for me. YMMV.

Advertisements

Git for Windows –help

Git for Windows wasn’t finding my web browser for launching help pages. The HTML was launched in Notepad.

First I made sure that the help should be launching as web pages. This is the default on Windows anyway as neither an info nor a man viewer are available.

$ git config --global help.format web

I tried tracing what was happening:

$ GIT_TRACE=1 git stash --help
trace: built-in: git 'help' 'stash'
Launching default browser to display HTML ...

Not enough information. I tried to use the web–browse script explicitly:

$ GIT_TRACE=1 git web--browse --browser=chrome 'http://news.bbc.co.uk/'
trace: exec: 'git-web--browse' '--browser=chrome' 'http://news.bbc.co.uk/'
trace: run_command: 'git-web--browse' '--browser=chrome' 'http://news.bbc.co.uk/'
trace: built-in: git 'config' 'browser.chrome.path'
The browser chrome is not available as 'chrome'.

Looks like the script couldn’t find my web browser:

$ git config --global browser.chrome.path "C:\Program Files\Google\Chrome\Application\chrome.exe"

No joy. I tried Doug Knox’s Windows XP File Association Fixes for HTM/HTML Associations. Nope.

Finally I went to the files in Git\doc\git\html and opened the Properties for one of the .html files and set the ‘Opens with:’ to Chrome. Joy!

So I can’t be sure exactly what worked here. I changed the git config to work with Firefox and the file ‘Opens with:’ to Firefox and it still worked. I’ve not repeated it with IE because, well, you wouldn’t, would you?