# Build & Install an Artifact

In the earlier section, we looked at how we configured the project directory for sfp, Now lets walk through some core commands.

### A. Build an artifact for a package

The build command will generate a zipped artifact file for each package you have defined in the sfdx-project.json file. The artifact file will contain metadata and the source code at the point build creation for you to use to install.

1. Open up a terminal within your Salesforce project directory and enter the following command:

```bash
sfp build -v <DevHubAlias/DevHubUsername>
```

You will see the logs with details of your package creation, for instance here is a sample output

<figure><img src="https://1646267036-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYLI5Ts7pWhWQV9UaBn3H%2Fuploads%2Fgit-blob-fc02c287fbef393599584a21514a9a0e7511851c%2Fimage.png?alt=media" alt=""><figcaption><p>Build Outputs</p></figcaption></figure>

2. A new "artifacts" folder will be generated within your source project containing a zipped artifact file for each package defined in your sfdx-project.json file.\
   \
   For example, the artifact files will contain the following naming convention with the "\_sfpowerscript\_artifact\_" in between the package name and version number.\
   \
   `package-name_sfpowerscripts_artifact_1.0.0-1.zip`\
   \\

   <figure><img src="https://1646267036-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYLI5Ts7pWhWQV9UaBn3H%2Fuploads%2Fgit-blob-65ad49e804e581238f290cf83f42aa5a312d984c%2Fimage.png?alt=media" alt=""><figcaption><p>artifacts folder</p></figcaption></figure>

### B. Install the artifact to a target org

Ensure you have authenticated your salesforce cli to a org first. If you haven't, please find the instructions [here](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_auth_web_flow.htm).

1. Once you have the authenticated to the sandbox, you could execute the installation command as below

```bash
sfp install -o <TargetOrgAlias/TargetOrgUsername>
```

<figure><img src="https://1646267036-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYLI5Ts7pWhWQV9UaBn3H%2Fuploads%2Fgit-blob-915edf89a12b352ce35fc9dd1e2919af32f1fa94%2Fimage.png?alt=media" alt=""><figcaption><p>Install Outputs</p></figcaption></figure>

2. Navigate to your target org and confirm that the package is now installed with the expected changes from your artifact. In this example above, a new custom field has been added to the Account Standard Object.

{% hint style="info" %}
Depending on the type of packages,[ sfp will issue the equivalent test classes](https://docs.flxbl.io/flxbl/sfp/concepts/supported-package-types) with in the package directory and it could result in failures during installation, Please fix the issues in your code and repeat till you get a sucessful installation. If your packages doesn't have sufficient test coverage, you may need to use the all tests in the org to get your package installed. Refer to the material [here](https://docs.flxbl.io/flxbl/sfp/building-artifacts/configuring-installation-behaviour-of-a-package/optimized-installation)
{% endhint %}
