Esempio n. 1
0
 internal MSBuildItemEvaluated(MSBuildProject parent, string name, string include, string evaluatedInclude)
 {
     this.include          = include;
     this.evaluatedInclude = evaluatedInclude;
     metadata = new MSBuildPropertyGroupEvaluated(parent);
     Name     = name;
 }
        internal IMSBuildPropertyGroupEvaluated GetEvaluatedItemDefinitionProperties(string itemName)
        {
            if (itemName == null || evaluatedItemDefinitions == null)
            {
                return(null);
            }

            MSBuildPropertyGroupEvaluated evalItemDefProps = null;

            evaluatedItemDefinitions.TryGetValue(itemName, out evalItemDefProps);
            return(evalItemDefProps);
        }
Esempio n. 3
0
        static AssemblyReference CreateAssemblyReference(MSBuildEvaluatedItem it, MSBuildProject project)
        {
            var imd = new MSBuildPropertyGroupEvaluated(project);

            if (it.Metadata.Count > 0)
            {
                var properties = new Dictionary <string, IMSBuildPropertyEvaluated> ();
                foreach (var m in it.Metadata)
                {
                    properties [m.Key] = new MSBuildPropertyEvaluated(project, m.Key, m.Value, m.Value);
                }
                imd.SetProperties(properties);
            }
            return(new AssemblyReference(it.ItemSpec, imd));
        }
        void SyncBuildProject(Dictionary <string, MSBuildItem> currentItems, MSBuildEngine e, object project)
        {
            evaluatedItemsIgnoringCondition.Clear();
            evaluatedItems.Clear();
            evaluatedItemDefinitions?.Clear();

            if (!OnlyEvaluateProperties)
            {
                foreach (var it in e.GetEvaluatedItemDefinitions(project))
                {
                    var xit = it as MSBuildItemEvaluated;
                    if (xit != null)
                    {
                        if (evaluatedItemDefinitions == null)
                        {
                            evaluatedItemDefinitions = new Dictionary <string, MSBuildPropertyGroupEvaluated> ();
                        }
                        MSBuildPropertyGroupEvaluated evalItemDefProps = null;
                        if (!evaluatedItemDefinitions.TryGetValue(xit.Name, out evalItemDefProps))
                        {
                            evalItemDefProps = new MSBuildPropertyGroupEvaluated(msproject);
                            evaluatedItemDefinitions [xit.Name] = evalItemDefProps;
                        }
                        evalItemDefProps.Sync(engine, xit, clearProperties: false);
                    }
                }

                var evalItems = new Dictionary <string, MSBuildItemEvaluated> ();
                foreach (var it in e.GetEvaluatedItems(project))
                {
                    var xit = it as MSBuildItemEvaluated;
                    if (xit == null)
                    {
                        xit = CreateEvaluatedItem(e, it);
                        var itemId = e.GetItemMetadata(it, NodeIdPropertyName);
                        var key    = itemId + " " + xit.Include;
                        if (evalItems.ContainsKey(key))
                        {
                            continue;                             // xbuild seems to return duplicate items when using wildcards. This is a workaround to avoid the duplicates.
                        }
                        MSBuildItem pit;
                        if (!string.IsNullOrEmpty(itemId) && currentItems.TryGetValue(itemId, out pit))
                        {
                            xit.AddSourceItem(pit);
                            xit.Condition   = pit.Condition;
                            evalItems [key] = xit;
                        }
                    }
                    evaluatedItems.Add(xit);
                }

                var evalItemsNoCond = new Dictionary <string, MSBuildItemEvaluated> ();
                foreach (var it in e.GetEvaluatedItemsIgnoringCondition(project))
                {
                    var xit = it as MSBuildItemEvaluated;
                    if (xit == null)
                    {
                        xit = CreateEvaluatedItem(e, it);
                        var itemId = e.GetItemMetadata(it, NodeIdPropertyName);
                        MSBuildItemEvaluated evItem;
                        var key = itemId + " " + xit.Include;
                        if (evalItemsNoCond.ContainsKey(key))
                        {
                            continue;                             // xbuild seems to return duplicate items when using wildcards. This is a workaround to avoid the duplicates.
                        }
                        if (!string.IsNullOrEmpty(itemId) && evalItems.TryGetValue(key, out evItem))
                        {
                            evaluatedItemsIgnoringCondition.Add(evItem);
                            evalItemsNoCond [key] = evItem;
                            continue;
                        }
                        MSBuildItem pit;
                        if (!string.IsNullOrEmpty(itemId) && currentItems.TryGetValue(itemId, out pit))
                        {
                            xit.AddSourceItem(pit);
                            xit.Condition         = pit.Condition;
                            evalItemsNoCond [key] = xit;
                        }
                    }
                    UpdateMetadata(xit);
                    evaluatedItemsIgnoringCondition.Add(xit);
                }

                // Clear the node id metadata
                foreach (var it in evaluatedItems.Concat(evaluatedItemsIgnoringCondition))
                {
                    ((MSBuildPropertyGroupEvaluated)it.Metadata).RemoveProperty(NodeIdPropertyName);
                }

                targets = e.GetTargets(project).ToArray();
                targetsIgnoringCondition = e.GetTargetsIgnoringCondition(project).ToArray();
            }

            var props = new MSBuildEvaluatedPropertyCollection(msproject);

            evaluatedProperties = props;
            props.SyncCollection(e, project);

            conditionedProperties = engine.GetConditionedProperties(project);
        }