Class PackageReaderBase
Abstract class that both the zip and folder package readers extend This class contains the path conventions for both zip and folder readers
public abstract class PackageReaderBase : IPackageCoreReader, IPackageContentReader, IAsyncPackageCoreReader, IAsyncPackageContentReader, ISignedPackageReader, IDisposable
- Inheritance
-
PackageReaderBase
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
PackageReaderBase(IFrameworkNameProvider)
Instantiates a new PackageReaderBase class.
public PackageReaderBase(IFrameworkNameProvider frameworkProvider)
Parameters
frameworkProvider
IFrameworkNameProviderA framework mapping provider.
Exceptions
- ArgumentNullException
Thrown if
frameworkProvider
isnull
.
PackageReaderBase(IFrameworkNameProvider, IFrameworkCompatibilityProvider)
Instantiates a new PackageReaderBase class.
public PackageReaderBase(IFrameworkNameProvider frameworkProvider, IFrameworkCompatibilityProvider compatibilityProvider)
Parameters
frameworkProvider
IFrameworkNameProviderA framework mapping provider.
compatibilityProvider
IFrameworkCompatibilityProviderA framework compatibility provider.
Exceptions
- ArgumentNullException
Thrown if
frameworkProvider
isnull
.- ArgumentNullException
Thrown if
compatibilityProvider
isnull
.
Properties
CompatibilityProvider
protected IFrameworkCompatibilityProvider CompatibilityProvider { get; set; }
Property Value
- IFrameworkCompatibilityProvider
FrameworkProvider
protected IFrameworkNameProvider FrameworkProvider { get; set; }
Property Value
- IFrameworkNameProvider
NuspecReader
Nuspec reader
public virtual NuspecReader NuspecReader { get; }
Property Value
Methods
CanVerifySignedPackages(SignedPackageVerifierSettings)
Indicates if the the ISignedPackageReader instance can verify signed packages.
public abstract bool CanVerifySignedPackages(SignedPackageVerifierSettings verifierSettings)
Parameters
verifierSettings
SignedPackageVerifierSettingsPackage verification settings. Include information about what is allowed.
Returns
Exceptions
- SignatureException
if the ISignedPackageReader does not support signed packages
CopyFiles(string, IEnumerable<string>, ExtractPackageFileDelegate, ILogger, CancellationToken)
Copies files from a package to a new location.
public abstract IEnumerable<string> CopyFiles(string destination, IEnumerable<string> packageFiles, ExtractPackageFileDelegate extractFile, ILogger logger, CancellationToken token)
Parameters
destination
stringThe destination folder path.
packageFiles
IEnumerable<string>The package files to copy.
extractFile
ExtractPackageFileDelegateA package file extraction delegate.
logger
ILoggerA logger.
token
CancellationTokenA cancellation token.
Returns
- IEnumerable<string>
An enumerable of paths of files copied to the destination.
CopyFilesAsync(string, IEnumerable<string>, ExtractPackageFileDelegate, ILogger, CancellationToken)
Asynchronously copies files from a package to a new location.
public virtual Task<IEnumerable<string>> CopyFilesAsync(string destination, IEnumerable<string> packageFiles, ExtractPackageFileDelegate extractFile, ILogger logger, CancellationToken cancellationToken)
Parameters
destination
stringThe destination path to copy to.
packageFiles
IEnumerable<string>The package files to copy.
extractFile
ExtractPackageFileDelegateA package file extraction delegate.
logger
ILoggerA logger.
cancellationToken
CancellationTokenA cancellation token.
Returns
- Task<IEnumerable<string>>
A task that represents the asynchronous operation. The task result (Result) returns am IEnumerable<T> for the copied file paths.
Exceptions
- OperationCanceledException
Thrown if
cancellationToken
is cancelled.
CopyNupkgAsync(string, CancellationToken)
public virtual Task<string> CopyNupkgAsync(string nupkgFilePath, CancellationToken cancellationToken)
Parameters
nupkgFilePath
stringcancellationToken
CancellationToken
Returns
Dispose()
public void Dispose()
Dispose(bool)
protected abstract void Dispose(bool disposing)
Parameters
disposing
bool
GetArchiveHashAsync(HashAlgorithmName, CancellationToken)
Gets the hash of an archive to be embedded in the package signature.
public abstract Task<byte[]> GetArchiveHashAsync(HashAlgorithmName hashAlgorithm, CancellationToken token)
Parameters
hashAlgorithm
HashAlgorithmNametoken
CancellationToken
Returns
GetBuildItems()
Returns all items under the build folder.
public virtual IEnumerable<FrameworkSpecificGroup> GetBuildItems()
Returns
GetBuildItemsAsync(CancellationToken)
Asynchronously returns all items under the build folder.
public virtual Task<IEnumerable<FrameworkSpecificGroup>> GetBuildItemsAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationTokenA cancellation token.
Returns
- Task<IEnumerable<FrameworkSpecificGroup>>
A task that represents the asynchronous operation. The task result (Result) returns an IEnumerable<T>.
GetContentHash(CancellationToken, Func<string>)
Get contenthash for a package.
public abstract string GetContentHash(CancellationToken token, Func<string> GetUnsignedPackageHash = null)
Parameters
token
CancellationTokenGetUnsignedPackageHash
Func<string>
Returns
GetContentItems()
Returns all items found in the content folder.
public virtual IEnumerable<FrameworkSpecificGroup> GetContentItems()
Returns
Remarks
Some legacy behavior has been dropped here due to the mix of content folders and target framework folders here.
GetContentItemsAsync(CancellationToken)
Asynchronously returns all items found in the content folder.
public virtual Task<IEnumerable<FrameworkSpecificGroup>> GetContentItemsAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationTokenA cancellation token.
Returns
- Task<IEnumerable<FrameworkSpecificGroup>>
A task that represents the asynchronous operation. The task result (Result) returns an IEnumerable<T>.
Remarks
Some legacy behavior has been dropped here due to the mix of content folders and target framework folders here.
GetDevelopmentDependency()
public virtual bool GetDevelopmentDependency()
Returns
GetDevelopmentDependencyAsync(CancellationToken)
public virtual Task<bool> GetDevelopmentDependencyAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationToken
Returns
GetFileGroups(string)
protected IEnumerable<FrameworkSpecificGroup> GetFileGroups(string folder)
Parameters
folder
string
Returns
GetFiles()
Gets all files in the package.
public abstract IEnumerable<string> GetFiles()
Returns
- IEnumerable<string>
An enumerable of files in the package.
GetFiles(string)
Gets files in a folder in the package.
public abstract IEnumerable<string> GetFiles(string folder)
Parameters
folder
stringFolder path
Returns
- IEnumerable<string>
An enumerable of files under specified folder.
GetFilesAsync(string, CancellationToken)
Asynchronously gets files in a folder in the package.
public virtual Task<IEnumerable<string>> GetFilesAsync(string folder, CancellationToken cancellationToken)
Parameters
folder
stringA folder path in the package.
cancellationToken
CancellationTokenA cancellation token.
Returns
- Task<IEnumerable<string>>
A task that represents the asynchronous operation. The task result (Result) returns an IEnumerable<T> for files under the specified folder.
Exceptions
- OperationCanceledException
Thrown if
cancellationToken
is cancelled.
GetFilesAsync(CancellationToken)
Asynchronously gets all files in the package.
public virtual Task<IEnumerable<string>> GetFilesAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationTokenA cancellation token.
Returns
- Task<IEnumerable<string>>
A task that represents the asynchronous operation. The task result (Result) returns an IEnumerable<T>.
Exceptions
- OperationCanceledException
Thrown if
cancellationToken
is cancelled.
GetFrameworkFromPath(string, bool)
protected NuGetFramework GetFrameworkFromPath(string path, bool allowSubFolders = false)
Parameters
Returns
- NuGetFramework
GetFrameworkItems()
Returns all framework references found in the nuspec.
public virtual IEnumerable<FrameworkSpecificGroup> GetFrameworkItems()
Returns
GetFrameworkItemsAsync(CancellationToken)
Asynchronously returns all framework references found in the nuspec.
public virtual Task<IEnumerable<FrameworkSpecificGroup>> GetFrameworkItemsAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationTokenA cancellation token.
Returns
- Task<IEnumerable<FrameworkSpecificGroup>>
A task that represents the asynchronous operation. The task result (Result) returns an IEnumerable<T>.
GetIdentity()
Gets the package identity.
public virtual PackageIdentity GetIdentity()
Returns
- PackageIdentity
A package identity.
GetIdentityAsync(CancellationToken)
Asynchronously gets the identity of the package.
public virtual Task<PackageIdentity> GetIdentityAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationTokenA cancellation token.
Returns
- Task<PackageIdentity>
A task that represents the asynchronous operation. The task result (Result) returns a PackageIdentity.
Exceptions
- OperationCanceledException
Thrown if
cancellationToken
is cancelled.
GetItems(string)
public virtual IEnumerable<FrameworkSpecificGroup> GetItems(string folderName)
Parameters
folderName
string
Returns
GetItemsAsync(string, CancellationToken)
public virtual Task<IEnumerable<FrameworkSpecificGroup>> GetItemsAsync(string folderName, CancellationToken cancellationToken)
Parameters
folderName
stringcancellationToken
CancellationToken
Returns
GetLibItems()
Returns all lib items without any filtering. Use GetReferenceItems for the filtered list.
public virtual IEnumerable<FrameworkSpecificGroup> GetLibItems()
Returns
GetLibItemsAsync(CancellationToken)
Asynchronously returns all lib items without any filtering.
public virtual Task<IEnumerable<FrameworkSpecificGroup>> GetLibItemsAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationTokenA cancellation token.
Returns
- Task<IEnumerable<FrameworkSpecificGroup>>
A task that represents the asynchronous operation. The task result (Result) returns an IEnumerable<T>.
Remarks
Use GetReferenceItemsAsync(...) for the filtered list.
GetMinClientVersion()
Gets the minimum client version needed to consume the package.
public virtual NuGetVersion GetMinClientVersion()
Returns
- NuGetVersion
A NuGet version.
GetMinClientVersionAsync(CancellationToken)
Asynchronously gets the minimum client version needed to consume the package.
public virtual Task<NuGetVersion> GetMinClientVersionAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationTokenA cancellation token.
Returns
- Task<NuGetVersion>
A task that represents the asynchronous operation. The task result (Result) returns a NuGet.Versioning.NuGetVersion.
Exceptions
- OperationCanceledException
Thrown if
cancellationToken
is cancelled.
GetNuspec()
Gets a nuspec stream.
public virtual Stream GetNuspec()
Returns
- Stream
A stream for the nuspec.
GetNuspecAsync(CancellationToken)
Asynchronously gets a nuspec stream.
public virtual Task<Stream> GetNuspecAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationTokenA cancellation token.
Returns
- Task<Stream>
A task that represents the asynchronous operation. The task result (Result) returns a Stream.
Exceptions
- OperationCanceledException
Thrown if
cancellationToken
is cancelled.
GetNuspecFile()
Gets a nuspec file path.
public virtual string GetNuspecFile()
Returns
- string
The nuspec file path.
GetNuspecFile(IEnumerable<string>)
protected static string GetNuspecFile(IEnumerable<string> files)
Parameters
files
IEnumerable<string>
Returns
GetNuspecFileAsync(CancellationToken)
Asynchronously gets a nuspec file path.
public virtual Task<string> GetNuspecFileAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationTokenA cancellation token.
Returns
- Task<string>
A task that represents the asynchronous operation. The task result (Result) returns a string representing the nuspec file path.
Exceptions
- OperationCanceledException
Thrown if
cancellationToken
is cancelled.
GetNuspecReaderAsync(CancellationToken)
public virtual Task<NuspecReader> GetNuspecReaderAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationToken
Returns
GetPackageDependencies()
Returns package dependencies.
public virtual IEnumerable<PackageDependencyGroup> GetPackageDependencies()
Returns
GetPackageDependenciesAsync(CancellationToken)
Asynchronously returns package dependencies.
public virtual Task<IEnumerable<PackageDependencyGroup>> GetPackageDependenciesAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationTokenA cancellation token.
Returns
- Task<IEnumerable<PackageDependencyGroup>>
A task that represents the asynchronous operation. The task result (Result) returns an IEnumerable<T>.
GetPackageTypes()
Gets zero or more package types from the .nuspec.
public virtual IReadOnlyList<PackageType> GetPackageTypes()
Returns
- IReadOnlyList<PackageType>
A readonly list of package types.
GetPackageTypesAsync(CancellationToken)
Asynchronously gets zero or more package types from the .nuspec.
public virtual Task<IReadOnlyList<PackageType>> GetPackageTypesAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationTokenA cancellation token.
Returns
- Task<IReadOnlyList<PackageType>>
A task that represents the asynchronous operation. The task result (Result) returns an IReadOnlyList<T>.
Exceptions
- OperationCanceledException
Thrown if
cancellationToken
is cancelled.
GetPrimarySignatureAsync(CancellationToken)
Get package signature.
public abstract Task<PrimarySignature> GetPrimarySignatureAsync(CancellationToken token)
Parameters
token
CancellationToken
Returns
Remarks
Returns a null if the package is unsigned.
GetReferenceItems()
Returns lib items + filtering based on the nuspec and other NuGet rules.
public virtual IEnumerable<FrameworkSpecificGroup> GetReferenceItems()
Returns
GetReferenceItemsAsync(CancellationToken)
Asynchronously returns lib items + filtering based on the nuspec and other NuGet rules.
public virtual Task<IEnumerable<FrameworkSpecificGroup>> GetReferenceItemsAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationTokenA cancellation token.
Returns
- Task<IEnumerable<FrameworkSpecificGroup>>
A task that represents the asynchronous operation. The task result (Result) returns an IEnumerable<T>.
GetStream(string)
Gets a file stream from the package.
public abstract Stream GetStream(string path)
Parameters
path
string
Returns
- Stream
A stream for a file in the package.
GetStreamAsync(string, CancellationToken)
Asynchronously returns a file stream from the package.
public virtual Task<Stream> GetStreamAsync(string path, CancellationToken cancellationToken)
Parameters
path
stringThe file path in the package.
cancellationToken
CancellationTokenA cancellation token.
Returns
- Task<Stream>
A task that represents the asynchronous operation. The task result (Result) returns a Stream.
Exceptions
- OperationCanceledException
Thrown if
cancellationToken
is cancelled.
GetSupportedFrameworks()
Frameworks mentioned in the package.
public virtual IEnumerable<NuGetFramework> GetSupportedFrameworks()
Returns
- IEnumerable<NuGetFramework>
Remarks
This method returns the target frameworks supported for packages.config projects. For PackageReference compatibility, use ManagedCodeConventions
GetSupportedFrameworksAsync(CancellationToken)
Frameworks mentioned in the package.
public virtual Task<IEnumerable<NuGetFramework>> GetSupportedFrameworksAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationToken
Returns
- Task<IEnumerable<NuGetFramework>>
Remarks
This method returns the target frameworks supported for packages.config projects. For PackageReference compatibility, use ManagedCodeConventions
GetToolItems()
Returns all items under the tools folder.
public virtual IEnumerable<FrameworkSpecificGroup> GetToolItems()
Returns
GetToolItemsAsync(CancellationToken)
Asynchronously returns all items under the tools folder.
public virtual Task<IEnumerable<FrameworkSpecificGroup>> GetToolItemsAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationTokenA cancellation token.
Returns
- Task<IEnumerable<FrameworkSpecificGroup>>
A task that represents the asynchronous operation. The task result (Result) returns an IEnumerable<T>.
IsAllowedBuildFile(string, string)
only packageId.targets and packageId.props should be used from the build folder
protected static bool IsAllowedBuildFile(string packageId, string path)
Parameters
Returns
IsReferenceAssembly(string)
True only for assemblies that should be added as references to msbuild projects
protected static bool IsReferenceAssembly(string path)
Parameters
path
string
Returns
IsServiceable()
public virtual bool IsServiceable()
Returns
IsServiceableAsync(CancellationToken)
public virtual Task<bool> IsServiceableAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationToken
Returns
IsSignedAsync(CancellationToken)
Check if a package contains signing information.
public abstract Task<bool> IsSignedAsync(CancellationToken token)
Parameters
token
CancellationToken
Returns
NormalizeDirectoryPath(string)
protected string NormalizeDirectoryPath(string path)
Parameters
path
string
Returns
ValidateIntegrityAsync(SignatureContent, CancellationToken)
Checks for the integrity of a package
public abstract Task ValidateIntegrityAsync(SignatureContent signatureContent, CancellationToken token)
Parameters
signatureContent
SignatureContentSignatureContent with expected hash value and hash algorithm used
token
CancellationToken
Returns
ValidatePackageEntries(string, IEnumerable<string>, PackageIdentity)
protected static void ValidatePackageEntries(string normalizedDestination, IEnumerable<string> packageFiles, PackageIdentity packageIdentity)
Parameters
normalizedDestination
stringpackageFiles
IEnumerable<string>packageIdentity
PackageIdentity
ValidatePackageEntry(string, string, PackageIdentity)
Validate file entry in package is not traversed outside of the expected extraction path. Eg: file entry like ../../foo.dll can get outside of the expected extraction path.
protected static void ValidatePackageEntry(string normalizedDestination, string normalizedFilePath, PackageIdentity packageIdentity)
Parameters
normalizedDestination
stringnormalizedFilePath
stringpackageIdentity
PackageIdentity