Merge-Script Issues

I have a simple Powershell Module, Test.psm1

#requires -Version 5.1

#region Using Statements
using namespace System.Web
#endregion

class Test {

    Test()
    {
        [String] $UserPrincipalName = "john.smith@nowhere.com"
        [String] $filter = "userPrincipalName eq '{0}'" -f $UserPrincipalName

        [String] $select = "id, userPrincipalName"

        $queryString = [HttpUtility]::ParseQueryString([String]::Empty)
        $queryString.Add('$filter', $filter)
        $queryString.Add('$select', $select)

        [String] $baseUri = "https://graph.microsoft.com/v1.0/users"
        [UriBuilder] $queryObject = $baseUri
        $queryObject.Query = $queryString.ToString()
        [String] $uri = $queryObject.Uri.OriginalString

        Write-Host($uri)
    }
}

and a script that invokes the class constructor above

#requires -Version 5.1

#region Using Statements
using module .\Test.psd1
#endregion

class Program {

    static [void] Main() {
        [Test]::new()
    }
}

[Program]::Main()

The file Test.psd1 contains the property for RequiredAssemblies

RequiredAssemblies = 'System.Web'

My pspack.config.psd1 files contents are

@{
    Root = ".\TestHttp.ps1";
    OutputPath = ".\TestHttp";
    Bundle = @{
        Enabled = $true;
        Modules = $true;
        NestedModules = $true;
        RequiredAssemblies = $true;
    }
    Package = @{
        Enabled = $true
        Obfuscate = $true
    }
}

After I run the
Merge-Script -ConfigFile .\pspack.config.psd1 -Verbose

and run the resulting EXE file I get the following error

Import-Module : File C:\temp\Test.psm1 cannot be loaded. The file C:\temp\Test.psm1 is not digitally signed. You
cannot run this script on the current system. For more information about running scripts and setting execution policy,
see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
    + CategoryInfo          : SecurityError: (:) [Import-Module], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess,Microsoft.PowerShell.Commands.ImportModuleCommand

This seems to suggest that the script bundling is really not happening if it is still looking on the disk for Test.psm1 file. What do I need to change to make this work?

I really need help with this issue. Anybody willing to help, please?

The packager doesn’t support the using statement for modules. It’s something we can get added. I’ll put it in the backlog. I realize you probably need the using statement otherwise the classes won’t be loaded.

Yes please do put support for the using statements in the backlog along with the ability to parse the psd files in the using statements and process the contents with respect to the RootModule, RequiredModules, RequiredAssemblies, ScriptsToProcess and other relevant directives.

Thank you much for taking this into consideration!