1
votes

We have a project hosted in VSTS which consumes a NuGet package that we have hosted in a private NuGet feed behind our firewall.

Accessing the feed from withing the network is fine, and we can locally restore dependencies and build the project.

When configuring a VSTS build we have selected a private build agent installed on a PC within the same network as the NuGet feed. Again we have tested that restoring and building manually on that PC works.

On the NuGet feed location in the VSTS build definition task we have typed the very address we use for restoring from the private NuGet feed, and we assumed that since the agent and the private NuGet feed are inside the network and the agent's PC can access the feed and then VSTS, then there will be no problem, but that's not the case. Build fails restoring packages and the error said "can't find the feed".

Can private VSTS build agents use custom NuGet feeds?

2
What's the detail error message? Try to change the agent service account to your account and try again.starian chen-MSFT

2 Answers

1
votes

Yes, private agent can access to your nuget feeds if the agent machine has right to access.

Since you have already verified the connection from your local machine to the private feed, you can check you VSTS build defition for NuGet restore task:

In NuGet restore task, you should select Feeds in my NuGet.config for Feeds to use option.

For Path to NuGet.config option, if you are using the nuget.config file located in %AppData%\NuGet\NuGet.Config, you can leave the option empty, it use the nuget.config file by default. If the nuget.config file you are using does not located in the path, you should specify the path for where the nuget.config file located.

For Credentials for feeds outside this account/collection option, select your private feed(s) for where to download the packages.

If you have not add endpoint for your private feed in VSTS, you can click New to add credential for your private feed.

enter image description here

enter image description here

1
votes

They can but you might need to configure where your nuget feed is at on the Build server.

We run our private build agents under a user we have defined. We will call him user1.

If you go out to c:\users\user1\appdata\roaming\nuget there should be a NuGet.Config.

It should look a lot like this. We have stopped our build servers from finding the Microsoft Feed. We only wanted them to run the enterprise feed we have. You can steal the one off your local machine or save it using Visual Studio on the Build Machine.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageRestore>
    <add key="enabled" value="True" />
    <add key="automatic" value="True" />
  </packageRestore>
  <packageSources>
    <add key="Your Repository Key" value="http://[your package location]/packages.svc" />
    <add key="nuget.org" value="https://www.nuget.org/api/v2/" />
  </packageSources>
  <disabledPackageSources>
    <add key="nuget.org" value="true" />
    <add key="Microsoft and .NET" value="true" />
  </disabledPackageSources>
  <activePackageSource>
    <add key="All" value="(Aggregate source)" />
  </activePackageSource>
</configuration>