Skip to content

PackageProvider Interface

Garrett Serack edited this page Apr 30, 2014 · 21 revisions

A OneGet PackageProvider that is implemented in PowerShell must be written as a module that exposes functions with signatures that match the following:

Required Methods

Method: GetPackageProviderName

Description

Returns the name of this PackageProvider

Necessity

This is required. Without this, the PackageProvider implementation will not be recognized, and will not load.

Syntax

string GetPackageProviderName()
function Get-PackageProviderName { } 

Return Value

As string representing the name for this package provider. This value is exposed to the user.

Exceptions

If the PackageProvider has a failure, it should throw an exception.

Optional Methods

Method: AddPackageSource

Description:

Adds a (or replaces an existing) package source.

Package Sources are always managed by the PackageProvider.

Necessity

This function is required if the PackageProvider supports user-specified package sources

Syntax

void AddPackageSource(string name, string location, bool trusted, bool validateLocation, Request request)
function Add-PackageSource { 
  param(
    [string] $name,      
    [string] $location,  
    [bool] $trusted,     
    [bool] $validateLocation 
    )
} 

Parameters

Parameter Type Description
name string the name the user is giving to the package source
location string the location that the source points to. (Uri, Filepath, or any other destination format supported by the package provider)
trusted bool Indicates whether the user trusts packages from this source
validateLocation bool If true, indicates the location should be validated (verified to be an actual workable location) before it is added as a source

Response

If a package source is added or updated, the PackageProvider must call $request.YieldPackageSource( ) with the details regarding the package source

Return Value

There is no return value from this function.

Exceptions

If the PackageProvider is unable to fulfill add the source, it should throw an exception.