PowershellFrameworkCollective / PSModuleDevelopment

Provides tools that help with module development
MIT License
122 stars 24 forks source link

Error during Invoke-PSMDTemplate on Linux related to BinaryFormatter #202

Open nyanhp opened 4 months ago

nyanhp commented 4 months ago

On Linux (Ubuntu 24.04 WSL to be precise), Invoke-PSMDTemplate fails continuously with the following warning:

WARNING: [13:53:34][Invoke-PSMDTemplate] Failed to: Creating file/project from template MiniModule 1.0.0.0 | Cannot process argument transformation on parameter 'Template'. Cannot convert value "MiniModule 1.0.0.0" to type "PSModuleDevelopment.Template.TemplateInfo". Error: "BinaryFormatter serialization and deserialization are disabled within this application. See https://aka.ms/binaryformatter for more information."

PowerShell Version: 7.4.2 Module Versions:

Name                            Version
----                            -------
PSFramework                     1.10.318
PSModuleDevelopment             2.2.11.168
string                          1.1.5

The entire error output looks thusly:

PSMessageDetails      : 
Exception             : System.Management.Automation.ParameterBindingArgumentTransformationException: Cannot process argument transformation on parameter 'Template'. Cannot convert
                         value "AzureFunction 2.0.5" to type "PSModuleDevelopment.Template.TemplateInfo". Error: "BinaryFormatter serialization and deserialization are disabled wit
                        hin this application. See https://aka.ms/binaryformatter for more information."
                         ---> System.Management.Automation.ArgumentTransformationMetadataException: Cannot convert value "AzureFunction 2.0.5" to type "PSModuleDevelopment.Template
                        .TemplateInfo". Error: "BinaryFormatter serialization and deserialization are disabled within this application. See https://aka.ms/binaryformatter for more 
                        information."
                         ---> System.Management.Automation.PSInvalidCastException: Cannot convert value "AzureFunction 2.0.5" to type "PSModuleDevelopment.Template.TemplateInfo". E
                        rror: "BinaryFormatter serialization and deserialization are disabled within this application. See https://aka.ms/binaryformatter for more information."
                         ---> System.NotSupportedException: BinaryFormatter serialization and deserialization are disabled within this application. See https://aka.ms/binaryformatt
                        er for more information.
                           at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)
                           at PSFramework.Serialization.SerializationTypeConverter.DeserializeObject(Object sourceValue, Type destinationType)
                           at System.Management.Automation.LanguagePrimitives.IsCustomTypeConversion(Object valueToConvert, Type resultType, IFormatProvider formatProvider, Object&
                         result, TypeTable backupTypeTable)
                           --- End of inner exception stack trace ---
                           at System.Management.Automation.LanguagePrimitives.IsCustomTypeConversion(Object valueToConvert, Type resultType, IFormatProvider formatProvider, Object&
                         result, TypeTable backupTypeTable)
                           at System.Management.Automation.LanguagePrimitives.ConvertCheckingForCustomConverter.Convert(Object valueToConvert, Type resultType, Boolean recursion, P
                        SObject originalValueToConvert, IFormatProvider formatProvider, TypeTable backupTable)
                           at System.Management.Automation.LanguagePrimitives.ConvertTo(Object valueToConvert, Type resultType, Boolean recursion, IFormatProvider formatProvider, T
                        ypeTable backupTypeTable)
                           at System.Management.Automation.ArgumentTypeConverterAttribute.Transform(EngineIntrinsics engineIntrinsics, Object inputData, Boolean bindingParameters, 
                        Boolean bindingScriptCmdlet)
                           --- End of inner exception stack trace ---
                           at System.Management.Automation.ArgumentTypeConverterAttribute.Transform(EngineIntrinsics engineIntrinsics, Object inputData, Boolean bindingParameters, 
                        Boolean bindingScriptCmdlet)
                           at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, Paramet
                        erBindingFlags flags)
                           --- End of inner exception stack trace ---
                           at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
                           at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
                           at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
                           at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
                           at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
                           at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
                           at System.Management.Automation.ScriptBlock.InvokeWithPipeImpl(ScriptBlockClauseToInvoke clauseToInvoke, Boolean createLocalScope, Dictionary`2 functions
                        ToDefine, List`1 variablesToDefine, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, Invoc
                        ationInfo invocationInfo, Object[] args)
                           at System.Management.Automation.ScriptBlock.InvokeWithPipe(Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object
                         input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Boolean propagateAllExceptionsToTop, List`1 variablesToDefine, Dictionary`2 funct
                        ionsToDefine, Object[] args)
                           at System.Management.Automation.CommandInvocationIntrinsics.InvokeScript(ScriptBlock sb, Boolean useNewScope, PipelineResultTypes writeToPipeline, IList 
                        input, Object[] args)
                           at System.Management.Automation.CommandInvocationIntrinsics.InvokeScript(Boolean useLocalScope, ScriptBlock scriptBlock, IList input, Object[] args)
                           at PSFramework.Commands.InvokePSFProtectedCommand.ProcessRecord()
TargetObject          : 
CategoryInfo          : InvalidData: (:) [Invoke-Template], ParameterBindingArgumentTransformationException
FullyQualifiedErrorId : ParameterArgumentTransformationError,Invoke-Template
ErrorDetails          : 
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at <ScriptBlock>, /home/jhp/.local/share/powershell/Modules/PSModuleDevelopment/2.2.11.168/PSModuleDevelopment.psm1: line 5630
                        at Invoke-PSMDTemplate<Process>, /home/jhp/.local/share/powershell/Modules/PSModuleDevelopment/2.2.11.168/PSModuleDevelopment.psm1: line 5629
                        at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}

I'll try to see if I can track down where it happens. If I do find out before you see this issue, I'll of course send a PR ;)

salty2011 commented 1 month ago

Hey @nyanhp

Were you able to track down this issue? I am able to replicate the problem on Windows as well when using Powershell 7.4.2 and Powershell 7.5 preview 4

nyanhp commented 1 month ago

Not yet, my day-job got the better of me. Since I don't create modules very often, it got deprioritized.

FriedrichWeinmann commented 1 month ago

Alright, sorry about the late reaction to this :( The problem has been solved in the backend - this was related to the security update in the latest PSFramework version - and I need to release a new version of PSModuleDevelopment now to make the whole thing work again. But I know where I broke things, soooo ... somewhen later today?

FriedrichWeinmann commented 1 month ago

Alright, once again some unintended delays, but ... version 2.2.12.171 is now out and should fix that

FriedrichWeinmann commented 1 month ago

And with 2.2.12.172, it will even do so on PS5.1 ^^