Creating powershell modules from multiple files, referencing with module

后端 未结 3 677
轻奢々
轻奢々 2021-02-19 16:04

I creating a PowerShell script module using separate source files. What is the canonical way to reference source functions internal to the module from other internal source fil

3条回答
  •  耶瑟儿~
    2021-02-19 16:17

    @Ryan I similarly assumed that dot sourcing wasn't the best choice here, but I'm not so sure anymore. I've used the NestedModules approach as well, but have run up against a specific problem. I've asked the question here: PowerShell module, call function in NestedModule from another NestedModule

    In summary I find that the PrimaryModule can call any function in any NestedModule. But one NestedModule is not able to call a function in another NestedModule.

    Splitting your code out into many logical files is Developer 101 basics. So I'm really surprised there isn't a standard way of handling this.

    Any help here much appreciated. Please read the linked question, it gives plenty of detail. Is the consensus that dot sourcing has to be used? Because I'm finding the module manifest way of splitting out the code very limiting.

提交回复
热议问题