Including custom library (like Globals.ps1)

Archived support forum for customers who once purchased a PrimalForms product license. This forum is locked.
User avatar
CEMEDIC
Posts: 7
Joined: Wed Jun 06, 2012 1:54 am

Including custom library (like Globals.ps1)

Post by CEMEDIC »

I've created a new project (not a forms project) and I'm packaging that project as a console application.

I have a file with all my cmdlets that I use throughout the script that is separate from my main application file. I'm not sure how PowerShell Studio 2012 packages everything together, do I need to dot source the library file? If so, what's the directory? Is there some option I need to select when packaging?

When I run the application once it's been bundled off to an .exe file, I call the executable, which has a call to a cmdlet named "test" in my library file. This is the output I get when I run the executable that PowerShell Studio creates:

Code: Select all

ERROR: The term 'test' is not recognized as the name of a cmdlet, function, script fil 
ERROR: e, or operable program. Check the spelling of the name, or if a path was includ 
ERROR: ed, verify that the path is correct and try again. 
ERROR: At line:38 char:6 
ERROR: +     test <<<< 
ERROR:     + CategoryInfo          : ObjectNotFound: (test:String) [], CommandNotFoun 
ERROR:    dException 
ERROR:     + FullyQualifiedErrorId : CommandNotFoundException 
ERROR:

User avatar
davidc
Posts: 5913
Joined: Thu Aug 18, 2011 4:56 am

Including custom library (like Globals.ps1)

Post by davidc »

Depends on how you use the ps1 files. If you need to execute the script file you need to use the Call-<filename> method. If the file only contains function definitions, then set the Project File's "Command Extension" property to "True" and the functions should appear in your PrimalSense. To set the property, select the file in the Project Panel and use the Property Panel to change the property. Depending on the setting, PrimalForms will wrap your file into a function or just include it as is.David
David
SAPIEN Technologies, Inc.

User avatar
CEMEDIC
Posts: 7
Joined: Wed Jun 06, 2012 1:54 am

Including custom library (like Globals.ps1)

Post by CEMEDIC »

Beautiful, thank you!