SimonAx
SimonAx

Reputation: 1378

Authentication installing Chocolatey packages hosted in VSTS

At work, we create nuget packages that we store in VSTS. All developers have added our repository to the global nuget.config (in folder %appdata%\Nuget), created personal access token (PAT), and installed CredentialProvider.VSS.exe. Therefore restoring nuget packages using the command line, e.g. nuget.exe restore, is done without having to supply any passwords or user names.

When using the same recipe for Chocolatey packages, things don't work that well. The blog at roadtoalm.com describes how you can install Chocolatey packages that are stored in VSTS, but you have to supply the PAT, repository address and user name (although the latter can be a bogus value, it's not being used). Is there no way to have Chocolatey use the credential provider just like nuget is doing it?

Update: After having added my Choco repository to the list of known repos, my chocolatey.config file looks like

  <sources>
    <source id="chocolatey" value="https://chocolatey.org/api/v2/" disabled="true" bypassProxy="false" selfService="false" priority="0" />    
    <source id="CompanyChoco" value="https://Company.pkgs.visualstudio.com/_packaging/CompanyChoco/nuget/v2/" disabled="false" bypassProxy="false" selfService="false" priority="1" />
  </sources>

As suggested by @starain-MSFT, I've created a package.config file, which looks like this:

<?xml version="1.0" encoding="utf-8"?>
  <packages>
    <package id="MyPackage" version="0.0.4"  source="https://Company.pkgs.visualstudio.com/_packaging/CompanyChoco/nuget/v2/" />
  </packages>

I have also ensured that I have the latest version of CredentialProvider.VSS.exe installed in %appdata%\local\nuget\credentialproviders. When doing "choco install package.config", I still get prompted for username and password.

Upvotes: 1

Views: 1704

Answers (1)

starian chen-MSFT
starian chen-MSFT

Reputation: 33708

Try it with these steps:

  1. Define packages in Packages.config
  2. Call choco source add command to add another source (using choco source list to check sources)
  3. Call choco install [packages.config] command to install packages.

Upvotes: 2

Related Questions