PowerShell Pro Tools 2021.12.1

A couple of fixings to packaging rolling out.

  • Fixed an issue where packaging an executable into an output directory with an apostrophe does not work.
  • Fixed an issue where PS7.1 and PS7.2 output directories would contain all unpackaged files

Adam, I am trying to download 2021.12.1 however it is not available in the PowerShell Gallery.

This was taken today 12/20/2021:

The release pipeline failed. I will get this fixed.

This has been released.

I just downloaded and tried creating the EXE again for NET 6.0 and PWSH 7.2. I am getting a strange error (see below), either using Merge-Script or directly from Visual Studio 2022.

PS ManageSmartkeys [12/20/2021 12:05:49]> merge-script -ConfigFile .\ManageSmartkeys-Core.psd1 -verbose
VERBOSE: Checking license
VERBOSE: OutputPath is C:\Users\Victor\Source\Repos\ManageSmartkeys\ManageSmartkeys\Core
VERBOSE: Bundling C:\Users\Victor\Source\Repos\ManageSmartkeys\ManageSmartkeys\ManageSmartkeys.ps1
VERBOSE: Parsing file C:\Users\Victor\Source\Repos\ManageSmartkeys\ManageSmartkeys\ManageSmartkeys.ps1.
VERBOSE: Parsing file C:\Users\Victor\Source\Repos\ManageSmartkeys\ManageSmartkeys\ListSmartkeys.ps1.
VERBOSE: Parsing file C:\Users\Victor\Source\Repos\ManageSmartkeys\ManageSmartkeys\DisplaySaving.ps1.
VERBOSE: Parsing file C:\Users\Victor\Source\Repos\ManageSmartkeys\ManageSmartkeys\APIfunctions.ps1.
VERBOSE: Parsing file C:\Users\Victor\Source\Repos\ManageSmartkeys\ManageSmartkeys\ManageSmartkeys.designer.ps1.
VERBOSE: Parsing file C:\Users\Victor\Source\Repos\ManageSmartkeys\ManageSmartkeys\ManageSmartkeys.resources.ps1.
VERBOSE: Parsing file C:\Users\Victor\Source\Repos\ManageSmartkeys\ManageSmartkeys\SmartkeyName.designer.ps1.
VERBOSE: Parsing file C:\Users\Victor\Source\Repos\ManageSmartkeys\ManageSmartkeys\SynchronizePEM.designer.ps1.
VERBOSE: Checking path $inFileName for XAML.
VERBOSE: Packaging C:\Users\Victor\AppData\Local\Temp\ManageSmartkeys.ps1
VERBOSE: Creating temp directory: C:\Users\Victor\AppData\Local\Temp\b7a9309e81dd40769e0603f8919f226f
VERBOSE: Packaging modules...
VERBOSE: Checking dotnet version.
VERBOSE: Checking dotnet SDK version.
VERBOSE: 6.0.101
VERBOSE: .NET SDK Version: 6.0.101
VERBOSE: Creating package project.
VERBOSE: Using .NET Framework version: net6.0
VERBOSE:   Determining projects to restore...
  Restored C:\Users\Victor\AppData\Local\Temp\b7a9309e81dd40769e0603f8919f226f\ManageSmartCore.csproj (in 498 ms).
VERBOSE:   Determining projects to restore...
  Restored C:\Users\Victor\AppData\Local\Temp\b7a9309e81dd40769e0603f8919f226f\ManageSmartCore.csproj (in 498 ms).
VERBOSE: Packaging C:\Users\Victor\AppData\Local\Temp\ManageSmartkeys.ps1 ->
C:\Users\Victor\Source\Repos\ManageSmartkeys\ManageSmartkeys\Core\ManageSmartCore.exe
VERBOSE: Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  Restored C:\Users\Victor\AppData\Local\Temp\b7a9309e81dd40769e0603f8919f226f\ManageSmartCore.csproj (in 550 ms).
  ManageSmartCore -> C:\Users\Victor\AppData\Local\Temp\b7a9309e81dd40769e0603f8919f226f\bin\Release\net6.0-windows\win-x64\ManageSmartCore.dll
  ManageSmartCore -> C:\Users\Victor\AppData\Local\Temp\b7a9309e81dd40769e0603f8919f226f\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 C:\Users\Victor\AppData\Local\Temp\b7a9309e81dd40769e0603f8919f226f\ManageSmartCore.csproj (in 550 ms).
  ManageSmartCore -> C:\Users\Victor\AppData\Local\Temp\b7a9309e81dd40769e0603f8919f226f\bin\Release\net6.0-windows\win-x64\ManageSmartCore.dll
  ManageSmartCore -> C:\Users\Victor\AppData\Local\Temp\b7a9309e81dd40769e0603f8919f226f\out\
VERBOSE: input path is not a directory: C:\Users\Victor\AppData\Local\Temp\b7a9309e81dd40769e0603f8919f226f\out
merge-script : Unknown error (0xffffffff)
At line:1 char:1
+ merge-script -ConfigFile .\ManageSmartkeys-Core.psd1 -verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Merge-Script], Exception
    + FullyQualifiedErrorId : PowerShellToolsPro.Cmdlets.MergeScriptCommand

PS ManageSmartkeys [12/20/2021 12:06:05]>
Rebuild started...
------ Rebuild All started: Project: ManageSmartkeys, Configuration: Release Any CPU ------
		Checking license
		OutputPath is C:\Users\Victor\Source\Repos\ManageSmartkeys\ManageSmartkeys\bin\Release\
		Packaging ManageSmartkeys.ps1
		Creating temp directory: C:\Users\Victor\AppData\Local\Temp\a81b8a9435d64e5e8285cec872df9486
		Packaging modules...
		Checking dotnet version.
		Checking dotnet SDK version.
		6.0.101

		.NET SDK Version: 6.0.101

		Creating package project.
		Using .NET Framework version: net6.0
		  Determining projects to restore...
  Restored C:\Users\Victor\AppData\Local\Temp\a81b8a9435d64e5e8285cec872df9486\ManageKeysCore.csproj (in 592 ms).

		  Determining projects to restore...
  Restored C:\Users\Victor\AppData\Local\Temp\a81b8a9435d64e5e8285cec872df9486\ManageKeysCore.csproj (in 592 ms).

		Packaging ManageSmartkeys.ps1 -> C:\Users\Victor\Source\Repos\ManageSmartkeys\ManageSmartkeys\bin\Release\ManageKeysCore.exe
		Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  Restored C:\Users\Victor\AppData\Local\Temp\a81b8a9435d64e5e8285cec872df9486\ManageKeysCore.csproj (in 528 ms).
  ManageKeysCore -> C:\Users\Victor\AppData\Local\Temp\a81b8a9435d64e5e8285cec872df9486\bin\Release\net6.0-windows\win-x64\ManageKeysCore.dll
  ManageKeysCore -> C:\Users\Victor\AppData\Local\Temp\a81b8a9435d64e5e8285cec872df9486\out\

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

  Determining projects to restore...
  Restored C:\Users\Victor\AppData\Local\Temp\a81b8a9435d64e5e8285cec872df9486\ManageKeysCore.csproj (in 528 ms).
  ManageKeysCore -> C:\Users\Victor\AppData\Local\Temp\a81b8a9435d64e5e8285cec872df9486\bin\Release\net6.0-windows\win-x64\ManageKeysCore.dll
  ManageKeysCore -> C:\Users\Victor\AppData\Local\Temp\a81b8a9435d64e5e8285cec872df9486\out\

		input path is not a directory: C:\Users\Victor\AppData\Local\Temp\a81b8a9435d64e5e8285cec872df9486\out

C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\PowerShell Tools for Visual Studio\PowerShellTools.targets(7,5): error : Unknown error (0xffffffff)
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

Please advise.

Hmm. I can’t reproduce this one.

Build started...
------ Build started: Project: PowerShellFormProject1, Configuration: Debug Any CPU ------
		Checking license
		OutputPath is C:\Users\adamr\source\repos\PowerShellFormProject1\PowerShellFormProject1\bin\Debug\
		Bundling PowerShellFormProject1.ps1
		Parsing file PowerShellFormProject1.ps1.
		Parsing file C:\Users\adamr\source\repos\PowerShellFormProject1\PowerShellFormProject1\PowerShellFormProject1.designer.ps1.
		Parsing file C:\Users\adamr\source\repos\PowerShellFormProject1\PowerShellFormProject1\PowerShellFormProject1.resources.ps1.
		Packaging C:\Users\adamr\AppData\Local\Temp\PowerShellFormProject1.ps1
		Creating temp directory: C:\Users\adamr\AppData\Local\Temp\cfc6f33f956e4cd18f085cf612e8abd1
		Packaging modules...
		Checking dotnet version.
		Checking dotnet SDK version.
		6.0.100

		.NET SDK Version: 6.0.100

		Creating package project.
		Using .NET Framework version: net6.0
		  Determining projects to restore...
  Restored C:\Users\adamr\AppData\Local\Temp\cfc6f33f956e4cd18f085cf612e8abd1\test.csproj (in 592 ms).

		  Determining projects to restore...
  Restored C:\Users\adamr\AppData\Local\Temp\cfc6f33f956e4cd18f085cf612e8abd1\test.csproj (in 592 ms).

		Packaging C:\Users\adamr\AppData\Local\Temp\PowerShellFormProject1.ps1 -> C:\Users\adamr\source\repos\PowerShellFormProject1\PowerShellFormProject1\bin\Debug\test.exe
		Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  Restored C:\Users\adamr\AppData\Local\Temp\cfc6f33f956e4cd18f085cf612e8abd1\test.csproj (in 917 ms).
  test -> C:\Users\adamr\AppData\Local\Temp\cfc6f33f956e4cd18f085cf612e8abd1\bin\Release\net6.0-windows\win-x64\test.dll
  test -> C:\Users\adamr\AppData\Local\Temp\cfc6f33f956e4cd18f085cf612e8abd1\out\

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

  Determining projects to restore...
  Restored C:\Users\adamr\AppData\Local\Temp\cfc6f33f956e4cd18f085cf612e8abd1\test.csproj (in 917 ms).
  test -> C:\Users\adamr\AppData\Local\Temp\cfc6f33f956e4cd18f085cf612e8abd1\bin\Release\net6.0-windows\win-x64\test.dll
  test -> C:\Users\adamr\AppData\Local\Temp\cfc6f33f956e4cd18f085cf612e8abd1\out\

		[1/4] counting contents of \\?\C:\Users\adamr\AppData\Local\Temp\cfc6f33f956e4cd18f085cf612e8abd1\out…
[2/4] writing runner \\?\C:\Users\adamr\AppData\Local\Temp\cfc6f33f956e4cd18f085cf612e8abd1\out\packed.exe…
[3/4] compressing 815 files and directories…
      successfully compressed 815 files and directories
[4/4] writing startup configuration…
      done!

		Output: C:\Users\adamr\source\repos\PowerShellFormProject1\PowerShellFormProject1\bin\Debug\test.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Can you see if this directory exists and try to run a build there?

cd C:\Users\Victor\AppData\Local\Temp\a81b8a9435d64e5e8285cec872df9486\
dotnet build

It may have been cleaned up and not exist now.

Can you share the package.psd1?

Yes, the temp folder was deleted, however I was able to cancel the script before it gave the error and copied the temporary folder into another location, then ran dotnet build and it worked fine.

I wonder if this folder was obtained before the proper contents are there, so perhaps you can send me a version of the script that does not remove the folder/contents or provide an extensive tracing. I can reproduce the problem anytime.

This is the PSD1

@{
        Root = 'C:\Users\Victor\Source\Repos\ManageSmartkeys\ManageSmartkeys\ManageSmartkeys.ps1' # Root script to package. This is the main entry point for the package.
        OutputPath = 'C:\Users\Victor\Source\Repos\ManageSmartkeys\ManageSmartkeys\Core' # The output directory for the packaging process.
        Package = @{
			OutputName = 'ManageSmartCore'
            Enabled = $true # Whether to package as an executable.
            Obfuscate = $false # Whether to obfuscate the resulting executable.
            HideConsoleWindow = $true # Whether to hide the console window.  Only valid for console applications.
			DotNetVersion = 'net6.0'
			PowerShellVersion = '7.2.0'
			FileVersion = '1.0.0' # The output file version
            FileDescription = 'Application to manage shared Smartkeys' # The output file description
            ProductName = 'ManageSmartkeys' # The output file product name
            ProductVersion = '1.0.0' # The output file product version.
            Copyright = 'PKWtest' # The output file copyright
            RequireElevation = $false # Whether to require elevation when running the executable. Only valid for console applications.
            ApplicationIconPath = 'C:\Users\Victor\Source\Repos\ManageSmartkeys\ManageSmartkeys\PkProtectKeys01.ico' # The path to the application icon to use for the executable.
            PackageType = 'Console' # The type of executable to generate. Valid values are Service or Console.
            ServiceName = "" # The name of the service if the package type is Service.
            ServiceDisplayName = "" # The display name of the service if the package type is Service.
            HighDPISupport = $true  # Whether to enable high DPI support for WinForm applications
            PowerShellArguments = '-NoProfile -ExecutionPolicy Bypass' # Sets the arguments for the PowerShell process that is hosted within the executable. You can use arguments like -NoExit, -ExecutionPolicy and -NoProfile.
            Platform = 'x64' # Sets the architecture of the executable. Can be either 'x86' or 'x64'
        }
        Bundle = @{
            Enabled = $true # Whether to bundle multiple PS1s into a single PS1. Always enabled when Package is enabled.
            Modules = $false # Whether to bundle modules into the package
        }
    }

Adam, I just found out 2021.12.2 was out so I installed it and tried again, however I am getting the exact same result as with the previous version.

This was not patched in that version. I still need to investigate this issue.

I just installed 2021.12.3 and this time it worked fine the merge-script for PWSH 7.2 and NET6.0.

Thanks.