AzureDevOps.Packaging/Public/Install-AzureDevOpsNuGetPackage.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
function Install-AzureDevOpsNuGetPackage
{
    <#
    .SYNOPSIS
    Installs a NuGet package from an Azure Artifacts feed.
 
    .DESCRIPTION
    Installs a NuGet package from an Azure Artifacts feed using the Azure Artifacts REST API.
 
    .PARAMETER Source
    The name or GUID of the package feed.
 
    .PARAMETER Name
    The name of the package to download.
 
    .PARAMETER Version
    The version of the package to download
 
    .PARAMETER OutFile
    The file name for the downloaded package. Defaults to `<name>.<version>.nupkg`.
 
    .EXAMPLE
    Install-AzureDevOpsNuGetPackage -Source "myfeed" -Name "Contoso.Examples.Shared" -Version "1.1.0.22";
    #>

    param
    (
        [string]$Source,
        [string]$Name,
        [string]$Version,
        [string]$OutFile
    )

    if(-not $OutFile)
    {
        $OutFile = "$name.$version.nupkg";
    }

    return Install-AzureDevOpsPackage `
        -Provider "nuget" `
        -Source $Source `
        -Name $Name `
        -Version $Version `
        -OutFile $OutFile;
}