Object browser don't see any function from module

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
alpari
Posts: 5
Joined: Thu Jan 14, 2016 4:30 am

Object browser don't see any function from module

Post by alpari » Tue Apr 19, 2016 3:15 am

PowerShell Studio 2016 x64 (5.2.119)
Windows 8 x64
PowerShell (from $PSVersionTable):
PSVersion 3.0
WSManStackVersion 3.0
SerializationVersion 1.1.0.1
CLRVersion 4.0.30319.42000
BuildVersion 6.2.9200.17065
PSCompatibleVersions {1.0, 2.0, 3.0}
PSRemotingProtocolVersion 2.2
==================================================

Good day. Read a lot of posts on this forum and on other sites but didn't find solution for my problem: PS Studio don't show me any function from my module.
Module was created by PS Studio. It contains from 3d part libraries and functions inside .psm1. So I have next files structure:

├ PSLibraryPack
│ └─NLog
│─PSLibraryPack.psd1
│─PSLibraryPack.psm1

So in folder NLog I have .dll file that will not assembly by importing module, only with function from module. Also i create profile.ps1 and put it to C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1. Inside:

Code: Select all

<# Start code for import PSLibraryPack #>
Import-Module PSLibraryPack -Force -DisableNameChecking
<# End code for import PSLibraryPack #>
So everytime that PowerShell started module will importing and inside PS everything working fine.
1.png
1.png (11.31 KiB) Viewed 1496 times
Here code from .psm1:

Code: Select all

function Set-ReturnObject {
	$obj = New-Object System.Management.Automation.PSObject
	Add-Member -InputObject $obj -MemberType NoteProperty -Name success -Value $false
	Add-Member -InputObject $obj -MemberType NoteProperty -Name errorInfo -Value $null
	Add-Member -InputObject $obj -MemberType NoteProperty -Name result -Value $null
	return $obj
}


function NLog.Get-Library {
	$returnObject = Set-ReturnObject
	try {
		[System.Void][System.Reflection.Assembly]::LoadFile($Script:PSScriptRoot + "\NLog\NLog.dll")
		$returnObject.success = $true
	} catch {
		$returnObject.errorInfo = $Error[0]
	}
	
	return $returnObject
}

function NLog.Set-Logger {
	[CmdletBinding()]
	param
	(
		[Parameter(Mandatory = $false,
				   Position = 0)]
		[System.String]$loggerName,
		[Parameter(Mandatory = $false,
				   Position = 1)]
		[System.String]$logsDir
	)
	
	$returnObject = Set-ReturnObject
	try {
		$nlogConfig = New-Object NLog.Config.XmlLoggingConfiguration($Script:PSScriptRoot + "\NLog\NLog.xml")
		[NLog.LogManager]::Configuration = $nlogConfig
		
		if ($logsDir) {
			$target = [NLog.LogManager]::Configuration.FindTargetByName("logfile")
			$target.FileName = $logsDir + "\`${shortdate}.log"
			[NLog.LogManager]::ReconfigExistingLoggers() | Out-Null
		}
		
		if ($loggerName) {
			$logger = [NLog.LogManager]::GetLogger($loggerName)
		} else {
			$logger = [NLog.LogManager]::GetLogger("nlog")
		}
		
		$returnObject.success = $true
		$returnObject.result = $logger
	} catch {
		$returnObject.errorInfo = $Error[0]
	}
	
	return $returnObject
}

Export-ModuleMember NLog.Get-Library
Export-ModuleMember NLog.Set-Logger
and .psd1:

Code: Select all

<#	
	===========================================================================
	 Created with: 	SAPIEN Technologies, Inc., PowerShell Studio 2016 v5.2.117
	 Created on:   	21.03.2016 21:23:09
	 Created by:   	Alexander Tarassenko
	 Organization: 	Roga i kopyta
	 Filename:     	PSLibraryPack.psd1
	 -------------------------------------------------------------------------
	 Module Manifest
	-------------------------------------------------------------------------
	 Module Name: PSLibraryPack
	===========================================================================
#>

@{
	
	# Script module or binary module file associated with this manifest
	ModuleToProcess = 'PSLibraryPack.psm1'
	
	# Version number of this module.
	ModuleVersion = '1.0.1.0'
	
	# ID used to uniquely identify this module
	GUID = '4b44e42b-1060-4108-8166-c28bdb5e0d91'
	
	# Author of this module
	Author = 'Alexander Tarassenko'
	
	# Company or vendor of this module
	CompanyName = 'Roga i kopyta'
	
	# Copyright statement for this module
	Copyright = '(c) 2016. All rights reserved.'
	
	# Description of the functionality provided by this module
	Description = 'PowerShell Library Pack Module'
	
	# Minimum version of the Windows PowerShell engine required by this module
	PowerShellVersion = '3.0'
	
	# Name of the Windows PowerShell host required by this module
	PowerShellHostName = ''
	
	# Minimum version of the Windows PowerShell host required by this module
	PowerShellHostVersion = ''
	
	# Minimum version of the .NET Framework required by this module
	DotNetFrameworkVersion = '4.0'
	
	# Minimum version of the common language runtime (CLR) required by this module
	CLRVersion = '4.0'
	
	# Processor architecture (None, X86, Amd64, IA64) required by this module
	ProcessorArchitecture = 'None'
	
	# Modules that must be imported into the global environment prior to importing
	# this module
	RequiredModules = @()
	
	# Assemblies that must be loaded prior to importing this module
	RequiredAssemblies = @()
	
	# Script files (.ps1) that are run in the caller's environment prior to
	# importing this module
	ScriptsToProcess = @()
	
	# Type files (.ps1xml) to be loaded when importing this module
	TypesToProcess = @()
	
	# Format files (.ps1xml) to be loaded when importing this module
	FormatsToProcess = @()
	
	# Modules to import as nested modules of the module specified in
	# ModuleToProcess
	NestedModules = @()
	
	# Functions to export from this module
	FunctionsToExport = '*'
	
	# Cmdlets to export from this module
	CmdletsToExport = '*'
	
	# Variables to export from this module
	VariablesToExport = '*'
	
	# Aliases to export from this module
	AliasesToExport = '*'
	
	# List of all modules packaged with this module
	ModuleList = @()
	
	# List of all files packaged with this module
	FileList = @()
	
	# Private data to pass to the module specified in ModuleToProcess
	PrivateData = @{
		
		#Support for PowerShellGet galleries.
		PSData = @{
			
			# Tags applied to this module. These help with module discovery in online galleries.
			# Tags = @()
			
			# A URL to the license for this module.
			# LicenseUri = ''
			
			# A URL to the main website for this project.
			# ProjectUri = ''
			
			# A URL to an icon representing this module.
			# IconUri = ''
			
			# ReleaseNotes of this module
			# ReleaseNotes = ''
			
		} # End of PSData hashtable
		
	} # End of PrivateData hashtable
}
Module located for all users: C:\Windows\System32\WindowsPowerShell\v1.0\Modules\PSLibraryPack
So why in PowerShell I can see cmdlet but not in PSStudio?
2.png
2.png (17.88 KiB) Viewed 1496 times
I tried to use CacheBuilder but it's not helped: files that must contains cmdlets for module are empty:
3.png
3.png (27.15 KiB) Viewed 1496 times
What I'm doying wrong? Please help )

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

Re: Object browser don't see any function from module

Post by davidc » Tue Apr 19, 2016 9:02 am

Try changing the version number of the module in the manifest then export it again. Once the cache update completes, let me know if the cmdlets appear.

David
David
SAPIEN Technologies, Inc.

User avatar
alpari
Posts: 5
Joined: Thu Jan 14, 2016 4:30 am

Re: Object browser don't see any function from module

Post by alpari » Tue Apr 19, 2016 9:34 am

Unfortunately it's not help. Trying do it twice:
4.png
4.png (20.15 KiB) Viewed 1482 times
Files are empty.
5.png
5.png (23.63 KiB) Viewed 1482 times

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

Re: Object browser don't see any function from module

Post by davidc » Tue Apr 19, 2016 9:45 am

Please zip the project files and upload them our SAPIEN Support uploads:

https://www.sapien.com/support/upload

This way we can test the module on our end to see what is happening.

David
David
SAPIEN Technologies, Inc.

User avatar
alpari
Posts: 5
Joined: Thu Jan 14, 2016 4:30 am

Re: Object browser don't see any function from module

Post by alpari » Tue Apr 19, 2016 12:24 pm

Uploaded. But web browsre didn't return URL when upload finished. File name: pslp.zip.
Thanks )

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

Re: Object browser don't see any function from module

Post by davidc » Tue Apr 19, 2016 2:12 pm

I believe the issue is related to the cmldet names. If you remove the "NLog." portion of the cmdlet name, it should appear in the cache.

I also forwarded the project to the dev team, so that they can determine why this is causing an issue in the caching process.

David
David
SAPIEN Technologies, Inc.

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

Re: Object browser don't see any function from module

Post by davidc » Tue Apr 19, 2016 2:16 pm

FYI, if you want to follow PowerShell naming conventions, you should look at naming the cmdlets:

Set-NLogLogger
Get-NLogLibrary

David
David
SAPIEN Technologies, Inc.

User avatar
alpari
Posts: 5
Joined: Thu Jan 14, 2016 4:30 am

Re: Object browser don't see any function from module

Post by alpari » Tue Apr 19, 2016 11:55 pm

It helps.
Thank you very much ))