Table of Contents

Class PackageReference

Namespace
NuGet.Packaging
Assembly
Chocolatey.NuGet.Packaging.dll

Represents a package element in the packages.config file

public class PackageReference
Inheritance
PackageReference
Inherited Members

Constructors

PackageReference(PackageIdentity, NuGetFramework)

Creates a new packages config entry

public PackageReference(PackageIdentity identity, NuGetFramework targetFramework)

Parameters

identity PackageIdentity
targetFramework NuGetFramework

PackageReference(PackageIdentity, NuGetFramework, bool)

Creates a new packages config entry

public PackageReference(PackageIdentity identity, NuGetFramework targetFramework, bool userInstalled)

Parameters

identity PackageIdentity
targetFramework NuGetFramework
userInstalled bool

PackageReference(PackageIdentity, NuGetFramework, bool, bool, bool)

Creates a new packages config entry

public PackageReference(PackageIdentity identity, NuGetFramework targetFramework, bool userInstalled, bool developmentDependency, bool requireReinstallation)

Parameters

identity PackageIdentity
targetFramework NuGetFramework
userInstalled bool
developmentDependency bool
requireReinstallation bool

PackageReference(PackageIdentity, NuGetFramework, bool, bool, bool, VersionRange)

Creates a new packages config entry

public PackageReference(PackageIdentity identity, NuGetFramework targetFramework, bool userInstalled, bool developmentDependency, bool requireReinstallation, VersionRange allowedVersions)

Parameters

identity PackageIdentity

Package id and version

targetFramework NuGetFramework

Package target framework installed to the project

userInstalled bool

True if the user installed this package directly

developmentDependency bool

True if the package is a development dependency

requireReinstallation bool

True if this package needs to be reinstalled

allowedVersions VersionRange

Restrict package versions to the allowedVersions range

Properties

AllowedVersions

The allowed range of versions that this package can be upgraded/downgraded to.

public VersionRange AllowedVersions { get; }

Property Value

VersionRange

Remarks

This is null if unbounded

HasAllowedVersions

True if allowedVersions exists.

public bool HasAllowedVersions { get; }

Property Value

bool

IsDevelopmentDependency

Development dependency

public bool IsDevelopmentDependency { get; }

Property Value

bool

IsUserInstalled

True if the user installed or updated this package directly. False if this package was installed as a dependency by another package.

public bool IsUserInstalled { get; }

Property Value

bool

PackageIdentity

Id and Version of the package

public PackageIdentity PackageIdentity { get; }

Property Value

PackageIdentity

RequireReinstallation

Require reinstallation

public bool RequireReinstallation { get; }

Property Value

bool

TargetFramework

Installed target framework version of the package.

public NuGetFramework TargetFramework { get; }

Property Value

NuGetFramework

Methods

ToString()

Displays the identity and target framework of the reference.

public override string ToString()

Returns

string