/// <summary> /// Parse a ProjectOutputElement /// </summary> private ProjectOutputElement ParseProjectOutputElement(XmlElementWithLocation element, ProjectTaskElement parent) { ProjectXmlUtilities.VerifyThrowProjectAttributes(element, ValidAttributesOnOutput); ProjectXmlUtilities.VerifyThrowProjectRequiredAttribute(element, XMakeAttributes.taskParameter); ProjectXmlUtilities.VerifyThrowProjectNoChildElements(element); XmlAttributeWithLocation itemNameAttribute = element.GetAttributeWithLocation(XMakeAttributes.itemName); XmlAttributeWithLocation propertyNameAttribute = element.GetAttributeWithLocation(XMakeAttributes.propertyName); ProjectErrorUtilities.VerifyThrowInvalidProject ( String.IsNullOrWhiteSpace(itemNameAttribute?.Value) && !String.IsNullOrWhiteSpace(propertyNameAttribute?.Value) || !String.IsNullOrWhiteSpace(itemNameAttribute?.Value) && String.IsNullOrWhiteSpace(propertyNameAttribute?.Value), element.Location, "InvalidTaskOutputSpecification", parent.Name ); ProjectXmlUtilities.VerifyThrowProjectAttributeEitherMissingOrNotEmpty(element, itemNameAttribute, XMakeAttributes.itemName); ProjectXmlUtilities.VerifyThrowProjectAttributeEitherMissingOrNotEmpty(element, propertyNameAttribute, XMakeAttributes.propertyName); ProjectErrorUtilities.VerifyThrowInvalidProject(String.IsNullOrWhiteSpace(propertyNameAttribute?.Value) || !ReservedPropertyNames.IsReservedProperty(propertyNameAttribute.Value), element.Location, "CannotModifyReservedProperty", propertyNameAttribute?.Value); return(new ProjectOutputElement(element, parent, _project)); }
/// <summary> /// Parse a ProjectUsingTaskElement /// </summary> private ProjectUsingTaskElement ParseProjectUsingTaskElement(XmlElementWithLocation element) { ProjectXmlUtilities.VerifyThrowProjectAttributes(element, ValidAttributesOnUsingTask); ProjectErrorUtilities.VerifyThrowInvalidProject(element.GetAttribute(XMakeAttributes.taskName).Length > 0, element.Location, "ProjectTaskNameEmpty"); string assemblyName = element.GetAttribute(XMakeAttributes.assemblyName); string assemblyFile = element.GetAttribute(XMakeAttributes.assemblyFile); ProjectErrorUtilities.VerifyThrowInvalidProject ( (assemblyName.Length > 0) ^ (assemblyFile.Length > 0), element.Location, "UsingTaskAssemblySpecification", XMakeElements.usingTask, XMakeAttributes.assemblyName, XMakeAttributes.assemblyFile ); ProjectXmlUtilities.VerifyThrowProjectAttributeEitherMissingOrNotEmpty(element, XMakeAttributes.assemblyName); ProjectXmlUtilities.VerifyThrowProjectAttributeEitherMissingOrNotEmpty(element, XMakeAttributes.assemblyFile); ProjectUsingTaskElement usingTask = new ProjectUsingTaskElement(element, _project, _project); bool foundTaskElement = false; bool foundParameterGroup = false; foreach (XmlElementWithLocation childElement in ProjectXmlUtilities.GetVerifyThrowProjectChildElements(element)) { ProjectElement child = null; string childElementName = childElement.Name; switch (childElementName) { case XMakeElements.usingTaskParameterGroup: if (foundParameterGroup) { ProjectXmlUtilities.ThrowProjectInvalidChildElementDueToDuplicate(childElement); } child = ParseUsingTaskParameterGroupElement(childElement, usingTask); foundParameterGroup = true; break; case XMakeElements.usingTaskBody: if (foundTaskElement) { ProjectXmlUtilities.ThrowProjectInvalidChildElementDueToDuplicate(childElement); } ProjectXmlUtilities.VerifyThrowProjectAttributes(childElement, ValidAttributesOnUsingTaskBody); child = new ProjectUsingTaskBodyElement(childElement, usingTask, _project); foundTaskElement = true; break; default: ProjectXmlUtilities.ThrowProjectInvalidChildElement(childElement.Name, element.Name, element.Location); break; } usingTask.AppendParentedChildNoChecks(child); } return(usingTask); }