Пример #1
0
 public VariablesProcessor(Project project) {
     if(project == null) new ArgumentNullException("project");
     this.project = project;
     if(project.Variables != null) {
         foreach(var variable in project.Variables) {
             preparedVariables.Add(new Tuple<string, string>(string.Concat("%", variable.Name.ToUpper(), "%"), variable.Value));
         }
     }
     DateTime now = DateTime.Now;
     preparedVariables.Add(new Tuple<string, string>("%DATETIME%", now.ToString("yyyyMMdd_HHmmss")));
     preparedVariables.Add(new Tuple<string, string>("%DATE%", now.ToString("yyyyMMdd")));
     preparedVariables.Add(new Tuple<string, string>("%TIME%", now.ToString("HHmmss")));
     preparedVariables.Add(new Tuple<string, string>("%DTHASH%", now.ToBinary().ToString()));
     preparedVariables.Add(new Tuple<string, string>("%PROGRAM%", Path.GetDirectoryName(typeof(Program).Assembly.Location)));
     preparedVariables.Add(new Tuple<string, string>("%7ZEXE%", Path.Combine(Path.GetDirectoryName(typeof(Program).Assembly.Location), "7za.exe")));
     preparedVariables.Add(new Tuple<string, string>("%7ZSFX%", Path.Combine(Path.GetDirectoryName(typeof(Program).Assembly.Location), "7z.sfx")));
 }
Пример #2
0
 static bool PrepareProject(ref string project, BCBBuildTask task) {
     if(string.IsNullOrEmpty(task.AddDefines) && (task.ProcessingItems == null || task.ProcessingItems.Length == 0))
         return false;
     XmlDocument xmlDoc = new XmlDocument();
     xmlDoc.Load(project);
     if(!string.IsNullOrEmpty(task.AddDefines)) {
         XmlNodeList definesNodeList = xmlDoc.GetElementsByTagName(DefinesTag);
         foreach(XmlNode node in definesNodeList) {
             node.Attributes["value"].Value = string.Concat(node.Attributes["value"].Value, separatorString, string.Join(separatorString, task.AddDefines.Split(separatorChars, StringSplitOptions.RemoveEmptyEntries)), separatorString);
         }
     }
     if(task.ProcessingItems != null) {
         foreach(BCBProjectProcessingItem item in task.ProcessingItems) {
             if(string.IsNullOrEmpty(item.Element)) continue;
             XmlNodeList nodeList = xmlDoc.GetElementsByTagName(item.Element);
             string[] removeList = string.IsNullOrEmpty(item.ToRemove) ? null : item.ToRemove.Split(new string[] { ";;" }, StringSplitOptions.RemoveEmptyEntries);
             foreach(XmlNode node in nodeList) {
                 if(string.IsNullOrEmpty(item.Attribute)) continue;
                 XmlAttribute attribute = node.Attributes[item.Attribute];
                 if(attribute == null) {
                     attribute = xmlDoc.CreateAttribute(item.Attribute); 
                     node.Attributes.Append(attribute);
                 }
                 if(item.Value != null) {
                     attribute.Value = item.Value;
                     continue;
                 }
                 string value = attribute.Value;                        
                 if(removeList != null) {
                     foreach(var remove in removeList) {
                         value = value.Replace(remove, "");
                     }
                 }
                 if(!string.IsNullOrEmpty(item.ToAdd)) {
                     value = value + item.ToAdd;
                 }
                 attribute.Value = value;
             }
         }
     }
     string dir = Path.GetDirectoryName(project);
     string projectName = Path.GetFileNameWithoutExtension(project);
     project = Path.Combine(dir, string.Concat(projectName, Guid.NewGuid().ToString("N"), ".bpr"));
     xmlDoc.Save(project);
     string contect = File.ReadAllText(project);
     contect.Replace("&#xD;&#xA;", Environment.NewLine);
     File.WriteAllText(project, contect);
     return true;
 }
Пример #3
0
 public TaskExecutor(Project project) {
     this.project = project;
 }