Home SALESFORCE Use the Salesforce CLI to Create and Install a Package – Trailhead Challenge

Use the Salesforce CLI to Create and Install a Package – Trailhead Challenge

Unlocked Packages for Customers -> Build Your First Unlocked Package


Use the Salesforce CLI to Create and Install a Package
Before You Start

  • If you haven’t already done so, enable Dev Hub in a Developer Edition org or Trailhead Playground, and install the Salesforce CLI.
  • Sign up for a GitHub account.
  • Create a new Trailhead Playground for this challenge.

Challenge Requirements
Locate the source for the DreamHouse App and use it to create a new unlocked package, then install that package in a Trailhead Playground.

Important: You don’t need to release the package version because you’re going to install it in a scratch org and Trailhead Playground (Developer Edition org). You release the package version only when you’re ready to install it in a production org.

  • Clone the DreamHouse Git repository to get the source files for the DreamHouse app.
  • Using the DreamHouse source, create an unlocked package in your Dev Hub with the name th-dreamhouseand description, My DreamHouse Package.
  • Create version 1.0 of the My DreamHouse Package.
  • Create a scratch org and install version 1.0 in it.
  • Use the Salesforce CLI to install version 1.0 of the DreamHouse package in the your Trailhead Playground org.

Steps to complete the Trailhead Challenge:

  1. Install the Command Line Interface (CLI)
  2. Enable Dev Hub (Developer/Trailhead PlayGround) (Setup -> Dev Hub)
  3. Git Clone the app repository (git clone https://github.com/dreamhouseapp/dreamhouse-sfdx.git)
  4. Login Your Developer/Trailhead Org (sfdx force:auth:web:login -d -a DevHub)
  5. Create Package (sfdx force:package:create –name th-dreamhouse –description “My DreamHouse Package” –packagetype Unlocked –path force-app –targetdevhubusername DevHub)
  6. Create ScratchOrg from Developer/Trailhead Org (sfdx force:org:create –definitionfile config/project-scratch-def.json –durationdays 30 –setalias MyScratchOrg -v DevHub)
  7. Create Package Version (sfdx force:package:version:create -p th-dreamhouse -d force-app -k test1234 –wait 10 -v DevHub)
  8. Install the Package to ScratchOrg (sfdx force:package:install –wait 10 –publishwait 10 –package [email protected] -k test1234 -r -u MyScratchOrg)
  9. Release the Package Version to Developer/Trailhead Org (sfdx force:package:version:promote -p [email protected] -v DevHub)
  10. Install the Package to Developer/Trailhead Org (sfdx force:package:install –wait 10 –publishwait 10 –package [email protected] -k test1234 -r -u DevHub)


DevHub – Developer Org Alias Name

MyScratchOrg – Scratch org of DevHub

Reference Links:

https://trailhead.salesforce.com/content/learn/projects/quick-start-salesforce-dx (Quick Start: Salesforce DX)




https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_dev2gp_create_pkg.htm – Salesforce DX Developer Guide to Create Package)

You may also like

Leave a Comment