Internet Explorer is no longer supported. Many things will still work, but your experience will be degraded and some things won't function. Please use a modern browser such as Edge, Chrome, or Firefox.

Import Universal Package

view on GitHub

The Import Universal Package is an endpoint in ProGet's Universal Feed API that will add a package from an asset directory, file share, or local path on the ProGet server.

  • Content Type: The Content-Type header should be application/json.

Content Parameter Description

These properties are specified as properties of the JSON object in the request content body:

Parameter Details
assetDirectory Name of the asset directory to import the package from. The asset directory must be in the same ProGet instance as the Universal feed.
from Required. Path of .upack file to import. If assetDirectory is specified, this refers to the path within the specified asset directory. Otherwise, it is a local/UNC file path relative to the ProGet server.
deleteFromSource Specifies whether to delete the file from the source after import. The default is true.

The intended usage of this endpoint is to allow an asset directory to act as a staging area for uploading very large universal packages. For optimal performance, assetDirectory should be specified, the asset directory and universal package feed should both be configured for local disk storage, and deleteFromSource must be true.

In this case, a fast filesystem move operation can be performed. In all other cases, the operation will still complete, but may take longer depending on the size of the package imported.

Request Specification

To import a package, simply POST to the URL with a feed name and JSON object in the request content body:

POST /upack/«feed-name»/import

Importing a universal package from an asset directory requires the feed (e.g. myUniversalFeed) and a JSON object as the request body:

POST /upack/MyFeed/import "Content-Type: application/json"

{
  assetDirectory: "myAssetDirectory"
  from: "myFolder\example-lib.upack"
}

Response Specification

Response Details
200 (Success) successfully imports the package
404 (Package Not Found) indicates the specified package does not exist

Bulk Import of Packages (Powershell)

This script will import all .upack and .vpack packages from the folder universal-packages in the asset directory internal-files, to the universal-feed asset-directory-imports:

$baseUrl = "https://proget.corp.local"
$assetDirectoryApiKey = "abcde12345"
$universalFeedApiKey = "vwxyz67890"
$assetDirectory = "internal-files"
$assetDirectoryFolder = "universal-packages"
$universalFeed = "asset-directory-imports"

$listFolderHeaders = @{"X-ApiKey" = $assetDirectoryApiKey}
$listFolderEndpoint = "$baseUrl/endpoints/$assetDirectory/dir/$assetDirectoryFolder"

$importHeaders = @{"X-ApiKey" = $universalFeedApiKey}
$importEndpoint = "$baseUrl/upack/$universalFeed/import"

$response = Invoke-RestMethod -Uri $listFolderEndpoint -Headers $listFolderHeaders -Method Get

foreach ($file in $response) {
    if ($file.name -like "*.upack" -or $file.name -like "*.vpack") {
        $importPayload = @{
            assetDirectory = $assetDirectory
            from = "$assetDirectoryFolder\$($file.name)"
        } | ConvertTo-Json

        Invoke-RestMethod -Uri $importEndpoint -Headers $importHeaders -Method Post -Body $importPayload

        Write-Host "Imported $($file.name) to the feed."
    }
}

Note, this will only import any packages in the root of the asset directory folder given. Any packages within subfolders of this folder will need to be imported separately.