Recently built a new TFS 2018 (update 3) server and configured package management to use upstream resources, i.e. NuGet.org. One thing I had to do was setup the IIS site to run through a proxy service. Once it was all configured, I set Visual Studio to use TFS as the only package source and cleared the local cache. After I restored the NuGet packages, I verified that TFS was in fact caching them.
I then proceeded to test the server builds. Cleared all the NuGet packages from TFS and local cache and tried to build. The build failed while attempting to retrieve the NuGet packages. As you can see below, the NuGet packages were not found in local cache nor in TFS, so an attempt was made to download the packages from NuGet which failed with a connection refused message.
The nuget command failed with exit code(1) and error(Errors in packages.config projects Unable to find version '1.3.2' of package 'MSTest.TestFramework'. C:\Users\TfsBuild.nuget\packages: Package 'MSTest.TestFramework.1.3.2' is not found on source 'C:\Users\TfsBuild.nuget\packages\'. https://tfs2.somedomain.com/testco/_packaging/be64f838-0b3e-42b4-92cc-bce7c435274a/nuget/v3/index.json: Package 'MSTest.TestFramework.1.3.2' is not found on source 'https://tfs2.somedomain.com/testco/_packaging/be64f838-0b3e-42b4-92cc-bce7c435274a/nuget/v3/index.json'. https://api.nuget.org/v3/index.json: Unable to load the service index for source https://api.nuget.org/v3/index.json. An error occurred while sending the request. Unable to connect to the remote server No connection could be made because the target machine actively refused it 72.21.81.200:443 Unable to find version '1.3.2' of package 'MSTest.TestAdapter'. C:\Users\TfsBuild.nuget\packages: Package 'MSTest.TestAdapter.1.3.2' is not found on source 'C:\Users\TfsBuild.nuget\packages\'. https://tfs2.somedomain.com/testco/_packaging/be64f838-0b3e-42b4-92cc-bce7c435274a/nuget/v3/index.json: Package 'MSTest.TestAdapter.1.3.2' is not found on source 'https://tfs2.somedomain.com/testco/_packaging/be64f838-0b3e-42b4-92cc-bce7c435274a/nuget/v3/index.json'. https://api.nuget.org/v3/index.json: Unable to load the service index for source https://api.nuget.org/v3/index.json. An error occurred while sending the request. Unable to connect to the remote server No connection could be made because the target machine actively refused it 72.21.81.200:443)
My guess is that somehow the build server is bypassing the proxy and attempting to retrieve the NuGet packages directly, but I don't know how. The package source on the build server is the exact same one I used in Visual Studio. Permissions don't seems to be a problem because when the packages exist locally in package management, the build succeeds.
Does anyone have a clue as to why this works from Visual Studio but fails on the build server?
UPDATE
I know where the build is bypassing the upstream feed. There's a check-box that says "Use packages from NuGet.org". When I uncheck this, TFS no longer attempts to go directly to NuGet.org. However, I discovered a new issue. When I setup TFS to use a proxy, the "Use packages from this VSTS/TFS feed" will no longer list my local feed. If I remove the proxy settings, the feed is now listed but the upstream source is broken.
Does anyone know how to configure TFS 2018 behind a proxy so that both upstream package resources can be used along side local package resources in both TFS and Visual Studio?