public int CreateManifestDocument(string path) { int r = ERROR_ROOTPATH_NOT_SPECIFIED; if (!string.IsNullOrEmpty(rootPath)) { r = ERROR_PROCUCT_NOT_SPECIFIED; if (!string.IsNullOrEmpty(applicationId)) { r = ERROR_PUBLISHER_NOT_SPECIFIED; if (!string.IsNullOrEmpty(publisherId)) { r = ERROR_NEWVERSION_NOT_SPECIFIED; if (newApplicationVersion != null) { r = ERROR_UPDATELOCATION_NOT_SPECIFIED; if (!string.IsNullOrEmpty(globalUpdateLocation)) { r = ERROR_ROOTPATH_NOT_FOUND; if (Directory.Exists(rootPath)) { r = ERROR_SUCCESS; DeployManifest appMan = new DeployManifest(); if (!string.IsNullOrEmpty(description)) { appMan.Description = description; } appMan.Product = applicationId; appMan.Publisher = publisherId; appMan.AssemblyIdentity.Name = applicationId; appMan.AssemblyIdentity.ProcessorArchitecture = platform.ToString(); if (targetApplicationVersion != null) { appMan.MinimumRequiredVersion = targetApplicationVersion.ToString(); } appMan.AssemblyIdentity.Version = newApplicationVersion.ToString(); string s1 = globalUpdateLocation; if ((copyMethod == FileCopyMethod.http) || (copyMethod == FileCopyMethod.ftp)) { s1 = s1.Replace("\\", "/"); } if (!s1.StartsWith(FileCopyMethod.file.ToString() + "://", StringComparison.CurrentCultureIgnoreCase) && !s1.StartsWith(FileCopyMethod.http.ToString() + "://", StringComparison.CurrentCultureIgnoreCase) && !s1.StartsWith(FileCopyMethod.ftp.ToString() + "://", StringComparison.CurrentCultureIgnoreCase)) { if ((copyMethod == FileCopyMethod.http) || (copyMethod == FileCopyMethod.ftp)) { s1 = copyMethod.ToString() + "://" + s1; } } appMan.DeploymentUrl = s1; if ((postUpdateCommand != null) && !string.IsNullOrEmpty(postUpdateCommand.executable)) { appMan.SupportUrl = postUpdateCommand.executable + ";" + ((postUpdateCommand.targetpath == null) ? string.Empty : postUpdateCommand.targetpath) + ";" + ((postUpdateCommand.arguments == null) ? string.Empty : postUpdateCommand.arguments) + ";" + postUpdateCommand.delete.ToString(); if (GetFileReferenceIndex(postUpdateCommand.executable) < 0) { AddFileReference(postUpdateCommand.executable, postUpdateCommand.targetpath); } } if (GetListCount(files) > 0) { foreach (Object obj in files) { appMan.FileReferences.Add(obj as FileReference); } } if (GetListCount(assemblies) > 0) { foreach (Object obj in assemblies) { appMan.AssemblyReferences.Add(obj as AssemblyReference); } } s1 = manifestFileName; if (string.IsNullOrEmpty(s1)) { s1 = Path.Combine(rootPath, DEFAULT_MANIFEST_FILENAME); } else if (!s1.Contains(Path.DirectorySeparatorChar.ToString()) && !s1.Contains(Path.AltDirectorySeparatorChar.ToString())) { s1 = Path.Combine(rootPath, s1); } appMan.SourcePath = s1; appMan.ResolveFiles(new string[] { rootPath }); if (useValidation) { appMan.UpdateFileInfo(); } if (string.IsNullOrEmpty(path)) { ManifestWriter.WriteManifest(appMan); } else { ManifestWriter.WriteManifest(appMan, path); } } } } } } } return(r); }
public int CreateManifestDocument(string path) { int r = ERROR_ROOTPATH_NOT_SPECIFIED; if (!string.IsNullOrEmpty(rootPath)) { r = ERROR_PROCUCT_NOT_SPECIFIED; if (!string.IsNullOrEmpty(applicationId)) { r = ERROR_PUBLISHER_NOT_SPECIFIED; if (!string.IsNullOrEmpty(publisherId)) { r = ERROR_NEWVERSION_NOT_SPECIFIED; if (newApplicationVersion != null) { r = ERROR_UPDATELOCATION_NOT_SPECIFIED; if (!string.IsNullOrEmpty(globalUpdateLocation)) { r = ERROR_ROOTPATH_NOT_FOUND; if (Directory.Exists(rootPath)) { r = ERROR_SUCCESS; manifestDocument = new XmlDocument(); XmlProcessingInstruction xPI = manifestDocument.CreateProcessingInstruction("xml", XML_PROCESSING_INSTRUCTION + " encoding=\"" + System.Text.Encoding.UTF8.WebName + "\""); manifestDocument.AppendChild(xPI); XmlComment xComment = manifestDocument.CreateComment(XML_COMMENT); manifestDocument.AppendChild(xComment); XmlElement xElmntRoot = manifestDocument.CreateElement(XML_ELEMENT_ROOT); xElmntRoot.SetAttribute(XML_ELEMENT_ROOT_ATTRIBUTE_APPLICATION_ID, applicationId); xElmntRoot.SetAttribute(XML_ELEMENT_ROOT_ATTRIBUTE_PUBLISHER_ID, publisherId); xElmntRoot.SetAttribute(XML_ELEMENT_ROOT_ATTRIBUTE_APPLICATION_PLATFORM, platform.ToString()); if (targetApplicationVersion != null) { xElmntRoot.SetAttribute(XML_ELEMENT_ROOT_ATTRIBUTE_APPLICATION_TARGETVERSION, targetApplicationVersion.ToString()); } if (!string.IsNullOrEmpty(description)) { XmlElement xDesc = manifestDocument.CreateElement(XML_ELEMENT_DESCRIPTION); xDesc.InnerText = description; xElmntRoot.AppendChild(xDesc); } string s = globalUpdateLocation; if ((copyMethod == FileCopyMethod.http) || (copyMethod == FileCopyMethod.ftp)) { s = s.Replace("\\", "/"); } if (!s.StartsWith(FileCopyMethod.file.ToString() + "://", StringComparison.CurrentCultureIgnoreCase) && !s.StartsWith(FileCopyMethod.http.ToString() + "://", StringComparison.CurrentCultureIgnoreCase) && !s.StartsWith(FileCopyMethod.ftp.ToString() + "://", StringComparison.CurrentCultureIgnoreCase)) { if ((copyMethod == FileCopyMethod.http) || (copyMethod == FileCopyMethod.ftp)) { s = copyMethod.ToString() + "://" + s; } } XmlElement xCopy = manifestDocument.CreateElement(XML_ELEMENT_UPDATE_LOCATION); xCopy.InnerText = s; xElmntRoot.AppendChild(xCopy); xCopy = manifestDocument.CreateElement(XML_ELEMENT_NEW_APPLICATION_VERSION); xCopy.InnerText = newApplicationVersion.ToString(); xElmntRoot.AppendChild(xCopy); xCopy = CreatePostUpdateCommand(postUpdateCommand); if (xCopy != null) { xElmntRoot.AppendChild(xCopy); if (GetFileReferenceIndex(postUpdateCommand.executable) < 0) { AddFileReference(postUpdateCommand.executable, postUpdateCommand.targetpath); } } xCopy = CreateFileList(); if (xCopy != null) { xElmntRoot.AppendChild(xCopy); } manifestDocument.AppendChild(xElmntRoot); if (string.IsNullOrEmpty(path)) { path = manifestFileName; } if (string.IsNullOrEmpty(path)) { path = DEFAULT_MANIFEST_FILENAME; } manifestDocument.Save(path); } } } } } } return(r); }