4
votes

So I think what I want is the opposite of this post: VSTS NuGet restore fails (proxy?)

We have an on-prem machine running a VSTS agent for builds. That machine has the http_proxy variable set so the agent process can talk to VSTS in the cloud.

I'm then trying to use the built in nuget task to do a nuget restore, but the feed I want to access is on an on-prem artifactory instance. To access this feed nuget needs to not use the proxy settings that the agent does (we have the 'bypass proxy for local addresses' option checked in Internet Options).

However, when I run the nuget task I see the following in my build log, it seems to set the nuget proxy to the agent proxy:

2017-10-17T14:02:14.4961204Z ##[debug]agent.proxyurl=http://X.X.X.X:8080
2017-10-17T14:02:14.4961204Z ##[debug]agent.proxyusername=undefined
2017-10-17T14:02:14.6992455Z ##[debug]agent.proxypassword=undefined
2017-10-17T14:02:14.7773706Z ##[debug]Adding environment variable for NuGet proxy: http://X.X.X.X:8080/
2017-10-17T14:02:14.7773706Z ##[debug]exec tool: C:\vsts-agent\_work\_tool\NuGet\4.0.0\x64\nuget.exe

(The 2 sets of X.X.X.X are identical in the real log)

I've tried setting a process variable of http_proxy="" and adding this line to my nuget.config <add key="http_proxy" value="" />, but it makes no difference.

Is there a way to run the nuget task without picking up the agent proxy?

If I just run nuget manually from a command line task in VSTS, it all works as expected.

1

1 Answers

3
votes

The VSTS agent should be able to pick up the proxy exclusion settings from a .proxybypass file:

echo http://local.nuget.server >> .proxybypass

enter image description here

I'm not sure if the Nuget task will pick this up (it looks like it doesn't yet), but at least that's how you can tell the agent to ignore certain hosts. This was added in a very recent agent version, so you may need to upgrade your agent.

I'm guessing that if you use my VSTS Set Variable Task to temporarily set the value of agent.proxyurl to an empty string and restore it after calling the nuget task, that it should work for now.

PS the new configuration no longer uses the environment variable to set the proxy, the new default is to put that in a .proxy file in the agent root as well.