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

Install PowerShell modules to a custom directory #125

Open
splatteredbits opened this issue Feb 4, 2021 · 6 comments
Open

Install PowerShell modules to a custom directory #125

splatteredbits opened this issue Feb 4, 2021 · 6 comments

Comments

@splatteredbits
Copy link

We have dozens of applications that use different versions of PowerShell modules when they get deployed. These modules are not pre-installed on the destination servers, nor do those servers have network access to any place from which they can be downloaded. Instead, we save all our to a PSModules directory in each application's repository (during builds) and include that directory in our deployment packages. Scripts import modules from that directory instead of globally.

Update PSDepend to support saving a module to a custom path instead of using "Install-Module".

@splatteredbits
Copy link
Author

If you give me a little direction on how you'd like this implemented, I can put together a PR. We use Whiskey to run our builds, and it has a GetPowerShellModule build task, but I'd prefer to get Whiskey out of the PowerShell module management business.

@gaelcolas
Copy link
Contributor

gaelcolas commented Feb 5, 2021

Hey Aaron, you can already using the option target:
https://github.com/gaelcolas/Sampler/blob/master/RequiredModules.psd1

It will save the modules in the target path.

@{
    PSDependOptions             = @{
        AddToPath  = $true
        Target     = 'output\RequiredModules'
        Parameters = @{}
    }

    InvokeBuild                 = 'latest'
    PSScriptAnalyzer            = '1.19.0'
    Pester                      = '4.10.1'
    Plaster                     = 'latest'
    ModuleBuilder               = 'latest'
}

@splatteredbits
Copy link
Author

Thank. This issue can be closed.

@fourpastmidnight
Copy link

@gaelcolas Quick question: do you know, is the PSDependOptions.Target directory relative to the *.psd1 file where it is set? For example, if I have the following directory structure:

<ProjectRoot>
  | -- build
  |      | -- build.depend.psd1  <-- Contains my PSDepend configuration
  | -- Dependencies              <-- This is where I want PSDependOptions.Target to point to...

then would PSDependOptions.Target's value be ..\Dependencies?

@gaelcolas
Copy link
Contributor

I don't know.
I'd expect either that or $pwd.

@fourpastmidnight
Copy link

Thanks for the response @gaelcolas , I appreciate it!

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

No branches or pull requests

3 participants