Solution

Commands for working with Dataverse solution projects.

Parameters

Property Name Description Example
add-license Add license and plan info the solution. It has the following parameters:
  • planDefinitionFile: License plan definition file in CSV format; expected columns: Service ID, Display name, More info URL (alias: -pd)
  • planMappingFile: License plan mapping file in CSV format; expected values: Service ID, Component name (alias: -pm)
add-reference Sets the reference path to the component project folder by passing the path parameter. pac solution add-reference --path c:\Users\Downloads\SampleComponent
check Perform static analysis check on the solutions against a set of best practices. It has the following parameters:
  • path: Path to the solution zip file (alias: -p).
  • outputDirectory: Output directory where the solution zip file should be stored (alias: -o).
  • geo: The geographical location of the environment where the solution checker should run. It has the following values: PreviewUnitedStates, UnitedStates,Europe, Asia, Australia, Japan, India, Canada, SouthAmerica, UnitedKingdom, France, Germany, UnitedArabEmirates, Switzerland, USGovernment, USGovernmentL4, USGovernmentL5DoD, China
  • ruleLevelOverride: Path to the file containing a JSON array rules and levels to override. It has the following values: Critical, High, Low, Medium, Informational
pac solution check --path c:\Users\Documents\Solution.zip --outputDirectory c:\samplepackage --geo UnitedStates
clone Creates a solution project based on the existing solution project. It has the following parameters:
  • name: The name of the solution to be exported.
  • targetversion: The version that the exported solution supports.
  • include: Settings that should be included in the solution being exported. It has the following values: autonumbering, calendar, customization, emailtracking, externalapplications, general, isvconfig, marketing, outlooksynchronization, relationshiproles, sales
pac solution clone -–name sampleSolution --version 1.0.0.2 --include general
create-settings Provides the ability to create a settings file that captures the environment variables and connection references in the setting. It has the following parameters:
  • solution-zip: Absolute path name or relative path name to the exported solution file (alias: -z).
  • solution-folder: Folder location of the cloned solution on the filesystem, you can either use solution zip file or the solution folder location, not both together (alias: -f).
  • settings-file: Location of the file to be created with the environment variable and connection reference information. The format of the created file is JSON (alias: -s).
pac solution create-settings --solution-zip C:\SampleSolution.zip --settings-file .\SampleDeploymentSettingsDev.json
delete Deletes the solution from the current Dataverse environment. It has the following parameter:
  • solution-name: Name of the solution you want to delete (alias: -sn).
pac solution delete --solution-name Samplesolution
export Exports a Dataverse solution from an environment. It requires that you be connected to an environment Auth command, and has the following parameters:
  • path: Complete file name where the exported solution .zip file will be saved.
  • name: Name of the solution that needs to be exported.
  • managed: Defines whether the solution should be exported as a managed solution.
  • targetversion: The version that the exported solution supports.
  • include: Settings that should be included in the solution being exported.
pac solution export --path c:\Users\Documents\Solution.zip --name SampleComponentSolution --managed true --targetversion 10.0.03 --include general
import Imports a Dataverse solution to an environment. It requires that you be connected to an environment Auth command, and has the following parameters:
  • activate-plugins: Activates plug-ins and workflows in the environment after the import (alias: -ap).
  • async: Imports the solution asynchronously (alias: -a).
  • force-overwrite: Forces an overwrite of unmanaged customizations (alias: -f).
  • import-as-holding: Imports the solution as a holding solution (alias: -h).
  • max-async-wait-time: Maximum asynchronous wait time in minutes. Default value is 60 minutes (alias: -wt).
  • path: Path to the solution .zip file. If not specified, assumes the current folder (alias: -p).
  • publish-changes: Publishes changes after successful import (alias: -pc).
  • skip-dependency-check: Skips the dependency check against dependencies flagged as product update (alias: -s).
  • convert-to-managed: This parameter does not take an unmanaged solution and import it as managed. This parameter will allow a managed solution that is being imported into an environment convert unmanaged components to managed. If this flag is not explicitly set, the solution system will fail the import request because managed layers cannot go on top of unmanaged base components. This switch will allow the solution import to succeed and the net result is that the inbound managed solution will be the base layer for each of these components – the components in the destination environment are converted from being an unmanaged component to being a managed component.
pac solution import --path c:\Users\Documents\Solution.zip
init Initializes the solution project. It has the following parameters:
  • publisher-name: Publisher name of the organization.
  • publisher-prefix: Publisher prefix of the organization.
pac solution init --publisher-name developer --publisher-prefix dev
list Lists all solutions from a Dataverse environment. It requires that you be connected to an environment Auth command. This command has no parameters. pac solution list
online-version Sets the solution version loaded in Dataverse environment. It has the following parameters:
  • solution-name: Name of the solution you want to delete (alias: -sn).
  • solution-version: Specify the solution version (alias: -sv).
pac solution online-version --solution-name Samplesolution --solution-version 1.0.0.2
pack Provides the ability to pack files on a filesystem into a solution zip file. It has the following parameters:
  • zipfile: Absolute path name or relative path name to the generated solution zip file (alias: -z).
  • folder: The path to the root folder on the local filesystem, this will be the folder from where the contents will be read from (alias: -f).
  • packagetype: Use to specify dual managed and unmanaged operation (alias: -p).
  • log: The path to the log file (alias: -l).
  • errorlevel: Minimum logging level for log output. It has the following values: Verbose, Info, Warning, Error, Off. Default value is Info (alias: -e).
  • singleComponent: Performs the action on a single component type. It has the following values: WebResource, Plugin, Workflow, None. Default value is None (alias: -sc).
  • allowDelete: Specifies if the delete operations should occur or not. It has the following values: Yes, No, Prompt. Default is Prompt (alias: -ad).
  • allowWrite: Specifies if the write operations should occur or not. Default value is false (alias: -aw).
  • clobber: Enables to delete or overwrite the files that are marked as read-only. Default value is false (alias: -c).
  • map: The full path to the mapping XML file that reads component folders to pack (alias: -m).
  • sourceLoc: Generates a template resource file. It has the following values: auto, LCID, ISO code of the language you wish to export. When set, this will extract the string resources from the given locale as a neutral resx file. If auto or just the long or short form of the switch is specified the base locale for the solution will be used (alias: -src).
  • localize: Extract or merge all string resources into .resx files (alias: -loc)
  • useLcid: Use LCID's (1033) rather than ISO codes (en-US) for language files (alias: -lcid).
  • useUnmanagedFileforMissingManaged: Use the same XML source file when packaging for managed and only unmanaged XML file is found. Applies to AppModuleSiteMap, AppModuleMap, FormXml files (alias: -same).
pac solution pack --zipfile C:\SampleSolution.zip --folder .\SampleSolutionUnpacked\.
publish Publishes all the customizations. pac solution publish
unpack Provides the ability to unpack solution zip files after they have been exported to the filesystem. It has the following parameters:
  • zipfile: Absolute path name or relative path name to the exported solution file (alias: -z).
  • folder: The path to the root folder on the local filesystem. This will be the folder where the unpacked contents will be written (alias: -f).
  • packagetype: Use to specify dual managed and unmanaged operation (alias: -p).
  • log: The path to the log file (alias: -l).
  • errorlevel: Minimum logging level for log output. It has the following values: Verbose, Info, Warning, Error, Off. Default value is Info (alias: -e).
  • singleComponent: Performs the action on a single component type. It has the following values: WebResource, Plugin, Workflow, None. Default value is None (alias: -sc).
  • allowDelete: Specifies if the delete operations should occur or not. It has the following values: Yes, No, Prompt. Default is Prompt (alias: -ad).
  • allowWrite: Specifies if the write operations should occur or not. Default value is false (alias: -aw).
  • clobber: Enables to delete or overwrite the files that are marked as read-only. Default value is false (alias: -c).
  • map: The full path to the mapping XML file that reads component folders to pack (alias: -m).
  • sourceLoc: Generates a template resource file. It has the following values: auto, LCID, ISO code of the language you wish to export. When set, this will extract the string resources from the given locale as a neutral resx file. If auto or just the long or short form of the switch is specified the base locale for the solution will be used (alias: -src).
  • localize: Extract or merge all string resources into .resx files (alias: -loc)
  • useLcid: Use LCID's (1033) rather than ISO codes (en-US) for language files (alias: -lcid).
  • useUnmanagedFileforMissingManaged: Use the same XML source file when packaging for managed and only unmanaged XML file is found. Applies to AppModuleSiteMap, AppModuleMap, FormXml files (alias: -same).
pac solution unpack --zipfile C:\SampleSolution.zip --folder .\SampleSolutionUnpacked\.
upgrade Command to upgrade the solution. It has the following parameters:
  • solution-name: Name of the solution (alias:-sn).
  • async: Upgrades the solution asynchronously (alias: -a).
  • max-async-wait-time: Maximum asynchronous wait time in minutes. Default value is 60 minutes (alias: -wt).
pac solution upgrade --solution-name SampleSolution --async --max-async-wait-time 60
version Updates the version of the existing solution. It has the following parameters:
  • patchversion: Patch version of the solution (alias: -pv).
  • strategy: Updates patch version for Solution.xml file using specified strategy. It has the following values:
    • gittags: Use Git tags to decide whether a particular solution's patch version needs to be updated. Set the personal access token in the PacCli.PAT environment variable (alias: -s).
    • filetracking: Use a .csv file to decide whether a particular solution's patch version needs to be updated.
    • solution: The solution file whose patch version should be updated.
  • filename: CSV file name to be used when using filetracking as a stategy. Default value is ControlStateVersionInfo.csv (alias: -fn).
pac solution version --patchversion 2

pac solution version --strategy gittags

Differences between pac solution clone and export

There are situations where you're unsure when to use pac solution clone or pac solution export command. You can use one of the commands in the following scenarios:

  • Use pac solution clone when you need to add new components to the solution.
  • Use pac solution export when you want to modify the existing content in a solution file but not adding any new components to the solution.

pac solution clone

The exported solution looks like a Visual Studio project when you export the solution using the pac solution clone command. Instead of a .csproj (as in Visual Studio), you'll see a cdsproj file. The cdsproj file has all the components information that is required to build the project. The build output is a solution zip file which you can import into different environments.

Pac solution clone.

The developer does not have to unpack the cloned solution because it is rendered in an unpacked format within the src (source) folder.

Pac solution unpack.

Now, if you want to associate a newly created plug-in with this solution, with the solution unpacked, you can use the pac solution add-reference command to update the .cdsproj file to add the new plug-in. Then, you can build the project using either dotnet build or msbuild.

It is recommended to do a build restore first before building the project. A build restore (dotnet build does a restore first automatically) will restore the required .NET libraries to generate a packed solution.

pac solution export

When you export the solution using pac solution export you feel like exporting the solution using the maker portal, and the resulting output is a solution zip file.

Pac solution export.

When you unpack the solution zip file (we do not recommend that you open the zip with standard tools and use the appropriate command from CLI). The resulting directory structure is similar to the structure in pac solution clone. The only difference is that you cannot add references to this unpacked solution, as it doesn't have the .cdsproj project file.

Pac solution solution structure.

You can modify the relevant set of files that you want to update and then proceed with the solution pack, which generates the solution zip file again to facilitate importing the solution into the target environment. The result from the action is a solution zip file with updated contents and an updated timestamp.

See also

Power Apps component framework overview

What is Microsoft Power Platform CLI