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.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With