Plugin Development

There are public demo plugins on GitHub:

Setup

They show what to do to develop kenaflow plugins.

To set this up just clone the repository

git clone https://github.com/ikarstein/kenaflow.demoplugin.v1

or

git clone https://github.com/ikarstein/kenaflow.demoplugin.v2

Now you need run PowerShell script _patch.ps1

. .\_patch.ps1 "<path-to-kenaflow>"

By default kenaflow is installed in C:\Program Files\kenaflow. Therefore run:

. .\_patch.ps1 "C:\Program Files\kenaflow"

The project has an assembly reference to kenaflow.lib.dll. Furthermore it has a NuGet package reference to Microsoft.PowerShell.5.ReferenceAssemblies (Version 1.1.0).

**Both assembly references have a setting Private (In Visual Studio Solution Explorer it's calles 'Copy Local') with value False in the project file.

    <Reference Include="kenaflow.lib">
      <HintPath>c:\program files\kenaflow\kenaflow.lib.dll</HintPath>
      <Private>False</Private>
    </Reference>
    <Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
      <HintPath>packages\Microsoft.PowerShell.5.ReferenceAssemblies.1.1.0\lib\net4\System.Management.Automation.dll</HintPath>
      <Private>False</Private>
    </Reference>

Setup kenaflow.demoplugin.v1

The project contains a demo workflow that uses the cmdlet Get-PluginTestV1 provided by the plugin. - The demo workflow is of type "POWERSHELL" and is located in the subfolder _ready_workflow in the project.

After you have patched all project files you can open the solution in Visual Studio (2017 / 2019) Community Edition (https://visualstudio.microsoft.com/downloads/).

When you compile the project its output is written to the Plugins subfolder of kenaflow, e.g. C:\Program Files\kenaflow\Plugins.

It's easy to debug the plugin.

Just set the startup options:

Start External Program => path to kenaflow.exe

Command line arguments => --exec --workflow "<path-to-_ready_workflow>" --notbe --noignore

Now you can debug the custom cmdlet.

If you want to run the plugin from within a workflow debug session - e.g. with Visual Studio Code or PowerShell ISE - you can use this settings:

Start External Program => path to C:\Windows\System32\WindowsPowerShell\v1.0\powershell_ise.exe

Command line arguments => "c:\source\kenaflow.demoplugin.v1\_ready_workflow\script.ps1"

Here you need to use the script file path as single argument. The path is case sensitive - otherwise breakpoints in PowerShell ISE will not work!

Continue here to get more details about Plugin Architecture Version 1.

Setup kenaflow.demoplugin.v2

The project contains a custom workflow type "DEMO2" with SubType "SUB1" and a custom cmdlet Get-PluginTestV2.

There is a demo workflow of type "DEMO2::SUB2" and is located in the subfolder _ready_workflow in the project folder.

After you have patched all project files you can open the solution in Visual Studio (2017 / 2019) Community Edition (https://visualstudio.microsoft.com/downloads/).

When you compile the project its output is written to the Plugins subfolder of kenaflow, e.g. C:\Program Files\kenaflow\Plugins.

It's easy to debug the plugin.

Just set the startup options:

Start External Program => path to kenaflow.exe

Command line arguments => --exec --workflow "<path-to-_ready_workflow>" --notbe --noignore

Now you can debug the custom workflow type.

If you want to run the plugin from within a workflow debug session - e.g. with Visual Studio Code or PowerShell ISE - you can use this settings:

Start External Program => path to C:\Windows\System32\WindowsPowerShell\v1.0\powershell_ise.exe

Command line arguments => "c:\source\kenaflow.demoplugin.v1\_ready_workflow\script.ps1"

Here you need to use the script file path as single argument. The path is case sensitive - otherwise breakpoints in PowerShell ISE will not work!

Continue here to get more details about Plugin Architecture Version 2.

Discussion