Esempio n. 1
0
        private bool TryRunInstallerForAsset(string assetId, out int installerExitCode, out string error)
        {
            error             = null;
            installerExitCode = 0;

            bool   installerIsRun = false;
            string path;
            string installerArgs;

            if (this.TryGetLocalInstallerPath(assetId, out path, out installerArgs))
            {
                if (!this.dryRun)
                {
                    string logFilePath = GSDEnlistment.GetNewLogFileName(
                        ProductUpgraderInfo.GetLogDirectoryPath(),
                        Path.GetFileNameWithoutExtension(path),
                        this.UpgradeInstanceId,
                        this.fileSystem);

                    string args     = installerArgs + " /Log=" + logFilePath;
                    string certCN   = null;
                    string issuerCN = null;
                    switch (assetId)
                    {
                    case GSDAssetId:
                    {
                        certCN   = GSDSigner;
                        issuerCN = GSDCertIssuer;
                        break;
                    }

                    case GitAssetId:
                    {
                        certCN   = GitSigner;
                        issuerCN = GitCertIssuer;
                        break;
                    }
                    }

                    this.RunInstaller(path, args, certCN, issuerCN, out installerExitCode, out error);

                    if (installerExitCode != 0 && string.IsNullOrEmpty(error))
                    {
                        error = assetId + " installer failed. Error log: " + logFilePath;
                    }
                }

                installerIsRun = true;
            }
            else
            {
                error = "Could not find downloaded installer for " + assetId;
            }

            return(installerIsRun);
        }
Esempio n. 2
0
        protected virtual bool TryDownloadAsset(Asset asset, out string errorMessage)
        {
            errorMessage = null;

            string    downloadPath = ProductUpgraderInfo.GetAssetDownloadsPath();
            string    localPath    = Path.Combine(downloadPath, asset.Name);
            WebClient webClient    = new WebClient();

            try
            {
                webClient.DownloadFile(asset.DownloadURL, localPath);
                asset.LocalPath = localPath;
            }
            catch (WebException webException)
            {
                errorMessage = "Download error: " + webException.Message;
                this.TraceException(webException, nameof(this.TryDownloadAsset), $"Error downloading asset {asset.Name}.");
                return(false);
            }

            return(true);
        }
 public void DeleteAllInstallerDownloads()
 {
     try
     {
         this.fileSystem.DeleteDirectory(GetAssetDownloadsPath());
     }
     catch (Exception ex)
     {
         if (this.tracer != null)
         {
             this.tracer.RelatedError($"{nameof(this.DeleteAllInstallerDownloads)}: Could not remove directory: {ProductUpgraderInfo.GetAssetDownloadsPath()}.{ex.ToString()}");
         }
     }
 }