Table of Contents

Class PackagesConfigWriter

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

Writes the packages.config XML file to a stream

public class PackagesConfigWriter : IDisposable
Inheritance
PackagesConfigWriter
Implements
Inherited Members

Constructors

PackagesConfigWriter(Stream, bool)

Create a packages.config writer using stream

public PackagesConfigWriter(Stream stream, bool createNew)

Parameters

stream Stream

Stream to write the XML packages.config file into, or load existing packages.config from

createNew bool

Whether to create a new packages.config file, or load an existing one

PackagesConfigWriter(Stream, bool, IFrameworkNameProvider)

Create a packages.config writer using stream

public PackagesConfigWriter(Stream stream, bool createNew, IFrameworkNameProvider frameworkMappings)

Parameters

stream Stream

Stream to write the XML packages.config file into, or load existing packages.config from

createNew bool

Whether to create a new packages.config file, or load an existing one

frameworkMappings IFrameworkNameProvider

Framework mappings

PackagesConfigWriter(string, bool)

Create a packages.config writer using file path

public PackagesConfigWriter(string fullPath, bool createNew)

Parameters

fullPath string

The full path to write the XML packages.config file into, or load existing packages.config from

createNew bool

Whether to create a new packages.config file, or load an existing one

PackagesConfigWriter(string, bool, IFrameworkNameProvider)

Create a packages.config writer using file path

public PackagesConfigWriter(string fullPath, bool createNew, IFrameworkNameProvider frameworkMappings)

Parameters

fullPath string

The full path to write the XML packages.config file into, or load existing packages.config from

createNew bool

Whether to create a new packages.config file, or load an existing one

frameworkMappings IFrameworkNameProvider

Framework mappings

Methods

AddPackageEntry(PackageIdentity, NuGetFramework)

Adds a basic package entry to the file

public void AddPackageEntry(PackageIdentity identity, NuGetFramework targetFramework)

Parameters

identity PackageIdentity
targetFramework NuGetFramework

AddPackageEntry(PackageReference)

Adds a package entry to the file

public void AddPackageEntry(PackageReference entry)

Parameters

entry PackageReference

Package reference entry

AddPackageEntry(string, NuGetVersion, NuGetFramework)

Add a package entry

public void AddPackageEntry(string packageId, NuGetVersion version, NuGetFramework targetFramework)

Parameters

packageId string

Package Id

version NuGetVersion

Package Version

targetFramework NuGetFramework

Package targetFramework that's compatible with current project

Dispose()

Write the XDocument to the stream and close it to disallow further changes.

public void Dispose()

Dispose(bool)

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

RemovePackageEntry(PackageIdentity, NuGetFramework)

Remove a package identity from the file

public void RemovePackageEntry(PackageIdentity identity, NuGetFramework targetFramework)

Parameters

identity PackageIdentity

Package identity

targetFramework NuGetFramework

Package targetFramework

RemovePackageEntry(PackageReference)

Removes a package entry from the file

public void RemovePackageEntry(PackageReference entry)

Parameters

entry PackageReference

Package reference entry

RemovePackageEntry(string, NuGetVersion, NuGetFramework)

Remove a package entry

public void RemovePackageEntry(string packageId, NuGetVersion version, NuGetFramework targetFramework)

Parameters

packageId string

Package Id

version NuGetVersion

Package version

targetFramework NuGetFramework

Package targetFramework

UpdateOrAddPackageEntry(XDocument, PackageReference)

Update a package entry using the original entry as a base if it exists.

public void UpdateOrAddPackageEntry(XDocument originalConfig, PackageReference newEntry)

Parameters

originalConfig XDocument
newEntry PackageReference

UpdatePackageEntry(PackageReference, PackageReference)

Update a package entry to the file

public void UpdatePackageEntry(PackageReference oldEntry, PackageReference newEntry)

Parameters

oldEntry PackageReference
newEntry PackageReference

WriteFile(string)

Write the XDocument to the packages.config and disallow further changes.

public void WriteFile(string fullPath)

Parameters

fullPath string

the full path to packages.config file

WriteMinClientVersion(NuGetVersion)

Write a minimum client version to packages.config

public void WriteMinClientVersion(NuGetVersion version)

Parameters

version NuGetVersion

Minumum version of the client required to parse and use this file.