diff --git a/PSFramework/PSFramework.psd1 b/PSFramework/PSFramework.psd1 index c2fad0e..5dc863e 100644 --- a/PSFramework/PSFramework.psd1 +++ b/PSFramework/PSFramework.psd1 @@ -4,7 +4,7 @@ RootModule = 'PSFramework.psm1' # Version number of this module. - ModuleVersion = '1.13.414' + ModuleVersion = '1.13.416' # ID used to uniquely identify this module GUID = '8028b914-132b-431f-baa9-94a6952f21ff' diff --git a/PSFramework/bin/PSFramework.dll b/PSFramework/bin/PSFramework.dll index a8fe0c6..746d783 100644 Binary files a/PSFramework/bin/PSFramework.dll and b/PSFramework/bin/PSFramework.dll differ diff --git a/PSFramework/bin/PSFramework.pdb b/PSFramework/bin/PSFramework.pdb index 6bbb17b..a32d55e 100644 Binary files a/PSFramework/bin/PSFramework.pdb and b/PSFramework/bin/PSFramework.pdb differ diff --git a/PSFramework/changelog.md b/PSFramework/changelog.md index 13c5a70..cc1e7e4 100644 --- a/PSFramework/changelog.md +++ b/PSFramework/changelog.md @@ -1,5 +1,10 @@ # CHANGELOG +## 1.13.416 (2025-10-22) + +- Fix: Invoke-PSFRunspace - errors incorrectly show PSFramework error, rather than actual errors. +- Fix: Invoke-PSFRunspace - variables are not created correctly in the background runspace + ## 1.13.414 (2025-10-14) - Upd: Wait-PSFRunspaceWorkflow - adding ProgressBar with `-ShowProgress` (#698 | @fslef) diff --git a/build/vsts-build.ps1 b/build/vsts-build.ps1 index b8af0a2..921874c 100644 --- a/build/vsts-build.ps1 +++ b/build/vsts-build.ps1 @@ -46,6 +46,9 @@ if ($Build) { # Prepare publish folder Write-Host "Creating and populating publishing directory" +if (Test-Path -Path (Join-Path -Path $WorkingDirectory -ChildPath 'publish')) { + Remove-Item -Path (Join-Path -Path $WorkingDirectory -ChildPath 'publish') -Recurse -Force +} $publishDir = New-Item -Path $WorkingDirectory -Name publish -ItemType Directory -Force Copy-Item -Path "$($WorkingDirectory)\PSFramework" -Destination $publishDir.FullName -Recurse -Force diff --git a/library/PSFramework/Runspace/RunspaceResult.cs b/library/PSFramework/Runspace/RunspaceResult.cs index db8a3fc..6be0681 100644 --- a/library/PSFramework/Runspace/RunspaceResult.cs +++ b/library/PSFramework/Runspace/RunspaceResult.cs @@ -1,4 +1,5 @@ -using System; +using PSFramework.Logging; +using System; using System.Collections.Generic; using System.Linq; using System.Management.Automation; @@ -54,7 +55,13 @@ public RunspaceResult(object InputObject, PSDataCollection Output, PSD if (Streams.Warning.Count > 0) Warnings.AddRange(Streams.Warning); if (Streams.Error.Count > 0) - Errors.AddRange(Streams.Error); + { + foreach (ErrorRecord record in Streams.Error) + { + try { Errors.Add(((RuntimeException)record.Exception.InnerException).ErrorRecord); } + catch { Errors.Add(record); } + } + } #if PS4 #else if (Streams.Information.Count > 0) diff --git a/library/PSFramework/Runspace/RunspaceTask.cs b/library/PSFramework/Runspace/RunspaceTask.cs index db29911..ce24fcd 100644 --- a/library/PSFramework/Runspace/RunspaceTask.cs +++ b/library/PSFramework/Runspace/RunspaceTask.cs @@ -88,7 +88,10 @@ public bool TryCollect(Cmdlet Command, bool NoStreams = false) try { foreach (ErrorRecord error in Runtime.Streams.Error) - Command.WriteError(error); + { + try { Command.WriteError(((RuntimeException)error.Exception.InnerException).ErrorRecord); } + catch { Command.WriteError(error); } + } } finally { @@ -166,7 +169,10 @@ public void Collect(Cmdlet Command, bool NoStreams = false) try { foreach (ErrorRecord error in Runtime.Streams.Error) - Command.WriteError(error); + { + try { Command.WriteError(((RuntimeException)error.Exception.InnerException).ErrorRecord); } + catch { Command.WriteError(error); } + } } finally { diff --git a/library/PSFramework/Runspace/RunspaceWrapper.cs b/library/PSFramework/Runspace/RunspaceWrapper.cs index e9e9216..b2c2701 100644 --- a/library/PSFramework/Runspace/RunspaceWrapper.cs +++ b/library/PSFramework/Runspace/RunspaceWrapper.cs @@ -96,7 +96,7 @@ public void AddVariable(string Name, object Value) /// Name/value map of variables to inclue public void AddVariable(Hashtable VariableHash) { - foreach (object key in VariableHash) + foreach (object key in VariableHash.Keys) Variables[key.ToString()] = new SessionStateVariableEntry(key.ToString(), VariableHash[key], ""); }