We encountered a scenario where scripts will fail when run under TeamCity because its cake/powershell runner does not have a console. In other words, Powershell will try to retrieve info from System.Console, but there is no window handle so an exception is thrown:
---> System.IO.IOException: The handle is invalid.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.Console.GetBufferInfo(Boolean throwOnNoConsole, Boolean& succeeded)
at Cake.Powershell.CakePSHostRawUserInterface.get_BufferSize()
at System.Management.Automation.Internal.Host.InternalHostRawUserInterface.get_BufferSize()
at Microsoft.PowerShell.Commands.OutStringCommand.InstantiateLineOutputInterface()
at Microsoft.PowerShell.Commands.OutStringCommand.BeginProcessing()
at System.Management.Automation.Cmdlet.DoBeginProcessing()
at System.Management.Automation.CommandProcessorBase.DoBegin()
--- End of inner exception stack trace ---
at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
at Cake.Powershell.PowershellRunner.Invoke(String script, PowershellSettings settings)
at Submission#0.StartPowershellFile(FilePath path, PowershellSettings settings)
at Submission#0.ExecutePowershellScriptFile(String scriptFileName, IList`1 arguments)
Admittedly, I don't know much about Managed Powershell; although this workaround fixed our issue, any suggestions for a cleaner solution are welcome.
@SharpeRAD, sorry it's me again.
We encountered a scenario where scripts will fail when run under TeamCity because its cake/powershell runner does not have a console. In other words, Powershell will try to retrieve info from System.Console, but there is no window handle so an exception is thrown:
Admittedly, I don't know much about Managed Powershell; although this workaround fixed our issue, any suggestions for a cleaner solution are welcome.