[SalesForce] Correct sequence to setup ant to deploy salesforce metadata

We are in the process of setting up ant to deploy our configuration changes across our environments to production. We are using changesets at the moment. We use standard objects, custom objects, profiles, workflows, lead assignment rules, ques, layouts, email templates and lead sharing rules at the moment. What should be the sequence i should follow on the package.xml so that i do not get dependancy errors like custom objects complaining workflows not found, or letter heads complaining logo file not found etc? What is the sequence or dependancy check you guys do to deploy configuration changes to another sandbox or production?
Buyan

Best Answer

The order of the elements in a single package.xml are irrelevant. The system intelligently reorders dependencies so that the elements are deployed in the correct order. Occassionally, the system doesn't get it right, though, in which case the order of the package.xml elements will not help you at all. For those situations, you must instead deploy multiple package.xml files and directories independently. Generally, the order within each package will not matter, but packages that refer to elements in other packages will need to be deployed after the elements they refer to.