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
stream
StreamStream to write the XML packages.config file into, or load existing packages.config from
createNew
boolWhether 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
StreamStream to write the XML packages.config file into, or load existing packages.config from
createNew
boolWhether to create a new packages.config file, or load an existing one
frameworkMappings
IFrameworkNameProviderFramework mappings
PackagesConfigWriter(string, bool)
Create a packages.config writer using file path
public PackagesConfigWriter(string fullPath, bool createNew)
Parameters
fullPath
stringThe full path to write the XML packages.config file into, or load existing packages.config from
createNew
boolWhether 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
stringThe full path to write the XML packages.config file into, or load existing packages.config from
createNew
boolWhether to create a new packages.config file, or load an existing one
frameworkMappings
IFrameworkNameProviderFramework mappings
Methods
AddPackageEntry(PackageIdentity, NuGetFramework)
Adds a basic package entry to the file
public void AddPackageEntry(PackageIdentity identity, NuGetFramework targetFramework)
Parameters
identity
PackageIdentitytargetFramework
NuGetFramework
AddPackageEntry(PackageReference)
Adds a package entry to the file
public void AddPackageEntry(PackageReference entry)
Parameters
entry
PackageReferencePackage reference entry
AddPackageEntry(string, NuGetVersion, NuGetFramework)
Add a package entry
public void AddPackageEntry(string packageId, NuGetVersion version, NuGetFramework targetFramework)
Parameters
packageId
stringPackage Id
version
NuGetVersionPackage Version
targetFramework
NuGetFrameworkPackage 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
PackageIdentityPackage identity
targetFramework
NuGetFrameworkPackage targetFramework
RemovePackageEntry(PackageReference)
Removes a package entry from the file
public void RemovePackageEntry(PackageReference entry)
Parameters
entry
PackageReferencePackage reference entry
RemovePackageEntry(string, NuGetVersion, NuGetFramework)
Remove a package entry
public void RemovePackageEntry(string packageId, NuGetVersion version, NuGetFramework targetFramework)
Parameters
packageId
stringPackage Id
version
NuGetVersionPackage version
targetFramework
NuGetFrameworkPackage 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
XDocumentnewEntry
PackageReference
UpdatePackageEntry(PackageReference, PackageReference)
Update a package entry to the file
public void UpdatePackageEntry(PackageReference oldEntry, PackageReference newEntry)
Parameters
oldEntry
PackageReferencenewEntry
PackageReference
WriteFile(string)
Write the XDocument to the packages.config and disallow further changes.
public void WriteFile(string fullPath)
Parameters
fullPath
stringthe full path to packages.config file
WriteMinClientVersion(NuGetVersion)
Write a minimum client version to packages.config
public void WriteMinClientVersion(NuGetVersion version)
Parameters
version
NuGetVersionMinumum version of the client required to parse and use this file.