-
Notifications
You must be signed in to change notification settings - Fork 103
Import-Module isn't exporting classes #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Would that be the cause of this error? Thanks!
|
Yep. This is how I'm working around it right now. |
Sorry, that doesn't work for me:
And the following is thrown whether or not I include AllowPrerelease:
$PSVersionTable
|
@lhoff did you ever find a resolution to this ? If you import the psm1 file instead of the PSD1 file you will get missing class errors. |
@adamdriscoll typically what I'd recommend doing here is just double up on your attribute class. The PowerShell class resolver is a bit janky across the module boundary, and I've found I often need to define a class MyClassAttribute : ValidateEnumeratedArgumentsAttribute {
$Property = 1
}
class MyClass : MyClassAttribute { } If that's not sufficient and you really do need to import the classes into the global session (would recommend avoiding it if you can, but sometimes you do need to), you can use # ScriptsToProcess file
switch ($null) {
('ClassName' -as [type]) {
# this class hasn't been created yet, create it here
}
# rinse and repeat for any number of classes throughout the switch statement
} |
@vexx32 - Thank you for this info! I haven't taken the time to solve this but I'm going to play with this today and see if I can avoid this issue. I'm seeing it in UD all the time now. |
This did the trick. Seems to work for me in PSv5.1 and PSv7 |
There are attributes used for certain cmdlets that throw exceptions when imported by Import-Module in PowerShell v5.1
Version: v3-beta1
The text was updated successfully, but these errors were encountered: