Example #1
0
 public TargetId(string path, string config, string platform)
 {
     Path   = path;
     Target = new TargetDef()
     {
         Config   = config,
         Platform = platform
     };
 }
Example #2
0
        private void LoadFiles(XmlDocument doc, string memberName, string nodeXpath)
        {
            Type      targetModelT  = typeof(TargetModel);
            FieldInfo listFieldInfo = targetModelT.GetField(
                memberName,
                BindingFlags.Public | BindingFlags.Instance);

            foreach (TargetModel target in _result.Targets)
            {
                listFieldInfo.SetValue(target, new List <string>());
            }

            var includes = doc.SelectNodes(nodeXpath, _nsMan);

            if (includes != null)
            {
                for (int i = 0; i < includes.Count; i++)
                {
                    XmlNode includeNode = includes[i];
                    string  path        = includeNode.Attributes["Include"].Value;
                    var     exclusions  = includeNode.SelectNodes("/msb:ExcludedFromBuild", _nsMan);

                    foreach (TargetModel target in _result.Targets)
                    {
                        bool excluded = false;
                        if (exclusions != null)
                        {
                            foreach (XmlNode exclusion in exclusions)
                            {
                                string    condition = exclusion.Attributes["condition"].Value;
                                TargetDef targetDef = GetTargetDefFromCondition(condition);
                                if (targetDef == target.TargetDef)
                                {
                                    excluded = true;
                                    break;
                                }
                            }
                        }

                        if (!excluded)
                        {
                            path = ResolveFilePath(path);
                            var values = listFieldInfo.GetValue(target) as List <string>;
                            values.Add(path);
                        }
                    }
                }
            }
        }
Example #3
0
        TargetDef GetTargetDefFromCondition(string condition)
        {
            // Get the configuration and platform from the condition
            const string kPattern = @"^'\$\(Configuration\)\|\$\(Platform\)'=='(.*)\|(.*)'$";
            var          regex    = new Regex(kPattern);
            Match        match    = regex.Match(condition);

            if (match.Success && (match.Groups.Count == 3))
            {
                var target = new TargetDef();
                target.Config   = match.Groups[1].Value;
                target.Platform = match.Groups[2].Value;
                return(target);
            }
            else
            {
                throw new Exception("Invalid Condition in ItemDefinitionGroup!: " + condition);
            }
        }