Intermediate 15 min read

package.xml and Change Sets vs. Source Deploy

By the end of this lesson, you'll be able to:

  • Explain what package.xml describes in a metadata deployment
  • Compare change sets and CLI-based source deploys as ways to move metadata between orgs

Prerequisites: Branching Strategies for Salesforce Teams

What package.xml describes

package.xml is an XML manifest that names metadata types and component names to include in a retrieve or deploy — it describes what to move, not the metadata content itself. It's the format the older Metadata API and Ant Migration Tool relied on, and the CLI still supports it via the --manifest flag, as an alternative to its directory-based --source-dir approach.

Change sets vs. CLI deploys

Change sets are built entirely in the Setup UI, work only between orgs with an established deployment connection, keep no local history, and are hard to automate.

CLI source deploys are driven from local, Git-tracked source, can target any authenticated org, and are fully scriptable — they're the foundation every Salesforce CI/CD pipeline is built on, which is exactly what the final lesson in this course covers.

A package.xml naming one Apex class

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>OpportunityTriggerHandler</members>
        <name>ApexClass</name>
    </types>
    <version>60.0</version>
</Package>

This manifest tells a deploy or retrieve to operate on exactly one Apex class, OpportunityTriggerHandler — package.xml lists metadata types and member names, not the metadata content itself.

Exercise

Write the CLI command that deploys metadata using a manifest file named manifest/package.xml, targeting an org aliased 'production'.

Show hint

sf project deploy start --manifest <path> --target-org <alias>

BASH

package.xml and Change Sets vs. Source Deploy — Quick Check

1. What does package.xml contain?

2. Change sets can be fully automated as part of a scripted CI/CD pipeline the same way CLI source deploys can.

3. Which CLI flag lets sf project deploy start use a package.xml manifest instead of a source directory?

Log in to submit the quiz and save your score.

My Notes

Log in to keep private notes on this lesson.

Questions about this lesson

No questions yet — be the first to ask.

Log in to ask a question about this lesson.

Summary

package.xml is a manifest listing exactly which metadata components a deployment includes; change sets are Salesforce's point-and-click way to move metadata between orgs, while CLI source deploys move the same metadata directly from version-controlled local source.