For some reason, I have to use build agent "Hosted Linux Preview", so I can only use "dotnet restore" instead of "nuget restore", and now our team has internal package server built on VSTS.
In "nuget restore" step, there's option for connecting to the server, yet "dotnet restore" doesn't.
I tried the following ways, but failed.
Try 1 add --source https://****.pkgs.visualstudio.com/_packaging/****/nuget/v3/index.json
, I got error in log: error : Unable to load the service index for source https://****.pkgs.visualstudio.com/_packaging/****/nuget/v3/index.json. [/opt/vsts/work/1/s/src/References.Mapper/References.Mapper.csproj]
Try 2 add --configfile ../../.nuget/Nuget.Config
, I got the same error as above
It seems that the build agent doesn't have authorization to retrieve the index.json file from VSTS, how shall I proceed?
After checking the link Use dotnet with Team Services feeds, now I can successfully consume the feed.
Steps:
--configfile ../../.nuget/NuGet.Config
(location) in "Arguments" (note the name is case-senstive)Nuget.Config sample:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="VSTS-Package" value="[feed url]" />
<add key="Nuget.org" value="https://www.nuget.org/api/v2/" />
</packageSources>
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
<packageSourceCredentials>
<VSTS-Package>
<add key="Username" value="[username]" />
<add key="ClearTextPassword" value="[PAT]" />
</VSTS-Package>
</packageSourceCredentials>
</configuration>