Package script for running in Linux

Tool: PowerShell Module
Version: 

I remember having done this a while ago with netcoreapp31 and PWSH 7.03. I need to create a Linux (Ubuntu 21-04) executable. I installed the PS ProTools in Linux and tried. I also installed the .NET SDK 6.0 for Linux. These are the errors obtained:

This is the PSD1 file:

@{
        Root = '/home/victor/source/executeJava.ps1'
        OutputPath = '/home/victor/source/out'
        Package = @{
            Enabled = $true
            Obfuscate = $false
            HideConsoleWindow = $false
            DotNetVersion = 'net6.0'
            PowerShellVersion = '7.2.0'
            RuntimeIdentifier = 'linux-x64'
            FileVersion = '1.0.0'
            FileDescription = ''
            ProductName = ''
            ProductVersion = ''
        }
        Bundle = @{
            Enabled = $true
            Modules = $false
        }
    }

Am I missing a SDK in Linux?

Please advise.

I uninstalled the PS Pro Tools module and started playing with the old versions, until I found that with version 5.8.10, netcoreapp31, and PWSH 7.0.3 the script now gets converted to executable, and runs.

I tried with later versions and I got the same error as before, so something dramatic changed in the way the linux executable is obtained.

1 Like

Adam,

I just installed 2021.2.1 in my Ubuntu system and tried to compile again my script with .NET 6.0 and PWSH 7.2.0, and this is the error i got. SHOULD I RUN AS ROOT?

PS /home/victor/source> merge-script -Configfile ./executeJava.psd1 -verbose
VERBOSE: Checking license
VERBOSE: OutputPath is /home/victor/source/out
VERBOSE: Bundling /home/victor/source/executeJava.ps1
VERBOSE: Parsing file /home/victor/source/executeJava.ps1.
VERBOSE: Packaging /tmp/executeJava.ps1
VERBOSE: Creating temp directory: /tmp/83732ca30a004e37a3448549ee35a7e2
VERBOSE: Packaging modules...
VERBOSE: Checking dotnet version.
VERBOSE: Checking dotnet SDK version.
VERBOSE: 6.0.102

VERBOSE: .NET SDK Version: 6.0.102

VERBOSE: Creating package project.
VERBOSE: Using .NET Framework version: net6.0
VERBOSE:   Determining projects to restore...
  Restored /tmp/83732ca30a004e37a3448549ee35a7e2/executeJava.csproj (in 337 ms).

VERBOSE:   Determining projects to restore...
  Restored /tmp/83732ca30a004e37a3448549ee35a7e2/executeJava.csproj (in 337 ms).

VERBOSE: Packaging /tmp/executeJava.ps1 -> /home/victor/source/out/executeJava
VERBOSE: Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  Restored /tmp/83732ca30a004e37a3448549ee35a7e2/executeJava.csproj (in 398 ms).
/tmp/83732ca30a004e37a3448549ee35a7e2/ConsolePowerShellHost.cs(88,13): warning SYSLIB0021: 'TripleDESCryptoServiceProvider' is obsolete: 'Derived cryptographic types are obsolete. Use the Create method on the base type instead.' [/tmp/83732ca30a004e37a3448549ee35a7e2/executeJava.csproj]
/tmp/83732ca30a004e37a3448549ee35a7e2/ConsolePowerShellHost.cs(88,55): warning SYSLIB0021: 'TripleDESCryptoServiceProvider' is obsolete: 'Derived cryptographic types are obsolete. Use the Create method on the base type instead.' [/tmp/83732ca30a004e37a3448549ee35a7e2/executeJava.csproj]
/tmp/83732ca30a004e37a3448549ee35a7e2/ConsolePowerShellHost.cs(141,35): warning SYSLIB0012: 'Assembly.CodeBase' is obsolete: 'Assembly.CodeBase and Assembly.EscapedCodeBase are only included for .NET Framework compatibility. Use Assembly.Location.' [/tmp/83732ca30a004e37a3448549ee35a7e2/executeJava.csproj]
  executeJava -> /tmp/83732ca30a004e37a3448549ee35a7e2/bin/Release/net6.0/linux-x64/executeJava.dll
  executeJava -> /tmp/83732ca30a004e37a3448549ee35a7e2/out/

VERBOSE: Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  Restored /tmp/83732ca30a004e37a3448549ee35a7e2/executeJava.csproj (in 398 ms).
/tmp/83732ca30a004e37a3448549ee35a7e2/ConsolePowerShellHost.cs(88,13): warning SYSLIB0021: 'TripleDESCryptoServiceProvider' is obsolete: 'Derived cryptographic types are obsolete. Use the Create method on the base type instead.' [/tmp/83732ca30a004e37a3448549ee35a7e2/executeJava.csproj]
/tmp/83732ca30a004e37a3448549ee35a7e2/ConsolePowerShellHost.cs(88,55): warning SYSLIB0021: 'TripleDESCryptoServiceProvider' is obsolete: 'Derived cryptographic types are obsolete. Use the Create method on the base type instead.' [/tmp/83732ca30a004e37a3448549ee35a7e2/executeJava.csproj]
/tmp/83732ca30a004e37a3448549ee35a7e2/ConsolePowerShellHost.cs(141,35): warning SYSLIB0012: 'Assembly.CodeBase' is obsolete: 'Assembly.CodeBase and Assembly.EscapedCodeBase are only included for .NET Framework compatibility. Use Assembly.Location.' [/tmp/83732ca30a004e37a3448549ee35a7e2/executeJava.csproj]
  executeJava -> /tmp/83732ca30a004e37a3448549ee35a7e2/bin/Release/net6.0/linux-x64/executeJava.dll
  executeJava -> /tmp/83732ca30a004e37a3448549ee35a7e2/out/

VERBOSE: Packaging executable with args: -c 8 --runner x86_64-unknown-linux-musl -i none "/tmp/83732ca30a004e37a3448549ee35a7e2/out" "executeJava" "/tmp/83732ca30a004e37a3448549ee35a7e2/out/packed"
Merge-Script: An error occurred trying to start process '/tmp/wrappe-linux' with working directory '/home/victor/source'. Permission denied
PS /home/victor/source>

Please advise.

P.S. I just ran it as root and got the same error as above.

I’ll have to look into this. I know compiling from a Windows box for Linux works since I have tests for the running on builds. If you want to try targeting Linux from Windows, you can give that a try.

I dont have that environment. Mine is a Ubuntu 21.10. I will wait for you to test it. I can try also in a Centos 7 environment however that would force me to install the SDKs I dont have

Hi Adam. I wonder if you are going to check on this problem for a next release of the Tools.

Yep. This is slated for our next version.

I read 2022.3.1 is available however I dont see it in PS Gallery yet.

Hmmm deployment failed. Checking…

The version was bumped so it failed to release to the gallery. Running a new build with the updated version. It should be available in the next couple of hours.

Still MIA…

Should be available now. They made changes to the PowerShell Gallery that broke all our release pipelines. If you manage any modules, make sure to change the version from x.x.x to x.x.x.x otherwise publishing with fail. :confounded: