Open wuping2004 opened 4 years ago
This is likely due to Publish-Module needing to look for a folder with the same name as the module you are looking to publish.
Can you create a new folder called Lazlo.PowerShell.Operations and move all the files thats under the netstandard2 folder and put them into this new folder?
Then once you do that you should be able to publish by running Publish-module to that Lazlo.PowerShell.Operations folder
Publishing C# cmdlets to the PowerShell Gallery
Publishing C# cmdlets to the PowerShell Gallery
Back to index Matthieu Maitre
PowerShellGet and the PowerShell Gallery are the equivalent of NuGet/NPM/Bower package managers for PowerShell. They come handy to share scripts and modules.
Installing a module, like this demo one for instance, is a one-liner:
Creating and publishing a new module is also relatively straightforward, although not exceptionally well documented.
A simple
Write-HelloWorld
cmdlet consists in a class deriving fromCmdlet
that overridesBeginProcessing
to output a string:One trick here is finding the
System.Management.Automation
reference. On my machine (Windows 10 x64) it could be found atc:\Program Files (x86)\Reference Assemblies\Microsoft\WindowsPowerShell\3.0\System.Management.Automation.dll
.Once compiled, the DLL that can be loaded in PowerShell using
Import-Module
.To make it a publishable module requires adding a .psd1 PowerShell manifest akin to NuGet’s .nuspec XML manifest:
Both the DLL and .psd1 file need to be placed in a folder whose name is the package name. Once this is done, the package gets uploaded to the gallery using
where the API Key comes from https://powershellgallery.com/account.
That is it. For the full source code and some unit-testing tricks see this repo on GitHub. https://mmaitre314.github.io/2016/03/22/publishing-csharp-cmdlets-to-the-powershell-gallery.html