private static void AddFile(XmlDocument document, XmlElement assemblyNode, System.Deployment.Application.Manifest.File file) { XmlElement newChild = document.CreateElement("file", "urn:schemas-microsoft-com:asm.v1"); assemblyNode.AppendChild(newChild); newChild.SetAttributeNode("name", null).Value = file.Name; }
private static void ProcessDownloadedFile(object sender, DownloadEventArgs e) { if (e.Cookie != null) { string fileName = Path.GetFileName(e.FileLocalPath); FileDownloader downloader = (FileDownloader)sender; if ((e.FileResponseUri != null) && !e.FileResponseUri.Equals(e.FileSourceUri)) { throw new InvalidDeploymentException(ExceptionTypes.AppFileLocationValidation, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_DownloadAppFileAsmRedirected"), new object[] { fileName })); } DependencyDownloadCookie cookie = (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(CultureInfo.CurrentUICulture, Resources.GetString("Ex_DownloadRefDefMismatch"), new object[] { fileName })); } if (assemblyManifest.Identity.Equals(deployManifest.Identity) || assemblyManifest.Identity.Equals(appManifest.Identity)) { throw new InvalidDeploymentException(ExceptionTypes.ManifestSemanticValidation, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_AppPrivAsmIdSameAsDeployOrApp"), new object[] { assemblyManifest.Identity.ToString() })); } System.Deployment.Application.Manifest.File[] files = assemblyManifest.Files; for (int i = 0; i < files.Length; i++) { Uri fileSourceUri = MapFileSourceUri(deployManifest, e.FileSourceUri, files[i].Name); if (!fileSourceUri.AbsoluteUri.Equals(e.FileSourceUri.AbsoluteUri, StringComparison.OrdinalIgnoreCase)) { string directoryName = Path.GetDirectoryName(e.FileLocalPath); AddFileToDownloader(downloader, deployManifest, appManifest, files[i], fileSourceUri, directoryName, files[i].NameFS, files[i].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) { System.Deployment.Application.Manifest.File file = (System.Deployment.Application.Manifest.File)cookie.ManifestElement; downloader.ComponentVerifier.AddFileForVerification(e.FileLocalPath, file.HashCollection); } } }
private static void ReorderFilesForIconFile(AssemblyManifest manifest, System.Deployment.Application.Manifest.File[] files) { if ((manifest.Description != null) && (manifest.Description.IconFile != null)) { for (int i = 0; i < files.Length; i++) { if (string.Compare(files[i].NameFS, manifest.Description.IconFileFS, StringComparison.OrdinalIgnoreCase) == 0) { if (i != 0) { System.Deployment.Application.Manifest.File file = files[0]; files[0] = files[i]; files[i] = file; } return; } } } }
private static void ReorderFilesForIconFile(AssemblyManifest manifest, System.Deployment.Application.Manifest.File[] files) { if (manifest.Description == null || manifest.Description.IconFile == null) { return; } for (int index = 0; index < files.Length; ++index) { if (string.Compare(files[index].NameFS, manifest.Description.IconFileFS, StringComparison.OrdinalIgnoreCase) == 0) { if (index == 0) { break; } System.Deployment.Application.Manifest.File file = files[0]; files[0] = files[index]; files[index] = file; break; } } }