Skip to content

$PSScriptRoot is null when loading scripts into Resolve-DynamicFunctionDefinition via dot sourcing #6

Description

@thayesgh

General summary of the issue

  • $PSScriptRoot is null when loading scripts into Resolve-DynamicFunctionDefinition via dot sourcing

Describe your environment

  • Dynamic version : 1.1.1
    PowerShell version : 7.4.0
    OS version : Microsoft Windows NT 10.0.19045.0

Steps to reproduce

    invokeOnImport  = {
            $public = Get-ChildItem -Path "$PSScriptRoot/public" -Filter *.ps1

            foreach ($script in $public) {
                . $script.FullName

                $functionInfo = Get-Command -Name $script.BaseName

                . (Resolve-DynamicFunctionDefinition -FunctionInfo $functionInfo)
            }
        }

Expected Behavior

  • $PSScriptRoot is set to the appropriate path of the script/function being called.

Current Behavior

  • $PSScriptRoot is null.

Possible Solution? (optional)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions