PowerShellGetv2
PowerShellGetv2 copied to clipboard
Publish-Module cannot be used on default $(OutputPath) for binary module
I've created a lot of modules (publicly, and for internal tooling) and always find myself having to reinvent the wheel when it comes to packaging and publishing PowerShell modules because Publish-Module
expects modules to be laid out as if they were installed, which really seems like getting the cart before the horse. It would be ideal if, at least when using the -Path
parameter set, Publish-Module
didn't just assume the module is laid out correct, or fail otherwise.
Steps to reproduce
- Create new project directory: mkdir test
- Create a new project: dotnet new classlib
- Add references: dotnet add package PowerShellStandard.Library
- Add a binary cmdlet
- Build: dotnet build
- Try to package:
publish-module -path bin\Debug (other args)
Expected behavior
It packages and publishes the module.
Actual behavior
publish-module : The specified module with path '.\bin\Debug' was not published because no valid module was found with that path.
Environment data
Name Value
---- -----
PSVersion 6.2.0
PSEdition Core
GitCommitId 6.2.0
OS Microsoft Windows 10.0.17763
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
(Though this happens/has happened with every version of (Windows) PowerShell. PowerShellGet is also at 2.1.2.
At present we expect there will be a .psd1 file containing the module manifest. Without that there's a bunch of data missing (what would you like the module to be called, for example?). So I feel like having a manifest in your project is going to be a requirement.
Beyond that, yes, the file layout Publish-Module requires and the default layout dotnet/msbuild creates are different, which is a nuisance. Willing to consider PRs which don't break existing publish commands, but don't expect we can work on it soon.
Almost every module I've written uses a properly formed PSD1 file, but the problem here is that a specific directory structure is required. If -Path
is used, is there any reason to think that, if the current directory structure isn't present, assuming everything local (as if msbuild produced it) would be breaking? Otherwise, I could add a switch parameter to opt into this new behavior.
A module manifest would be the minimum requirement I would think (even though .psm1 can be used standalone, it's not a best practice). If there is a .psd1 in the target path, we could assume the name of the psd1 is the module name as they have to match anyways.