Class PackagesConfigWriter
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
streamStreamStream to write the XML packages.config file into, or load existing packages.config from
createNewboolWhether 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
streamStreamStream to write the XML packages.config file into, or load existing packages.config from
createNewboolWhether to create a new packages.config file, or load an existing one
frameworkMappingsIFrameworkNameProviderFramework mappings
PackagesConfigWriter(string, bool)
Create a packages.config writer using file path
public PackagesConfigWriter(string fullPath, bool createNew)
Parameters
fullPathstringThe full path to write the XML packages.config file into, or load existing packages.config from
createNewboolWhether 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
fullPathstringThe full path to write the XML packages.config file into, or load existing packages.config from
createNewboolWhether to create a new packages.config file, or load an existing one
frameworkMappingsIFrameworkNameProviderFramework mappings
Methods
AddPackageEntry(PackageIdentity, NuGetFramework)
Adds a basic package entry to the file
public void AddPackageEntry(PackageIdentity identity, NuGetFramework targetFramework)
Parameters
identityPackageIdentitytargetFrameworkNuGetFramework
AddPackageEntry(PackageReference)
Adds a package entry to the file
public void AddPackageEntry(PackageReference entry)
Parameters
entryPackageReferencePackage reference entry
AddPackageEntry(string, NuGetVersion, NuGetFramework)
Add a package entry
public void AddPackageEntry(string packageId, NuGetVersion version, NuGetFramework targetFramework)
Parameters
packageIdstringPackage Id
versionNuGetVersionPackage Version
targetFrameworkNuGetFrameworkPackage 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
disposingbool
RemovePackageEntry(PackageIdentity, NuGetFramework)
Remove a package identity from the file
public void RemovePackageEntry(PackageIdentity identity, NuGetFramework targetFramework)
Parameters
identityPackageIdentityPackage identity
targetFrameworkNuGetFrameworkPackage targetFramework
RemovePackageEntry(PackageReference)
Removes a package entry from the file
public void RemovePackageEntry(PackageReference entry)
Parameters
entryPackageReferencePackage reference entry
RemovePackageEntry(string, NuGetVersion, NuGetFramework)
Remove a package entry
public void RemovePackageEntry(string packageId, NuGetVersion version, NuGetFramework targetFramework)
Parameters
packageIdstringPackage Id
versionNuGetVersionPackage version
targetFrameworkNuGetFrameworkPackage 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
originalConfigXDocumentnewEntryPackageReference
UpdatePackageEntry(PackageReference, PackageReference)
Update a package entry to the file
public void UpdatePackageEntry(PackageReference oldEntry, PackageReference newEntry)
Parameters
oldEntryPackageReferencenewEntryPackageReference
WriteFile(string)
Write the XDocument to the packages.config and disallow further changes.
public void WriteFile(string fullPath)
Parameters
fullPathstringthe full path to packages.config file
WriteMinClientVersion(NuGetVersion)
Write a minimum client version to packages.config
public void WriteMinClientVersion(NuGetVersion version)
Parameters
versionNuGetVersionMinumum version of the client required to parse and use this file.