Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you restore packages in a VSTS feed that belongs to another VSTS account?

My company has many Visual Studio Team Services accounts. We have one for our internal development, and one for each of our clients. We're hosting our internal nuget libraries in our internal development account (https://{dev-account}.visualstudio.com/DefaultCollection), and I want to restore packages when running a build in a client's account (https://{client-account}.visualstudio.com/DefaultCollection).

I set up the repository using bootstrap tools, and in my VSTS build I added a Batch Script build step the executes init.cmd. That works fine, however, the next step is NuGet Package Restore where it can't find the packages in the dev account's NuGet feed:

2016-03-22T23:34:37.5398840Z Please provide credentials for: https://{dev-account}.pkgs.visualstudio.com/DefaultCollection/_packaging/{my-feed}/nuget/v3/index.json

2016-03-22T23:34:37.5408842Z UserName: Password: WARNING: Unable to find version '1.9.0.10' of package '{my-package}'.

This makes sense, because the feed is in a separate VSTS account and the build agent doesn't have permission to access the feed.

Is there anyway around this? I'm aware of MyGet, which offers free public feeds, but I'd like to use VSTS, if possible.

like image 459
jrummell Avatar asked Oct 31 '22 07:10

jrummell


1 Answers

I'm not thrilled with this solution, but it works. You can store credentials for a package source in nuget.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <config>
    <clear />
    <add key="repositoryPath" value="packages" />
  </config>
  <packageSources>
    <!-- When <clear /> is present, previously defined sources are ignored -->
    <!-- Remove this tag or un-comment the nuget.org source below to restore packages from nuget.org -->
    <!-- For more info, see https://docs.nuget.org/consume/nuget-config-file -->
    <clear />
    <add key="vss-package-management" value="https://www.myget.org/F/vss-package-management/api/v2" />
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
    <add key="{dev-account}" value="https://{dev-account}.pkgs.visualstudio.com/DefaultCollection/_packaging/{feed}/nuget/v3/index.json" />
  </packageSources>
  <activePackageSource>
    <add key="All" value="(Aggregate source)" />
  </activePackageSource>
  <packageSourceCredentials>
    <{dev-account}>
      <add key="Username" value="username" />
      <add key="ClearTextPassword" value="password" />
    </{dev-account}>
  </packageSourceCredentials>
</configuration>
like image 177
jrummell Avatar answered Nov 13 '22 01:11

jrummell