/// <summary> /// Harvest a reg file. /// </summary> /// <param name="path">The path of the file.</param> /// <returns>A harvested registy file.</returns> public Wix.Fragment HarvestRegFile(string path) { if (null == path) { throw new ArgumentNullException("path"); } if (!File.Exists(path)) { throw new WixException(UtilErrors.FileNotFound(path)); } Wix.Directory directory = new Wix.Directory(); directory.Id = "TARGETDIR"; // Use absolute paths path = Path.GetFullPath(path); FileInfo file = new FileInfo(path); using (StreamReader sr = file.OpenText()) { string line; this.currentLineNumber = 0; while (null != (line = this.GetNextLine(sr))) { if (line.StartsWith(@"Windows Registry Editor Version 5.00")) { this.unicodeRegistry = true; } else if (line.StartsWith(@"REGEDIT4")) { this.unicodeRegistry = false; } else if (line.StartsWith(@"[HKEY_CLASSES_ROOT\")) { this.ConvertKey(sr, ref directory, Wix.RegistryRootType.HKCR, line.Substring(19, line.Length - 20)); } else if (line.StartsWith(@"[HKEY_CURRENT_USER\")) { this.ConvertKey(sr, ref directory, Wix.RegistryRootType.HKCU, line.Substring(19, line.Length - 20)); } else if (line.StartsWith(@"[HKEY_LOCAL_MACHINE\")) { this.ConvertKey(sr, ref directory, Wix.RegistryRootType.HKLM, line.Substring(20, line.Length - 21)); } else if (line.StartsWith(@"[HKEY_USERS\")) { this.ConvertKey(sr, ref directory, Wix.RegistryRootType.HKU, line.Substring(12, line.Length - 13)); } } } Console.WriteLine("Processing complete"); Wix.Fragment fragment = new Wix.Fragment(); fragment.AddChild(directory); return(fragment); }
/// <summary> /// Harvest a payload. /// </summary> /// <param name="path">The path of the payload.</param> /// <returns>A harvested payload.</returns> public Wix.RemotePayload HarvestRemotePayload(string path) { if (null == path) { throw new ArgumentNullException("path"); } if (!File.Exists(path)) { throw new WixException(UtilErrors.FileNotFound(path)); } Wix.RemotePayload remotePayload = new Wix.RemotePayload(); FileInfo fileInfo = new FileInfo(path); remotePayload.Size = (int)fileInfo.Length; remotePayload.Hash = this.GetFileHash(path); FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(path); if (null != versionInfo) { // Use the fixed version info block for the file since the resource text may not be a dotted quad. Version version = new Version(versionInfo.ProductMajorPart, versionInfo.ProductMinorPart, versionInfo.ProductBuildPart, versionInfo.ProductPrivatePart); remotePayload.Version = version.ToString(); remotePayload.Description = versionInfo.FileDescription; remotePayload.ProductName = versionInfo.ProductName; } return(remotePayload); }
/// <summary> /// Harvest a payload. /// </summary> /// <param name="path">The path of the payload.</param> /// <returns>A harvested payload.</returns> public Wix.RemotePayload HarvestRemotePayload(string path) { if (null == path) { throw new ArgumentNullException("path"); } if (!File.Exists(path)) { throw new WixException(UtilErrors.FileNotFound(path)); } PayloadInfo payloadInfo = new PayloadInfo() { SourceFile = Path.GetFullPath(path), SuppressSignatureValidation = false // assume signed, if its unsigned it won't get the certificate properties }; PayloadInfoRow.ResolvePayloadInfo(payloadInfo); return(payloadInfo); }
/// <summary> /// Harvest a file. /// </summary> /// <param name="path">The path of the file.</param> /// <returns>A harvested file.</returns> public Wix.File HarvestFile(string path) { if (null == path) { throw new ArgumentNullException("path"); } if (!File.Exists(path)) { throw new WixException(UtilErrors.FileNotFound(path)); } Wix.File file = new Wix.File(); // use absolute paths path = Path.GetFullPath(path); file.KeyPath = Wix.YesNoType.yes; file.Source = String.Concat("SourceDir\\", Path.GetFileName(path)); return(file); }