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
frameworkProviderIFrameworkNameProviderA framework mapping provider.
Exceptions
- ArgumentNullException
Thrown if
frameworkProviderisnull.
PackageReaderBase(IFrameworkNameProvider, IFrameworkCompatibilityProvider)
Instantiates a new PackageReaderBase class.
public PackageReaderBase(IFrameworkNameProvider frameworkProvider, IFrameworkCompatibilityProvider compatibilityProvider)
Parameters
frameworkProviderIFrameworkNameProviderA framework mapping provider.
compatibilityProviderIFrameworkCompatibilityProviderA framework compatibility provider.
Exceptions
- ArgumentNullException
Thrown if
frameworkProviderisnull.- ArgumentNullException
Thrown if
compatibilityProviderisnull.
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
verifierSettingsSignedPackageVerifierSettingsPackage 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
destinationstringThe destination folder path.
packageFilesIEnumerable<string>The package files to copy.
extractFileExtractPackageFileDelegateA package file extraction delegate.
loggerILoggerA logger.
tokenCancellationTokenA 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
destinationstringThe destination path to copy to.
packageFilesIEnumerable<string>The package files to copy.
extractFileExtractPackageFileDelegateA package file extraction delegate.
loggerILoggerA logger.
cancellationTokenCancellationTokenA 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
cancellationTokenis cancelled.
CopyNupkgAsync(string, CancellationToken)
public virtual Task<string> CopyNupkgAsync(string nupkgFilePath, CancellationToken cancellationToken)
Parameters
nupkgFilePathstringcancellationTokenCancellationToken
Returns
Dispose()
public void Dispose()
Dispose(bool)
protected abstract void Dispose(bool disposing)
Parameters
disposingbool
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
hashAlgorithmHashAlgorithmNametokenCancellationToken
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
cancellationTokenCancellationTokenA 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
tokenCancellationTokenGetUnsignedPackageHashFunc<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
cancellationTokenCancellationTokenA 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
cancellationTokenCancellationToken
Returns
GetFileGroups(string)
protected IEnumerable<FrameworkSpecificGroup> GetFileGroups(string folder)
Parameters
folderstring
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
folderstringFolder 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
folderstringA folder path in the package.
cancellationTokenCancellationTokenA 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
cancellationTokenis cancelled.
GetFilesAsync(CancellationToken)
Asynchronously gets all files in the package.
public virtual Task<IEnumerable<string>> GetFilesAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenA 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
cancellationTokenis 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
cancellationTokenCancellationTokenA 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
cancellationTokenCancellationTokenA cancellation token.
Returns
- Task<PackageIdentity>
A task that represents the asynchronous operation. The task result (Result) returns a PackageIdentity.
Exceptions
- OperationCanceledException
Thrown if
cancellationTokenis cancelled.
GetItems(string)
public virtual IEnumerable<FrameworkSpecificGroup> GetItems(string folderName)
Parameters
folderNamestring
Returns
GetItemsAsync(string, CancellationToken)
public virtual Task<IEnumerable<FrameworkSpecificGroup>> GetItemsAsync(string folderName, CancellationToken cancellationToken)
Parameters
folderNamestringcancellationTokenCancellationToken
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
cancellationTokenCancellationTokenA 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
cancellationTokenCancellationTokenA 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
cancellationTokenis 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
cancellationTokenCancellationTokenA cancellation token.
Returns
- Task<Stream>
A task that represents the asynchronous operation. The task result (Result) returns a Stream.
Exceptions
- OperationCanceledException
Thrown if
cancellationTokenis 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
filesIEnumerable<string>
Returns
GetNuspecFileAsync(CancellationToken)
Asynchronously gets a nuspec file path.
public virtual Task<string> GetNuspecFileAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenA 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
cancellationTokenis cancelled.
GetNuspecReaderAsync(CancellationToken)
public virtual Task<NuspecReader> GetNuspecReaderAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationToken
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
cancellationTokenCancellationTokenA 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
cancellationTokenCancellationTokenA 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
cancellationTokenis cancelled.
GetPrimarySignatureAsync(CancellationToken)
Get package signature.
public abstract Task<PrimarySignature> GetPrimarySignatureAsync(CancellationToken token)
Parameters
tokenCancellationToken
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
cancellationTokenCancellationTokenA 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
pathstring
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
pathstringThe file path in the package.
cancellationTokenCancellationTokenA cancellation token.
Returns
- Task<Stream>
A task that represents the asynchronous operation. The task result (Result) returns a Stream.
Exceptions
- OperationCanceledException
Thrown if
cancellationTokenis 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
cancellationTokenCancellationToken
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
cancellationTokenCancellationTokenA 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
pathstring
Returns
IsServiceable()
public virtual bool IsServiceable()
Returns
IsServiceableAsync(CancellationToken)
public virtual Task<bool> IsServiceableAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationToken
Returns
IsSignedAsync(CancellationToken)
Check if a package contains signing information.
public abstract Task<bool> IsSignedAsync(CancellationToken token)
Parameters
tokenCancellationToken
Returns
NormalizeDirectoryPath(string)
protected string NormalizeDirectoryPath(string path)
Parameters
pathstring
Returns
ValidateIntegrityAsync(SignatureContent, CancellationToken)
Checks for the integrity of a package
public abstract Task ValidateIntegrityAsync(SignatureContent signatureContent, CancellationToken token)
Parameters
signatureContentSignatureContentSignatureContent with expected hash value and hash algorithm used
tokenCancellationToken
Returns
ValidatePackageEntries(string, IEnumerable<string>, PackageIdentity)
protected static void ValidatePackageEntries(string normalizedDestination, IEnumerable<string> packageFiles, PackageIdentity packageIdentity)
Parameters
normalizedDestinationstringpackageFilesIEnumerable<string>packageIdentityPackageIdentity
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
normalizedDestinationstringnormalizedFilePathstringpackageIdentityPackageIdentity