Dataverse: Export Import Solution from your command prompt using PowerApps CLI

Powerapps CLI have lots of function to support our daily activities. The most useful to me of course the command “pac plugin init” that automatically creates Plugin Project. Today, we will learn about Authentication and Solution commands to do export-import across the environment.

Installing

You can find the download link of the PowerApps CLI on this page. Once you have already downloaded the MSI and install it (in the folder that you want). Then you can try to open the command prompt and then run the “pac” command. If you got a response you are good to go, if not you can do it like me to set the Environment Variable (so you can call it anywhere across your machine).

Download link

Type on the start > Edit the Environment Variable > System will open System Properties > click on Environment Variables > copy and paste the location of the installed folder on the previous step.

Set Environment Variables on your machine

Authenticating

Before we can export/import a solution, the first thing that we need to do is to connect with the environment we want to connect. To add a connection to the Dataverse environment, you just need to open a command prompt > type the below command:

pac auth create --name powermvps1 --url https://yourcrmurl.crm.dynamics.com --username yourusername@yourdomain.com --password yourpassword

If your setting is correct, then you will get the below response(then you can run the command “pac auth list” to see the connected Environments):

Created Environment + Environment List

From the above image, you can see that my system marks the environment the powermvps (index no 2) as the active environment. So every command that we will run, will be to this environment. But in case you want to change the environment, you can run the command “pac auth select –index 1” to set insurgo2 as the active environment.

Export Solution

Once the above steps are already in place, we just need to go running the below command for exporting:

pac solution export --path d:\\Solutions\Blog_Unmanaged.zip --name blog --managed false --include general

There are several parameters that you can apply here based on this link. You can set the name parameter to the correct solution, managed (true/false). In the latest version that I’m using (1.13.6+gf8c1356), I can’t use the targetversion flag. Then there is include flag also that can be set as thesethese values: autonumbering, calendar, customization, emailtracking, externalapplications, general, isvconfig, marketing, outlooksynchronization, relationshiproles, sales.

Import Solution

The next one is how to import the solution, you just need to import the below command:

pac solution import --path D:\Solutions\Blog_Unmanaged.zip --activate-plugins true --publish-changes true --async true

And below is the result once it finished importing:

Importing solution response

There are lots of parameters that we can use here! Like convert-to-managed parameter that will allow a managed solution that is being imported into an environment to convert unmanaged components to managed state. The activate-plugins parameter to active the plugins once we finished importing.

Happy CRM-ing!

Advertisement

4 thoughts on “Dataverse: Export Import Solution from your command prompt using PowerApps CLI

  1. Importing a managed solution (pac solution import –path) does it “upgrade” or “update”? The choice is available in power platform UI while importing a managed solution but I’m not able to figure out what happens when you do it through pac.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.