01 Aug, 2024
Deploying PCF Controls to Dataverse Using CLI
Posted on 01 Aug, 2024 by Ankit Gore, Posted in
PCF (PowerApps Component Framework)
Dataverse
Power Platform
Blogs
Introduction
In this blog, we will deploy the PCF code component using the CLI. With this approach, you won't need to manually import the solution into the Dataverse environment. Instead, you can run CLI commands to import your solution directly into the target environment.
Prerequisites
- A Microsoft Dataverse environment with admin access
- Power Apps CLI installed on your machine
- A code editor of your choice (e.g., Visual Studio Code)
- A PCF control project created
- npm installed on your system
- MSBuild installed on your system. Ensure that MSBuild is added to the System Environment Variables.
Step-by-Step Guide
Step 1: Creating the solution to deploy.
- Open the Solution folder path in CMD.
- If the solution folder is not created, create it. Then, inside that folder, run the following command to create the solution project. Provide the publisher name and prefix for the solution in the command.
pac solution init --publisher-name developer --publisher-prefix dev
- Now, run this command in the Solution folder path.
pac solution add-reference --path c:/FolderPath of PCF Project
- Run command
msbuild /t:restore
- Run command to build the debug solution in bin.
msbuild
Step 2: Connecting to your environment.
To deploy the code components directly, use the Microsoft Power Platform CLI to connect to the Dataverse environment and then push the updated components.
- Create an authentication profile using the command below. Provide the org URL:
pac auth create --url https://xyz.crm.dynamics.com
- If you have previously created an authentication profile, you can view all the existing profiles using the command:
pac auth list
Example:
- To select your authentication profile from the list, run the command:
pac auth select --index
Example:
- Now you are successfully connected to the environment.
Step 3: Deploying PCF code components.
After you have successfully created an authentication profile, you can start pushing the code components to the Dataverse instance with all the latest changes. Navigate to the directory where the PCF component file is located.
- Run the command “pac pcf push --publisher-prefix ”.
Note: The publisher prefix of your solution and the one provided in the command should be the same.
Wait for some time it will automatically deploy the PCF components in the environment.
I hope you find this helpful!