Пример #1
0
        internal TargetExecutionWrapper
        (
            Target targetClass,
            ArrayList taskElementList,
            List<string> targetParameters,
            XmlElement targetElement,
            Expander expander,
            BuildEventContext targetBuildEventContext
        )
        {
            // Initialize the data about the target XML that has been calculated in the target class
            this.targetClass   = targetClass;
            this.parentEngine  = targetClass.ParentEngine;
            this.parentProject = targetClass.ParentProject;
            this.targetElement   = targetElement;
            this.taskElementList = taskElementList;
            this.targetParameters = targetParameters;
            this.targetBuildEventContext = targetBuildEventContext;

            // Expand the list of depends on targets
            dependsOnTargetNames = expander.ExpandAllIntoStringList(targetClass.DependsOnTargets, targetClass.DependsOnTargetsAttribute);

            // Starting to build the target
            inProgressBuildState = InProgressBuildState.StartingBuild;
            // No messages have been logged
            loggedTargetStart = false;
        }
Пример #2
0
        /// <summary>
        /// Creates a list of targets to execute for the OnErrorClause
        /// </summary>
        private void InitializeOnErrorClauseExecution()
        {
            // Give default values;
            currentErrorTarget = 0;
            onErrorTargets = null;

            // Loop through each of the child nodes of the <target> element.
            List<XmlElement> childElements = ProjectXmlUtilities.GetValidChildElements(targetElement);

            foreach (XmlElement childElement in childElements)
            {
                switch (childElement.Name)
                {
                    case XMakeElements.onError:
                        ProjectXmlUtilities.VerifyThrowProjectNoChildElements(childElement);

                        XmlAttribute condition = null;
                        XmlAttribute executeTargets = null;

                        foreach (XmlAttribute onErrorAttribute in childElement.Attributes)
                        {
                            switch (onErrorAttribute.Name)
                            {
                                case XMakeAttributes.condition:
                                    condition = childElement.Attributes[XMakeAttributes.condition];
                                    break;
                                case XMakeAttributes.executeTargets:
                                    executeTargets = childElement.Attributes[XMakeAttributes.executeTargets];
                                    break;
                                default:
                                    ProjectXmlUtilities.ThrowProjectInvalidAttribute(onErrorAttribute);
                                    break;
                            }
                        }

                        ProjectErrorUtilities.VerifyThrowInvalidProject(executeTargets != null, childElement, "MissingRequiredAttribute", XMakeAttributes.executeTargets, XMakeElements.onError);

                        Expander expander = new Expander(this.parentProject.evaluatedProperties, this.parentProject.evaluatedItemsByName);

                        bool runErrorTargets = true;
                        if (condition != null)
                        {
                            if
                            (
                                !Utilities.EvaluateCondition
                                (
                                    condition.InnerText, condition, expander,
                                    null, ParserOptions.AllowProperties | ParserOptions.AllowItemLists,
                                    parentEngine.LoggingServices, targetBuildEventContext
                                )
                            )
                            {
                                runErrorTargets = false;
                            }
                        }

                        if (runErrorTargets)
                        {
                            if (onErrorTargets == null)
                            {
                                onErrorTargets = expander.ExpandAllIntoStringList(executeTargets.InnerText, executeTargets);
                            }
                            else
                            {
                                onErrorTargets.AddRange(expander.ExpandAllIntoStringList(executeTargets.InnerText, executeTargets));
                            }
                        }
                        break;

                    default:
                        // Ignore
                        break;
                }
            }
        }
Пример #3
0
        public void ExpandAllIntoStringListComplex()
        {
            ReadOnlyLookup lookup;
            Dictionary<string, string> itemMetadata;
            CreateComplexPropertiesItemsMetadata(out lookup, out itemMetadata);

            Expander expander = new Expander(lookup, itemMetadata);

            XmlAttribute xmlattribute = (new XmlDocument()).CreateAttribute("dummy");
            xmlattribute.Value = "@(Resource->'%(Filename)') ; @(Content) ; @(NonExistent) ; $(NonExistent) ; %(NonExistent) ; " +
                "$(OutputPath) ; $(TargetPath) ; %(Language)_%(Culture)";

            List<string> expanded = expander.ExpandAllIntoStringList(xmlattribute.Value, xmlattribute);

            Assertion.AssertEquals(9, expanded.Count);
            Assertion.AssertEquals(@"string$(p)", expanded[0]);
            Assertion.AssertEquals(@"dialogs%3b", expanded[1]);
            Assertion.AssertEquals(@"splash.bmp", expanded[2]);
            Assertion.AssertEquals(@"\jk", expanded[3]);
            Assertion.AssertEquals(@"l\mno%3bpqr\stu", expanded[4]);
            Assertion.AssertEquals(@"subdir1\", expanded[5]);
            Assertion.AssertEquals(@"subdir2\", expanded[6]);
            Assertion.AssertEquals(@"english_abc%3bdef", expanded[7]);
            Assertion.AssertEquals(@"ghi", expanded[8]);

            expanded = expander.ExpandAllIntoStringList(xmlattribute);

            Assertion.AssertEquals(9, expanded.Count);
            Assertion.AssertEquals(@"string$(p)", expanded[0]);
            Assertion.AssertEquals(@"dialogs%3b", expanded[1]);
            Assertion.AssertEquals(@"splash.bmp", expanded[2]);
            Assertion.AssertEquals(@"\jk", expanded[3]);
            Assertion.AssertEquals(@"l\mno%3bpqr\stu", expanded[4]);
            Assertion.AssertEquals(@"subdir1\", expanded[5]);
            Assertion.AssertEquals(@"subdir2\", expanded[6]);
            Assertion.AssertEquals(@"english_abc%3bdef", expanded[7]);
            Assertion.AssertEquals(@"ghi", expanded[8]);
        }