private static void AddDependencies(FileDownloader downloader, AssemblyManifest deployManifest, AssemblyManifest appManifest, Uri sourceUriBase, string targetDirectory, string group) { long total = 0; System.Deployment.Application.Manifest.File[] filesInGroup = appManifest.GetFilesInGroup(group, true); DownloadManager.ReorderFilesForIconFile(appManifest, filesInGroup); foreach (System.Deployment.Application.Manifest.File file in filesInGroup) { Uri fileSourceUri = DownloadManager.MapFileSourceUri(deployManifest, sourceUriBase, file.Name); DownloadManager.AddFileToDownloader(downloader, deployManifest, appManifest, (object)file, fileSourceUri, targetDirectory, file.NameFS, file.HashCollection); total += (long)file.Size; } DependentAssembly[] assembliesInGroup = appManifest.GetPrivateAssembliesInGroup(group, true); foreach (DependentAssembly dependentAssembly in assembliesInGroup) { Uri fileSourceUri = DownloadManager.MapFileSourceUri(deployManifest, sourceUriBase, dependentAssembly.Codebase); DownloadManager.AddFileToDownloader(downloader, deployManifest, appManifest, (object)dependentAssembly, fileSourceUri, targetDirectory, dependentAssembly.CodebaseFS, dependentAssembly.HashCollection); total += (long)dependentAssembly.Size; } downloader.SetExpectedBytesTotal(total); if (filesInGroup.Length == 0 && assembliesInGroup.Length == 0) { throw new InvalidDeploymentException(string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("Ex_NoSuchDownloadGroup"), new object[1] { (object)group })); } }
private static void ProcessDownloadedFile(object sender, DownloadEventArgs e) { if (e.Cookie == null) { return; } string fileName = Path.GetFileName(e.FileLocalPath); FileDownloader downloader = (FileDownloader)sender; if (e.FileResponseUri != (Uri)null && !e.FileResponseUri.Equals((object)e.FileSourceUri)) { throw new InvalidDeploymentException(ExceptionTypes.AppFileLocationValidation, string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("Ex_DownloadAppFileAsmRedirected"), new object[1] { (object)fileName })); } DownloadManager.DependencyDownloadCookie cookie = (DownloadManager.DependencyDownloadCookie)e.Cookie; if (cookie.ManifestElement is DependentAssembly) { DependentAssembly manifestElement = (DependentAssembly)cookie.ManifestElement; AssemblyManifest deployManifest = cookie.DeployManifest; AssemblyManifest appManifest = cookie.AppManifest; AssemblyManifest assemblyManifest = new AssemblyManifest(e.FileLocalPath); if (!assemblyManifest.Identity.Matches(manifestElement.Identity, true)) { throw new InvalidDeploymentException(ExceptionTypes.RefDefValidation, string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("Ex_DownloadRefDefMismatch"), new object[1] { (object)fileName })); } if (assemblyManifest.Identity.Equals((object)deployManifest.Identity) || assemblyManifest.Identity.Equals((object)appManifest.Identity)) { throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("Ex_AppPrivAsmIdSameAsDeployOrApp"), new object[1] { (object)assemblyManifest.Identity.ToString() })); } System.Deployment.Application.Manifest.File[] files = assemblyManifest.Files; for (int index = 0; index < files.Length; ++index) { Uri fileSourceUri = DownloadManager.MapFileSourceUri(deployManifest, e.FileSourceUri, files[index].Name); if (!fileSourceUri.AbsoluteUri.Equals(e.FileSourceUri.AbsoluteUri, StringComparison.OrdinalIgnoreCase)) { string directoryName = Path.GetDirectoryName(e.FileLocalPath); DownloadManager.AddFileToDownloader(downloader, deployManifest, appManifest, (object)files[index], fileSourceUri, directoryName, files[index].NameFS, files[index].HashCollection); } } downloader.ComponentVerifier.AddFileForVerification(e.FileLocalPath, manifestElement.HashCollection); if (assemblyManifest.Identity.PublicKeyToken == null) { downloader.ComponentVerifier.AddSimplyNamedAssemblyForVerification(e.FileLocalPath, assemblyManifest); } else { downloader.ComponentVerifier.AddStrongNameAssemblyForVerification(e.FileLocalPath, assemblyManifest); } } else { if (!(cookie.ManifestElement is System.Deployment.Application.Manifest.File)) { return; } System.Deployment.Application.Manifest.File manifestElement = (System.Deployment.Application.Manifest.File)cookie.ManifestElement; downloader.ComponentVerifier.AddFileForVerification(e.FileLocalPath, manifestElement.HashCollection); } }