0

I am trying to automatically call powershell script when install my own nuget package.

My install.ps1 is as below

I want to call a function in functions.ps1 which is in tools\Functions.ps1

Functions.ps1

Function Write-HelloWorld($param1 , $param2)
{
    Write-Output "$param1 and $param2"
}

Install.ps1

param($installPath, $toolsPath, $package, $project)

. .\Functions.ps1

Write-HelloWorld 1,2

I am getting error saying the install.ps1 not able to find the function Write-HelloWorld.

How to call the function Write-HelloWorld in functions.ps1 inside install.ps1?

Thanks

Mukil Deepthi
  • 6,072
  • 13
  • 71
  • 156

1 Answers1

0

Instead of having

..\Functions.ps1

you can use

. (join-path $toolsPath 'Functions.ps1')

Both the install.ps1 file and the Functions.ps1 file will need to be in the tools folder.

phokus
  • 341
  • 2
  • 6