static int Main(string[] args) { try { if (args.Length != 1) { Usage(); throw new ArgumentException("filename"); } WixPreprocessor preprocessor = new WixPreprocessor(args[0]); XmlDocument xml = new XmlDocument(); preprocessor.Preprocess(); //Console.WriteLine(preprocessor.Result); xml.LoadXml(preprocessor.Result); XmlNamespaceManager nsm = new XmlNamespaceManager(xml.NameTable); nsm.AddNamespace("wix", "http://schemas.microsoft.com/wix/2006/wi"); TransformProducts(xml, nsm); TransformModules(xml, nsm); return(0); } catch (Exception ex) { Console.WriteLine(ex.Message); return(-1); } }
static int Main(string[] args) { try { if (args.Length != 1) { Usage(); throw new ArgumentException("filename"); } WixPreprocessor preprocessor = new WixPreprocessor(args[0]); XmlDocument xml = new XmlDocument(); preprocessor.Preprocess(); //Console.WriteLine(preprocessor.Result); xml.LoadXml(preprocessor.Result); XmlNamespaceManager nsm = new XmlNamespaceManager(xml.NameTable); nsm.AddNamespace("wix", "http://schemas.microsoft.com/wix/2006/wi"); TransformProducts(xml, nsm); TransformModules(xml, nsm); return 0; } catch (Exception ex) { Console.WriteLine(ex.Message); return -1; } }
public void Preprocess() { StringBuilder sb = new StringBuilder(); StreamReader r = new StreamReader(_filename); while (!r.EndOfStream) { string line = r.ReadLine(); // <?define ?> Match m_define = Regex.Match(line, @"\<\?define\s(?<name>.*)=(?<value>.*)\?\>"); if (m_define.Success) { // Console.WriteLine("{0}: {1} - {2}", line, m_define.Success, m_define.Length); string value = m_define.Groups["value"].Value; value = value.Trim("\" '".ToCharArray()); value = Expand(value); // Console.WriteLine("Value: {0}", value); _defines[m_define.Groups["name"].Value] = value; } Match m_include = Regex.Match(line, @"\<\?include\s(?<filename>.*)\s\?\>"); if (m_include.Success) { string filename = m_include.Groups["filename"].Value; filename = Path.Combine(_root, filename); // preprocess internals XmlDocument includexml = new XmlDocument(); // Console.WriteLine("Preprocessing {0}", filename); WixPreprocessor innerpreprocessor = new WixPreprocessor(filename, _root); innerpreprocessor._defines = _defines; innerpreprocessor.Preprocess(); // Console.WriteLine("Done preprocessing {0}", filename); //Console.WriteLine(innerpreprocessor.Result); includexml.LoadXml(innerpreprocessor.Result); line = includexml.DocumentElement.InnerXml; } sb.AppendLine(Expand(line)); } _result = sb.ToString(); }