Hello! Welcome to the final lesson in our module on the Power Apps Component Framework (PCF).
In our last session, you mastered the local development inner loop. You learned how to use the local test harness with npm start watch to build, test, and debug your PCF components rapidly, all without leaving your machine. We now have a component that works perfectly in a simulated environment.
Today, we take the final and most crucial step: moving your component from your local machine into a live Dataverse environment. Our learning outcome is to package and deploy a PCF component as part of a Dataverse solution. This process makes your custom component available for use in model-driven and canvas apps.
You'll leverage your existing experience with Dynamics 365 solutions, but we'll focus on the specific commands and steps required for PCF components, using the Power Platform CLI to manage the process.
1. The PCF Deployment Workflow
Deploying a PCF component involves bundling it into a solution package (a .zip file) and importing that package into your target Power Platform environment. A solution acts as a container for all your customizations.
The core process involves three main stages using the Power Platform CLI:
- Initialize a Solution Project: Create a project that will define the contents of your solution.
- Add a Component Reference: Tell the solution project about your PCF component.
- Build and Deploy: Compile the solution project into a
.zipfile and import it into Dataverse.
Let's walk through this process step-by-step.
2. Step 1: Create and Configure a Solution Project
First, you need to create a dedicated solution project that will contain your PCF component. This is done outside your PCF component's project directory. A common practice is to create a sibling folder for your solutions.
For example, if your PCF component is at C:\Projects\MyPCFComponent, you might create your solution project at C:\Projects\Solutions\MySolution.
The entire process of creating the solution, adding a reference, and building it is demonstrated well in the following video.
Learn PCF Power Apps Component Code Component in 1 Hour | Installation, Demo and Use in Dataverse
This video from Softchief Learn provides a practical demonstration of packaging a PCF component. We'll start by watching the section on creating the solution project and adding the component reference.
Watch from 25:47 to 28:47. Pay close attention to the CLI commands used. Note how the presenter creates a new 'solution' sub-folder to keep the solution project separate from the component project.
Let's break down the commands you just saw.
Initializing the Solution
In your terminal, navigate to a new, empty folder where you want your solution project to live and run the pac solution init command.
# It's good practice to create a separate directory for the solution project
mkdir MySolutionProject
cd MySolutionProject
# Initialize the solution project
pac solution init --publisher-name "YourPublisherName" --publisher-prefix "yourprefix"
--publisher-name: The display name of your publisher.--publisher-prefix: A unique prefix (e.g.,dev,contoso) for all custom components in this solution. As you know from your Dynamics 365 work, this is critical for avoiding naming conflicts.
This command creates a .cdsproj file, which is the MSBuild project file for your Dataverse solution.
Adding the Component Reference
Next, you need to tell the solution project which PCF component(s) to include. This is done by adding a reference using the pac solution add-reference command. You must provide the path to your PCF component's project folder.
# From within your solution project directory
pac solution add-reference --path "C:\Path\To\Your\PCF\ProjectFolder"
This command updates your .cdsproj file, adding a <ProjectReference> entry that points to your PCF component's .pcfproj file.
For a detailed breakdown of these commands, you can refer to the official Microsoft documentation.
This Microsoft Learn article is the official guide to packaging a code component. It provides the syntax and explanation for the commands we are using.
Read the first part of the article, which covers creating the 'Solutions' folder, running pac solution init, and using pac solution add-reference. This will solidify your understanding of the commands.
3. Step 2: Build the Solution Package
With the solution project initialized and the reference to your PCF component added, you can now build the solution. This process packages your component and all solution metadata into a single .zip file, ready for deployment.
You can use either msbuild (if you have Visual Studio build tools) or dotnet build.
# Run this from your solution project directory
# On the first build, you need to restore NuGet packages.
# The 'dotnet build' command does this automatically.
dotnet build
# Alternatively, with MSBuild:
# msbuild /t:restore (only needed for the first build)
# msbuild
After the build successfully completes, you will find the solution .zip files in the bin/Debug/ (or bin/Release/) subfolder of your solution project. You will typically see two files:
YourSolution_managed.zip: For production deployments.YourSolution.zip: The unmanaged solution, for development environments.

4. Step 3: Deploy and Configure the Component
Now you're ready to deploy. This involves importing the generated solution .zip file into your Dataverse environment and then configuring a form to use your new component.
Importing the Solution
You have two primary methods for importing the solution:
- Manual Import (via Maker Portal): This is the standard UI-based approach. You navigate to Solutions in the Power Apps maker portal, click Import solution, and upload your generated
.zipfile. - CLI Import (programmatic): For a more automated, scriptable approach, you can use the Power Platform CLI. This is often preferred in DevOps scenarios.
First, you must create or select an authentication profile to connect the CLI to your target environment.
# Create an auth profile (only needs to be done once)
pac auth create --url https://your-org.crm.dynamics.com
# Or list existing profiles and select one
pac auth list
pac auth select --index <number>
Once connected, you can import the solution.
pac solution import --path "bin\Debug\YourSolution_managed.zip" --publish-changes
The --publish-changes flag is a convenient way to automatically publish all customizations after a successful import.
Test your understanding!
You have built your solution, and you now have MyPCFSolution.zip and MyPCFSolution_managed.zip. You need to deploy this to a User Acceptance Testing (UAT) environment where you do not want other developers to make changes to your component. Which file do you deploy, and why?
Show answer
You should deploy MyPCFSolution_managed.zip. Managed solutions are intended for non-development environments (like UAT and Production) because they are locked, preventing modifications to their components. This ensures consistency and stability.
Configuring the Component on a Form
After the solution is imported and published, your PCF component is available within the environment. The final step is to associate it with a field or dataset on a model-driven app form.
This final part of the process connects your deployed code to the user interface.
Learn PCF Power Apps Component Code Component in 1 Hour | Installation, Demo and Use in Dataverse
Let's return to the Softchief Learn video to see the deployment and configuration in action. The presenter will manually import the solution and then add the component to a form field.
Watch from 47:32 to 56:36. Observe how the presenter: Manually imports the generated solution zip file through the maker portal. Publishes the customizations. Opens a form in the classic designer, selects a field, and adds the custom control from the 'Controls' tab. Enables the control for Web, Phone, and Tablet.
The process you just watched is:
- Navigate to your solution in the maker portal and open the form you want to customize.
- Select the field (column) you want to enhance.
- In the properties pane on the right, switch to the Components section.
- Click + Component and select your newly deployed PCF component from the list.
- Choose the form factors (Web, Tablet, Phone) where this component should be active.
- Save and Publish the form.
Now, when you open a record in your model-driven app, you will see your PCF component rendering instead of the default control!
5. An Alternative for Rapid Development: pac pcf push
While the full solution packaging process is essential for formal deployments and ALM, it can be slow during active development. For a faster "inner-loop" that includes testing in a real environment (especially for things the local harness can't do, like Web API calls), you can use pac pcf push.
This command directly "pushes" your latest PCF component build to a Dataverse environment, bypassing the solution build and import steps.
The pac pcf push command significantly accelerates the development lifecycle. This section of the documentation explains how it works.
Read the section 'Deploying code components'. Pay attention to the purpose of the push command and the requirement that your publisher prefix must match the prefix of a solution you plan to eventually package it in.
To use it, ensure you are authenticated to your dev environment, navigate to your PCF component's project directory, and run:
# Make sure your CLI is connected to the right environment first!
pac pcf push --publisher-prefix "yourprefix"
This command automatically creates or updates a temporary solution (named PowerAppsTools_yourprefix) in your environment and deploys the component into it. It's incredibly useful for quick testing, but remember that the formal pac solution build process is the correct approach for structured ALM and moving solutions between environments.
Conclusion
Congratulations! You have successfully completed the entire lifecycle of a PCF component, from initialization to deployment. You now have the skills to build a component locally, package it into a distributable solution, and deploy it to a Power Platform environment where it can be used in real applications.
Key Takeaways:
- PCF components are deployed within Dataverse solutions.
- The Power Platform CLI is your primary tool for packaging.
- The core workflow is:
pac solution init,pac solution add-reference, anddotnet build(ormsbuild). - The build process generates a
.zipsolution file for import. - You can import solutions manually via the portal or programmatically with
pac solution import. - After deployment, you must configure the component on a form and publish the changes.
- For rapid development-time testing in Dataverse,
pac pcf pushoffers a much faster alternative to the full solution packaging process.
What's Next?
You now know how to build, test, and deploy individual components. The next step in becoming an advanced Power Platform developer is to manage complex solutions and integrations professionally. In the upcoming module, we will explore Azure and Power Platform Integration Patterns. You will learn how to connect your apps and automations to powerful Azure services like Azure Service Bus and Azure Functions to build highly scalable and robust enterprise solutions.