Deploy & ALM
PowerShell module
Install the Logic Fabric PowerShell module and use its cmdlets to export, import and manage projects from PowerShell scripts.
If your deployment scripts are written in PowerShell, you can use the Logic Fabric PowerShell module instead of calling the CLI. Its cmdlets cover the same operations as most CLI commands, return objects you can pipe on, and report failures as PowerShell errors you can catch.
Before you begin
Section titled “Before you begin”- PowerShell 7 or later.
- The same environment access as for the CLI; see Installation.
Install
Section titled “Install”-
Download the module package:
Terminal window Install-Package Flowon.Xrm.Tools.PowerShell -Source https://api.nuget.org/v3/index.json -Scope CurrentUser -
Import the module manifest from the package’s
lib\net10.0folder:Terminal window Import-Module "<path to package>\lib\net10.0\flowon-module.psd1" -
Check that the cmdlets are available:
Terminal window Get-Command -Module flowon-module
Cmdlets
Section titled “Cmdlets”| Cmdlet | CLI equivalent | Returns |
|---|---|---|
Test-ListProjectsCmdletCommand |
projects |
The projects, with their solutions and publisher prefixes. |
Test-ListFeaturesCmdlet |
features |
Feature objects with Name, DisplayName, Description and Version. |
Test-ExportCmdletCommand |
export |
The path of the exported package. |
Test-ImportCmdletCommand |
import |
— |
Test-GenerateMappingsCmdletCommand |
generate-mappings |
— |
Test-GenerateOpenApiSchemaCmdletCommand |
generate-openapi |
The path of the schema file. |
Test-EnablePluginsCmdletCommand |
enable-plugins |
— |
Test-DisablePluginsCmdletCommand |
disable-plugins |
— |
Test-EnableLogicRecipeCmdletCommand |
enable-recipe |
— |
Test-DisableLogicRecipeCmdletCommand |
disable-recipe |
— |
Test-IncrementSolutionVersionCmdletCommand |
increment-solution-version |
The new version. |
Test-GenerateDocsCmdletCommand |
docs |
— |
There are no cmdlets for apply-mappings, publish-api or create-patch; call the CLI for those.
Parameters
Section titled “Parameters”Every cmdlet that talks to an environment takes -ConnectionString, and every cmdlet takes -LogLevel (None, Info or Verbose; the default is Info, unlike the CLI). Parameters can also be piped in by property name.
| Cmdlet | Parameters (mandatory in bold) |
|---|---|
Test-ExportCmdletCommand |
-ProjectName, -OutputDirectory, -ExportManagedSolution $true, -ExportUnManagedSolution $true, -DataSpecFilePath |
Test-ImportCmdletCommand |
-SolutionFilePath, -OverrideUnmanagedCustomizations $true, -DataFilesPath, -PackageFilePath, -MapFilesPath |
Test-GenerateMappingsCmdletCommand |
-PackageFilePath, -OutputDirectory |
Test-GenerateOpenApiSchemaCmdletCommand |
-ProjectName, -ApiName, -OutputDirectory, -ApiVersion (for example 2.1; default the latest published version) |
Test-EnableLogicRecipeCmdletCommand, Test-DisableLogicRecipeCmdletCommand |
-ProjectName, -Recipes (one or more names) |
Test-IncrementSolutionVersionCmdletCommand |
-Solution (unique name), -Version (Major, Minor, Build or Revision) |
Test-GenerateDocsCmdletCommand |
-PackageFilePath, -OutputDirectory |
Test-ImportCmdletCommand works like the CLI’s import: it imports the solution, then the data files, then the package with its data map files; give at least one of them, and later steps don’t run when one fails. A managed solution is skipped when the installed version is the same or newer, and unmanaged customizations are kept unless you pass -OverrideUnmanagedCustomizations $true.
The enable and disable recipe cmdlets stop at the first recipe they can’t change, for example one that doesn’t exist.
Handle errors
Section titled “Handle errors”When a cmdlet can’t complete, it stops with a terminating error that says what failed, for example “Project ‘Contoso Service’ was not found in the Dataverse environment.” The error has an ErrorId (such as ImportFailed, ExportFailed, ProjectNotFound, FileNotFound or NothingToImport), so scripts can react to specific failures. Use try/catch, and run with -LogLevel Verbose to see full details.
Example: release script
Section titled “Example: release script”$ErrorActionPreference = 'Stop'Import-Module "C:\tools\Flowon.Xrm.Tools.PowerShell\lib\net10.0\flowon-module.psd1"
$dev = $env:DEV_CONNECTION$prod = $env:PROD_CONNECTION
try { $version = Test-IncrementSolutionVersionCmdletCommand -ConnectionString $dev -Solution 'contososervice' -Version Build $package = Test-ExportCmdletCommand -ConnectionString $dev -ProjectName 'Contoso Service' ` -ExportManagedSolution $true -DataSpecFilePath .\specs\reference-data.xml -OutputDirectory .\release
Test-ImportCmdletCommand -ConnectionString $prod ` -SolutionFilePath .\release\contososervice_managed.zip ` -DataFilesPath .\release\data.xml ` -PackageFilePath $package ` -MapFilesPath .\mappings\prod\configuration.datamap.xml, .\mappings\prod\entity.datamap.xml
Write-Host "Released Contoso Service $version"}catch { Write-Error "Release failed ($($_.FullyQualifiedErrorId)): $($_.Exception.Message)" exit 1}