PoshCode / ModuleBuilder

A PowerShell Module to help scripters write, version, sign, package, and publish.
MIT License
445 stars 54 forks source link

Install-RequiredModule is ignoring the full name #66

Closed Jaykul closed 4 years ago

Jaykul commented 5 years ago

I was trying to do a build that's split across multiple agents. My default RequiredModules.psd1 file has all the things in it which I want on my dev laptop for this project:

@{
    "PowerShellGet"    = "[2.1.4, 3.0)"
    "ModuleBuilder"    = "1.*"
    "Pester"           = "[4.8.0, 5.0)"
    "PSScriptAnalyzer" = "1.18.0"
}

But on the build and test agents, I'd like to install a subset:

#### RequiredModules.Build.psd1
@{
    "ModuleBuilder"    = "1.*"
}

#### RequiredModules.Test.psd1
@{
    "Pester"           = "[4.8.0, 5.0)"
    "PSScriptAnalyzer" = "1.18.0"                                                                                                                            }

However Install-RequiredModule in ImportRequiredModulesFile does this:

        $LocalizedData = @{
            BaseDirectory = [IO.Path]::GetDirectoryName($RequiredModulesFile)
            FileName = [IO.Path]::GetFileNameWithoutExtension($RequiredModulesFile)
        }
        Import-LocalizedData @LocalizedData

And so when I call it with RequiredModules.Build.psd1 it's removing the .psd1 and then Import-LocatlizedData actually sees the .Build as a file extension, and removes it, and then loads RequiredModules.psd1 instead of RequiredModules.Build.psd1

I don't know why we might need to GetFileNameWithoutExtension there, but I think it's better if we don't, to support the idea of installing a subset like this. What do you think?

I suppose I can just rename them to RequiredModules-Build.psd1 but it seems weird that I need to, and this feels like a bug.

Jaykul commented 4 years ago

OK, Install-RequiredModule is in it's own repo now. This is fixed in the version that's on master there: /Jaykul/RequiredModules