Class DeploymentHelper
Deployment related defintions and utilities.
Namespace: Neon.Deployment
Assembly: Neon.Deployment.dll
Syntax
public static class DeploymentHelper
Fields
DownloadManifestContentType
The HTTP Content-Type used for multi-part download manifest.
Declaration
public const string DownloadManifestContentType = "application/vnd+neonforge.download+manifest+json"
Field Value
Type | Description |
---|---|
string |
NeonProfileServicePipe
Identifies the named pipe used to communicate with the Neon profile service running on the local workstation to query for user profile information as well as secrets.
Declaration
public const string NeonProfileServicePipe = "neon-profile-service"
Field Value
Type | Description |
---|---|
string |
Methods
ClearPowershellHistory()
Clears the Powershell command history. It's possible that scripts and GitHub workflow runs may leave sensitive information in the command history which could become a security vunerability.
Declaration
public static void ClearPowershellHistory()
DownloadMultiPart(DownloadManifest, string, DownloadProgressDelegate, IRetryPolicy, TimeSpan, bool)
Synchronously downloads and assembles a multi-part file as specified by a DownloadManifest.
Declaration
public static void DownloadMultiPart(DownloadManifest download, string targetPath, DownloadProgressDelegate progressAction = null, IRetryPolicy retry = null, TimeSpan partTimeout = default, bool strictCheck = false)
Parameters
Type | Name | Description |
---|---|---|
DownloadManifest | download | The download details. |
string | targetPath | The target file path. |
DownloadProgressDelegate | progressAction | Optionally specifies an action to be called with the the percentage downloaded. |
IRetryPolicy | retry | Optionally specifies the retry policy. This defaults to a reasonable policy. |
TimeSpan | partTimeout | Optionally specifies the HTTP download timeout for each part (defaults to 10 minutes). |
bool | strictCheck | Optionally used to enable a slow but more comprehensive check of any existing file. When this is enabled and the download file already exists along with its MD5 hash file, the method will assume that the existing file matches when the file size is the same as specified in the manifest and manifest overall MD5 matches the local MD5 file. Otherwise, this method will need to compute the MD5 hashes for the existing file parts and compare those to the part MD5 hashes in the manifest, which can take quite a while for large files.
This defaults to |
Exceptions
Type | Condition |
---|---|
IOException | Thrown when the download is corrupt. |
SocketException | Thrown for network errors. |
HttpException | Thrown for HTTP network errors. |
OperationCanceledException | Thrown when the operation was cancelled. |
DownloadMultiPart(string, string, DownloadProgressDelegate, IRetryPolicy, TimeSpan, bool)
Asynchronously downloads and assembles a multi-part file as specified by a source URI.
Declaration
public static void DownloadMultiPart(string uri, string targetPath, DownloadProgressDelegate progressAction = null, IRetryPolicy retry = null, TimeSpan partTimeout = default, bool strictCheck = true)
Parameters
Type | Name | Description |
---|---|---|
string | uri | The URI for the source URI holding the DownloadManifest details as JSON. |
string | targetPath | The target file path. |
DownloadProgressDelegate | progressAction | Optionally specifies an action to be called with the the percentage downloaded. |
IRetryPolicy | retry | Optionally specifies the retry policy. This defaults to a reasonable policy. |
TimeSpan | partTimeout | Optionally specifies the HTTP download timeout for each part (defaults to 10 minutes). |
bool | strictCheck | Optionally used to enable a slow but more comprehensive check of any existing file. When this is enabled and the download file already exists along with its MD5 hash file, the method will assume that the existing file matches when the file size is the same as specified in the manifest and manifest overall MD5 matches the local MD5 file. Otherwise, this method will need to compute the MD5 hashes for the existing file parts and compare those to the part MD5 hashes in the manifest, which can take quite a while for large files.
This defaults to |
Exceptions
Type | Condition |
---|---|
IOException | Thrown when the download is corrupt. |
SocketException | Thrown for network errors. |
HttpException | Thrown for HTTP network errors. |
OperationCanceledException | Thrown when the operation was cancelled. |
FormatException | Thrown when the object retrieved from |
DownloadMultiPartAsync(DownloadManifest, string, DownloadProgressDelegate, TimeSpan, IRetryPolicy, bool, CancellationToken)
Asynchronously downloads and assembles a multi-part file as specified by a DownloadManifest.
Declaration
public static Task<string> DownloadMultiPartAsync(DownloadManifest manifest, string targetPath, DownloadProgressDelegate progressAction = null, TimeSpan partTimeout = default, IRetryPolicy retry = null, bool strictCheck = false, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
DownloadManifest | manifest | The download details. |
string | targetPath | The target file path. |
DownloadProgressDelegate | progressAction | Optionally specifies an action to be called with the the percentage downloaded. |
TimeSpan | partTimeout | Optionally specifies the HTTP download timeout for each part (defaults to 10 minutes). |
IRetryPolicy | retry | Optionally specifies the retry policy. This defaults to a reasonable policy. |
bool | strictCheck | Optionally used to disable a slow but more comprehensive check of any existing file. When this is disabled and the download file already exists along with its MD5 hash file, the method will assume that the existing file matches when the file size is the same as specified in the manifest and manifest overall MD5 matches the local MD5 file.
Otherwise when
This defaults to |
CancellationToken | cancellationToken | Optionally specifies the operation cancellation token. |
Returns
Type | Description |
---|---|
Task<string> | The path to the downloaded file. |
Remarks
This method downloads the file specified by manifest
to the folder specified, creating
the folder first when required. The file will be downloaded in parts, where each part will be validated
by comparing the part's MD5 hash (when present) with the computed value. The output file will be named
Name and the overall MD5 hash will also be saved using the same file name but
adding the .md5 extension.
This method will continue downloading a partially downloaded file. This works by validating the already downloaded parts against their MD5 hashes and then continuing part downloads after the last valid part. Nothing will be downloaded when the existing file is fully formed.
note
The target files (output and MD5) will be deleted when download appears to be corrupt.
Exceptions
Type | Condition |
---|---|
IOException | Thrown when the download is corrupt. |
SocketException | Thrown for network errors. |
HttpException | Thrown for HTTP network errors. |
OperationCanceledException | Thrown when the operation was cancelled. |
DownloadMultiPartAsync(string, string, DownloadProgressDelegate, TimeSpan, IRetryPolicy, bool, CancellationToken)
Asynchronously downloads and assembles a multi-part file as specified by a DownloadManifest.
Declaration
public static Task<string> DownloadMultiPartAsync(string uri, string targetPath, DownloadProgressDelegate progressAction = null, TimeSpan partTimeout = default, IRetryPolicy retry = null, bool strictCheck = false, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | uri | The URI for the source URI holding the DownloadManifest details as JSON. |
string | targetPath | The target file path. |
DownloadProgressDelegate | progressAction | Optionally specifies an action to be called with the the percentage downloaded. |
TimeSpan | partTimeout | Optionally specifies the HTTP download timeout for each part (defaults to 10 minutes). |
IRetryPolicy | retry | Optionally specifies the retry policy. This defaults to a reasonable policy. |
bool | strictCheck | Optionally used to enable a slow but more comprehensive check of any existing file. When this is enabled and the download file already exists along with its MD5 hash file, the method will assume that the existing file matches when the file size is the same as specified in the manifest and manifest overall MD5 matches the local MD5 file. Otherwise, this method will need to compute the MD5 hashes for the existing file parts and compare those to the part MD5 hashes in the manifest, which can take quite a while for large files.
This defaults to |
CancellationToken | cancellationToken | Optionally specifies the operation cancellation token. |
Returns
Type | Description |
---|---|
Task<string> | The path to the downloaded file. |
Remarks
This method downloads the file specified by uri
to the folder specified, creating
the folder first when required. The file will be downloaded in parts, where each part will be validated
by comparing the part's MD5 hash (when present) with the computed value. The output file will be named
Name and the overall MD5 hash will also be saved using the same file name but
adding the .md5 extension.
This method will continue downloading a partially downloaded file. This works by validating the already downloaded parts against their MD5 hashes and then continuing part downloads after the last valid part. Nothing will be downloaded when the existing file is fully formed.
note
The target files (output and MD5) will be deleted when download appears to be corrupt.
Exceptions
Type | Condition |
---|---|
IOException | Thrown when the download is corrupt. |
SocketException | Thrown for network errors. |
HttpException | Thrown for HTTP network errors. |
OperationCanceledException | Thrown when the operation was cancelled. |
FormatException | Thrown when the object retrieved from |