private void InstallProviderFromInstaller(DynamicElement provider, string fastPath, BootstrapRequest request) { string tmpFile = null; var failedBecauseInvalid = false; // download the file foreach (var link in provider.XPath("/swid:SoftwareIdentity/swid:Link[@rel = 'installationmedia']")) { var href = link.Attributes["href"]; if (string.IsNullOrWhiteSpace(href) || !Uri.IsWellFormedUriString(href, UriKind.Absolute)) { request.Debug("Bad or missing uri: {0}", href); continue; } var artifact = link.Attributes["artifact"]; try { tmpFile = artifact.GenerateTemporaryFilename(); request.Debug("Downloading '{0}' to '{1}'", href, tmpFile); if (!request.DownloadFileToLocation(new Uri(href), tmpFile)) { request.Debug("Failed download of '{0}'", href); continue; } request.Debug("Verifying the package"); var valid = request.ProviderServices.IsSignedAndTrusted(tmpFile, request); if (!valid) { request.Debug("Not Valid file '{0}' => '{1}'", href, tmpFile); failedBecauseInvalid = true; request.Warning(Constants.Messages.FileFailedVerification, href); #if !DEBUG tmpFile.TryHardToDelete(); continue; #endif } // we have a valid file. // run the installer if (request.ProviderServices.Install(tmpFile, "", request)) { // it installed ok! request.YieldFromSwidtag(provider, null, null, null, fastPath); PackageManagementService.LoadProviders(request.As <IRequest>()); } else { request.Error(ErrorCategory.InvalidOperation, fastPath, Constants.Messages.FailedProviderBootstrap, fastPath); } } catch (Exception e) { e.Dump(); } finally { if (!string.IsNullOrWhiteSpace(tmpFile)) { tmpFile.TryHardToDelete(); } } } if (failedBecauseInvalid) { request.Error(ErrorCategory.InvalidData, fastPath, Constants.Messages.FileFailedVerification, fastPath); } }