public void SettingWhenConditionDirties() { string content = @" <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003' > <Choose> <When Condition='true'> <PropertyGroup> <p>v1</p> </PropertyGroup> </When> </Choose> </Project> "; Project project = new Project(XmlReader.Create(new StringReader(content))); ProjectChooseElement choose = Helpers.GetFirst(project.Xml.ChooseElements); ProjectWhenElement when = Helpers.GetFirst(choose.WhenElements); when.Condition = "false"; Assert.Equal("v1", project.GetPropertyValue("p")); project.ReevaluateIfNecessary(); Assert.Equal(String.Empty, project.GetPropertyValue("p")); }
public static void Verify(ProjectWhenElement viewXml, ProjectWhenElement realXml, ValidationContext context = null) { if (viewXml == null && realXml == null) { return; } VerifyProjectElement(viewXml, realXml, context); Verify(viewXml.ChooseElements, realXml.ChooseElements, context); Verify(viewXml.ItemGroups, realXml.ItemGroups, context); Verify(viewXml.PropertyGroups, realXml.PropertyGroups, context); }
/// <summary> /// Adds a <Choose /> element to the current project. /// </summary> /// <param name="label">An optional label to add to the Choose.</param> /// <returns>The current <see cref="ProjectCreator"/>.</returns> public ProjectCreator Choose(string label = null) { _lastChoose = AddTopLevelElement(RootElement.CreateChooseElement()); _lastChoose.Label = label; _lastOtherwiseItemGroup = null; _lastOtherwisePropertyGroup = null; _lastWhen = null; _lastWhenItemGroup = null; _lastWhenPropertyGroup = null; return(this); }
/// <summary> /// Adds a <When /> element to the current <Choose /> element. /// </summary> /// <param name="condition">An optional condition to add to the <When /> element.</param> /// <param name="label">An optional label to add to the <When /> element.</param> /// <returns>The current <see cref="ProjectCreator"/>.</returns> public ProjectCreator When(string condition = null, string label = null) { ProjectChooseElement lastChoose = LastChoose; _lastWhen = RootElement.CreateWhenElement(condition); _lastWhen.Label = label; lastChoose.AppendChild(_lastWhen); _lastWhenPropertyGroup = null; _lastWhenItemGroup = null; return(this); }