We are currently evaluating the PowerShellProTools PowerShell module in order to package a PowerShell Core script into a self-contained executable for Linux.
We installed the .NET SDK (3.1.301) and PowerShell Core (7.0.2) on an Ubuntu machine. Next up we tried to run the following command:
/usr/share/dotnet/sdk/3.1.301/Microsoft.Common.CurrentVersion.targets(1177,5): error MSB3644: The reference assemblies for .NETFramework,Version=v4.6.2 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [/tmp/bf3bf0c9032740e2b325b3c7638b90d3/My.csproj]
0 Warning(s)
1 Error(s)
Of course we can’t install the .NET Framework 4.6.2 on Linux, we don’t even know why it is trying to use .NET 4.6.2 when we’ve installed .NET Core only.
I tried to run the same cmdlet in Windows, we don’t need to build the script on Linux we just need it to be executable on Linux .
However, it also fails, with a different error though:
VERBOSE: Checking license
VERBOSE: OutputPath is C:\Temp\MyCore
VERBOSE: OutputPath does not exist. Creating directory.
VERBOSE: Bundling C:\Temp\My.ps1
VERBOSE: Packaging C:\Users\dr\AppData\Local\Temp\My.ps1
VERBOSE: Checking dotnet version.
VERBOSE: 3.1.301
VERBOSE: 3.1.301
VERBOSE: Creating package project.
VERBOSE: Using .NET Framework version: netcoreapp31
VERBOSE: Determining projects to restore...
Restored C:\Users\dr\AppData\Local\Temp\3d89977364c04f01ae2ac4fc903fb7c2\My.csproj (in 567 ms).
VERBOSE: Determining projects to restore...
Restored C:\Usersdr\AppData\Local\Temp\3d89977364c04f01ae2ac4fc903fb7c2\My.csproj (in 567 ms).
VERBOSE: Packaging C:\Users\dr\AppData\Local\Temp\My.ps1 -> C:\Temp\MyCore\My.exe
VERBOSE: Microsoft (R) Build Engine version 16.6.0+5ff7b0c9e for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
Restored C:\Users\dr\AppData\Local\Temp\3d89977364c04f01ae2ac4fc903fb7c2\My.csproj (in 5,68 sec).
ConsolePowerShellHost.cs(26,13): error CS0234: The type or namespace name 'Forms' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?) [C:\Users\dr\AppData\Local\Temp\3d89977364c04f01ae2ac4fc903fb7c2\My.csproj]
Merge-Script: Failed to build.