nuget library
A Dart library that allows interaction with the NuGet Server API.
This library provides easy access to the NuGet Server API, allowing you to perform various operations such as querying package information, downloading package content, fetching package metadata, and more.
Here's a basic example demonstrating how to use the NuGetClient
class
to interact with the NuGet Server API:
import 'package:nuget/nuget.dart';
void main() async {
// Create an instance of NuGetClient
final client = NuGetClient();
// Download package content (.nupkg)
final content = await client.downloadPackageContent('Newtonsoft.Json',
version: '13.0.3');
print('`Newtonsoft.Json` package size: ${content.length} bytes');
// Get package metadata
final metadata =
await client.getPackageMetadata('Newtonsoft.Json', version: '13.0.3');
print('`Newtonsoft.Json` metadata:');
print(' - Version: ${metadata.version}');
print(' - Description: ${metadata.description}');
print(' - Author(s): ${metadata.authors}');
// Get package versions
final versions = await client.getPackageVersions('Newtonsoft.Json');
print('`Newtonsoft.Json` has ${versions.length} versions:');
for (final version in versions) {
print(' - $version');
}
// Search packages
final searchResponse = await client.searchPackages('win32');
print('The `win32` query returned ${searchResponse.totalHits} hits. Here '
'are the first 20 results:');
for (final package in searchResponse.data) {
print(' - ${package.packageId} (${package.version})');
}
// Don't forget to close the client when you're done with it
client.close();
}
Classes
- AlternatePackage
- The alternate package that should be used instead of a deprecated package.
- AutocompletePackageIdsResponse
-
Represents the response from the Autocomplete Resource's
Search for package IDs
API. - AutocompleteResource
- The NuGet Autocomplete resource, used to retrieve package IDs and versions that match a query.
- CatalogEntry
- Represents a package's metadata.
- DependencyGroupItem
- The dependencies of the package for a specific target framework.
- DependencyItem
- Represents a package dependency.
- NuGetClient
- A client for interacting with the NuGet Server API.
- NuGetResource
- A base class for all NuGet resources.
- PackageContentResource
- The NuGet Package Content resource, used to retrieve the contents of a package.
- PackageDeprecation
- Represents information about a package's deprecation.
- PackageMetadataResource
- The NuGet Package Metadata resource, used to retrieve metadata about packages.
- RegistrationIndexPage
-
A resource in the
items
List from theRegistrationIndexResponse
class. - RegistrationIndexPageItem
-
A resource in the
items
List from theRegistrationIndexPage
class. - RegistrationIndexResponse
- The response from the registration index.
- RegistrationLeafResponse
- The response from the registration leaf.
- RegistrationPageResponse
- The response from the registration page.
- SearchEntry
-
A resource in the
data
List from theSearchResponse
class. - SearchResource
- The NuGet Search resource, used to search for packages.
- SearchResponse
-
Represents the response from the Search Resource's
Search for packages
API. - ServiceIndexItem
-
A resource in the
resources
List from theServiceIndexResponse
class. - ServiceIndexResource
- The NuGet Service Index resource, used to discover other resources.
- ServiceIndexResponse
- Represents the response from the Service Index resource.
- VersionItem
-
A resource in the
versions
List from theSearchEntry
class.
Enums
- PackageDeprecationReason
- Represents the reason why a package is deprecated.
Extensions
Exceptions / Errors
- NuGetServerException
- Exception thrown when a server returns non-200 status code.
- PackageNotFoundException
- Exception thrown when a package is not found.