Beispiel #1
0
        public void GetPropertyGroupUnderTarget()
        {
            string content = @"
                    <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
                        <Target Name='t'>
                            <PropertyGroup Condition='c1'>
                                <p1 Condition='c2'>v1</p1>
                                <p2/>
                            </PropertyGroup>
                        </Target>
                    </Project>
                ";

            ProjectInstance p = GetProjectInstance(content);
            ProjectPropertyGroupTaskInstance propertyGroup = (ProjectPropertyGroupTaskInstance)(p.Targets["t"].Children[0]);

            Assert.Equal("c1", propertyGroup.Condition);

            List <ProjectPropertyGroupTaskPropertyInstance> properties = Helpers.MakeList(propertyGroup.Properties);

            Assert.Equal(2, properties.Count);

            Assert.Equal("c2", properties[0].Condition);
            Assert.Equal("v1", properties[0].Value);

            Assert.Equal(String.Empty, properties[1].Condition);
            Assert.Equal(String.Empty, properties[1].Value);
        }
Beispiel #2
0
        /// <summary>
        /// Constructs a task logging context from a parent target context and a task node.
        /// </summary>
        internal TaskLoggingContext(TargetLoggingContext targetLoggingContext, string projectFullPath, ProjectTargetInstanceChild task)
            : base(targetLoggingContext)
        {
            _targetLoggingContext = targetLoggingContext;
            _task = task;

            ProjectTaskInstance taskInstance = task as ProjectTaskInstance;

            if (taskInstance != null)
            {
                _taskName = taskInstance.Name;
            }
            else
            {
                ProjectPropertyGroupTaskInstance propertyGroupInstance = task as ProjectPropertyGroupTaskInstance;
                if (propertyGroupInstance != null)
                {
                    _taskName = "PropertyGroup";
                }
                else
                {
                    ProjectItemGroupTaskInstance itemGroupInstance = task as ProjectItemGroupTaskInstance;
                    if (itemGroupInstance != null)
                    {
                        _taskName = "ItemGroup";
                    }
                    else
                    {
                        _taskName = "Unknown";
                    }
                }
            }

            this.BuildEventContext = LoggingService.LogTaskStarted2
                                     (
                targetLoggingContext.BuildEventContext,
                _taskName,
                projectFullPath,
                task.Location.File,
                task.Location.Line,
                task.Location.Column
                                     );
            this.IsValid = true;
        }
Beispiel #3
0
 /// <summary>
 /// Create a new PropertyGroup task.
 /// </summary>
 /// <param name="taskInstance">The task instance data</param>
 /// <param name="loggingContext">The logging context</param>
 /// <param name="projectInstance">The project instance</param>
 /// <param name="logTaskInputs">Flag to determine whether or not to log task inputs.</param>
 public PropertyGroupIntrinsicTask(ProjectPropertyGroupTaskInstance taskInstance, TargetLoggingContext loggingContext, ProjectInstance projectInstance, bool logTaskInputs)
     : base(loggingContext, projectInstance, logTaskInputs)
 {
     _taskInstance = taskInstance;
 }