Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guidance on External Module Dependencies #151

Open
brotherdust opened this issue Jun 25, 2021 · 3 comments
Open

Guidance on External Module Dependencies #151

brotherdust opened this issue Jun 25, 2021 · 3 comments

Comments

@brotherdust
Copy link

Hello! This is such a great document! Thanks to all the community for putting it together.

I am authoring a module that I'd like to be re-usable by others. This module depends on other third-party modules. What's the best or "least wrong" way to define these dependencies in such a way as that, when a user downloads the module, the dependencies will be downloaded, too?

Thanks much!

@ChrisLGardner
Copy link

Use the RequiredModules section of the psd1 file and then PowerShellGet will handle the rest for you.

@brotherdust
Copy link
Author

Thank you for such a fast reply!
One more question: is there a way to "test" that the modules specified in RequireModules work? Like a sort of fake or mock install?
Thanks again!

@Jaykul
Copy link
Member

Jaykul commented Jun 29, 2021

Not sure what you mean, exactly. Testing that PowerShell or PowerShellGet work is kind-of outside the scope of your module, right? I mean, there are tests in their repositories, and you can validate how the installation works with existing modules such as ModuleBuilder which depends on Configuration, or PowerLine which depends on Configuration and PANSIES -- or even the "Az" module which is a "meta module" that installs about 60 dependencies...

For what it's worth ...

Faking out the module during installation with PowerShellGet is complicated, because they do extra (file system) checks when installing (they keep metadata files with the modules that they install), so the existence of a module on your system will not convince them to skip installing the version that comes from the same gallery you're installing from.

However, you can easily create a new PowerShellGet Source by registering a folder on your system as your source, and sticking (real or partial or metadata-only) modules in there to trick PowerShellGet into not installing the real modules. Additionally, there's an ExternalModuleDependencies property you can put in your module's PrivateData\PSData in order to tell PowerShellGet that some dependencies should be managed outside of PowerShellGet...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants