示例#1
0
        private async Task DownloadProjectPackage()
        {
            var packageRequest = new ProjectPackagePullRequest {
                ProjectPackageId      = ProjectPackageId,
                ProjectPackageVersion = ProjectPackageVersion,
            };

            ProjectPackagePullResponse packageResponse;

            try {
                packageResponse = await Transceiver.Send(packageRequest)
                                  .GetResponseAsync <ProjectPackagePullResponse>();
            }
            catch (Exception error) {
                throw new ApplicationException($"Failed to download package '{ProjectPackageId}.{ProjectPackageVersion}'! {error.Message}");
            }

            try {
                Metadata = await ProjectPackageTools.UnpackAsync(packageResponse.Filename, BinDirectory);

                AssemblyFilename = Path.Combine(BinDirectory, Metadata.AssemblyFilename);
            }
            finally {
                try {
                    File.Delete(packageResponse.Filename);
                }
                catch (Exception error) {
                    Log.Warn("Failed to remove temporary package file!", error);
                }
            }
        }
示例#2
0
        private void PackageClient_OnPullProjectPackage(string id, string version, RemoteTaskCompletionSource <string> taskHandle)
        {
            Task.Run(async() => {
                var packageRequest = new ProjectPackagePullRequest {
                    ProjectPackageId      = id,
                    ProjectPackageVersion = version,
                };

                var response = await Transceiver.Send(packageRequest)
                               .GetResponseAsync <ProjectPackagePullResponse>();

                return(response.Filename);
            }).ContinueWith(taskHandle.FromTask);
        }