EDIT
I added the path to the dll in the RootModule
RootModule = './bin/Debug/net8.0/PSInvestigator.dll'
section of the .psd1 and it worked. I can confirm that PlatyPS is the way to go for writing PowerShell binary file documentation
I have a PowerShell C# binary called PSInvestigator with the directory structure PSInvestigation/PSInvestigator/ and the files
PSIUptime.cs, PSIPartitions.cs etc
I can run and execute the c# .dll no problem in PowerShell by doing
dotnet build
ipmo /home/deca/RiderProjects/PSInvestigator/PSInvestigator/bin/Debug/net8.0/PSInvestigator.dll
Then I can run my commands like Get-PSIVersion this has all worked fine. But now I want to add help to my C# PowerShell cmdlets. It looks like I need to add a .psd1, and en-us folder with the xml help files, and a psm1. My directory looks like this now
PS ~/RiderProjects/PSInvestigator/PSInvestigator> tree .
.
├── bin
│ └── Debug
│ └── net8.0
│ ├── PSInvestigator.deps.json
│ ├── PSInvestigator.dll
│ └── PSInvestigator.pdb
├── en-us
│ └── PSIPartitions-Help.xml
├── PSICmdline.cs
├── PSInvestigator.csproj
├── PSInvestigator.psd1
├── PSInvestigator.psm1
├── PSIPartitions.cs
├── PSIUptime.cs
└── PSIVersion.cs
I generated my .psd1 using the NewModuleManifest PowerShell cmdlet and I made sure to add these lines to it exported all the functions and specifying the .psm1 file. I'm not actually sure if I need the .psm1 file though.
# Script module or binary module file associated with this manifest.
RootModule = 'PSInvestigator.psm1'
# Assemblies that must be loaded prior to importing this module
RequiredAssemblies = @("./bin/Debug/net8.0/PSInvestigator.dll")
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = '*'
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = '*'
# Variables to export from this module
VariablesToExport = '*'
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = '*'
I added this to the .psm1 file but I've tried imported the module both with and without the .psm1 file and neither option has worked
# Get the directory of the script
$scriptDirectory = $PSScriptRoot
# Load the assembly
$assemblyPath = Join-Path -Path $scriptDirectory -ChildPath "bin/Debug/net8.0/PSInvestigator.dll"
Add-Type -Path $assemblyPath
# Exported cmdlets and functions
Export-ModuleMember -Function * -Cmdlet *
Now when I run import-module ./PSInvestigator.psd1 and execute Get-Module I don't see any exported commands
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Script 0.0.1 PSInvestigator
If I just run import-module on the full path /home/deca/RiderProjects/PSInvestigator/PSInvestigator/bin/Debug/net8.0/PSInvestigator.dll everything works. What do I need to do to get the PowerShell Module and it's documentation to be imported correctly?
psm1for a binary module. YourRootModuleshould be the relative path to your assembly. as for the help, it seems correctly placed. As long as it is a valid xaml, generally the easiest way to generate your help file is using platyPS converting your md (markdown files) to that single XML as you have, then PowerShell should correctly load the cmdlet's help. If you do need apsm1for some reason, then your current issue is that you're usingAdd-Typeto thedllinstead ofImport-Moduleto thedll