Powershell: Include another script that has includes?

Viewed 21437

I want to make my life easier when making scripts. I'm staring a little framework that will have a hierarchy of include files. The problem is dot sourcing a ps1 script that already has other files dot sourced brakes the scope in the original calling scripts. It looks like this:

\config\loadvariables.ps1

$var = "shpc0001"

\config\config.ps1

. '.\loadvariables.ps1'

\test.ps1

. '.\config\config.ps1'
echo $var

The problem is that test.ps1 tries to load loadvariables.ps1 as it is located beside test.ps1 script. How can I solve this?

2 Answers
Related