File tree Expand file tree Collapse file tree 1 file changed +17
-11
lines changed
src/chocolatey.resources/helpers Expand file tree Collapse file tree 1 file changed +17
-11
lines changed Original file line number Diff line number Diff line change @@ -62,18 +62,24 @@ if (Test-Path $extensionsPath) {
62
62
Write-Debug " Importing '$licensedExtensionPath '"
63
63
Write-Debug " Loading 'chocolatey.licensed' extension"
64
64
65
- # Attempt to import module via already-loaded assembly
66
- $licensedAssembly = $currentAssemblies |
67
- Where-Object { $_.GetName ().Name -eq ' chocolatey.licensed' } |
68
- Select-Object - First 1
69
-
70
- if ($licensedAssembly ) {
71
- # It's already loaded, just import the existing assembly as a module for PowerShell to use
72
- Import-Module $licensedAssembly
65
+ try {
66
+ # Attempt to import module via already-loaded assembly
67
+ $licensedAssembly = $currentAssemblies |
68
+ Where-Object { $_.GetName ().Name -eq ' chocolatey.licensed' } |
69
+ Select-Object - First 1
70
+
71
+ if ($licensedAssembly ) {
72
+ # It's already loaded, just import the existing assembly as a module for PowerShell to use
73
+ Import-Module $licensedAssembly
74
+ }
75
+ else {
76
+ # Fallback: load the extension DLL from the path directly.
77
+ Import-Module $licensedExtensionPath
78
+ }
73
79
}
74
- else {
75
- # Fallback: load the extension DLL from the path directly .
76
- Import-Module $licensedExtensionPath
80
+ catch {
81
+ # Only write a warning if the Licensed extension failed to load in some way .
82
+ Write-Warning " Import failed for Chocolatey Licensed Extension. Error: ' $_ ' "
77
83
}
78
84
}
79
85
You can’t perform that action at this time.
0 commit comments