---
title: "Query-Package"
---
Tests whether a universal package exists and optionally extracts its metadata.
UPack::Query-Package(
[From: <text>],
Name: <text>,
Version: <text>,
NewVersion: <text>,
[Reason: <text>],
[PackageFile: <text>],
[Feed: <text>],
[EndpointUrl: <text>],
[UserName: <text>],
[Password: <text>],
[ApiKey: <text>],
[Exists: <true/false>],
[Metadata: <%(key1: value1, ...)>],
[FeedUrl: <text>]
);
Name | Format | Script Usage | Usage Notes |
---|---|---|---|
Package source | text | From | |
☆ Package name | text | Name | This argument is required. |
☆ Package version | text | Version | This argument is required. |
☆ New version | text | NewVersion | This argument is required. |
Reason | text | Reason | |
Package file | text | PackageFile | When specified, FeedUrl, UserName, Password, PackageName, and PackageVersion are ignored. |
Feed name | text | Feed | |
API endpoint URL | text | EndpointUrl | |
ProGet user name | text | UserName | The name of a user in ProGet that can access this feed. |
ProGet password | text | Password | The password of a user in ProGet that can access this feed. |
ProGet API Key | text | ApiKey | An API Key that can access this feed. |
⇒ Package exists | true/false | Exists | When specified, this string variable will be set to "true" if the package exists or "false" if it does not. |
⇒ Package metadata | %(key1: value1, ...) | Metadata | When specified, this map variable will be assigned containing all of the package's metadata. If the package does not exist this value is not defined. |
FeedUrl | text | FeedUrl |
# test whether a package exists in a feed and capture its metadata
Query-Package
(
Credentials: MyExternalFeed,
PackageName: Group/Package,
Exists => $exists,
Metadata => %packageData
);
if $exists
{
Log-Debug 'Package $(%packageData.name) exists. Latest version is $(%packageData.version).';
}
# extract metadata from a locally-stored package file
Query-Package
(
PackageFile: C:\MyPackages\Package-1.0.0.upack,
Metadata => %packageData
);
Log-Debug 'Package name is $(%packageData.name).';