diff --git a/AppHandling/Sort-AppFilesByDependencies.ps1 b/AppHandling/Sort-AppFilesByDependencies.ps1 index f37a6a164..77eaa0be2 100644 --- a/AppHandling/Sort-AppFilesByDependencies.ps1 +++ b/AppHandling/Sort-AppFilesByDependencies.ps1 @@ -48,12 +48,13 @@ try { $appJson = Invoke-ScriptInBcContainer -containerName $containerName -scriptblock { Param($appFile) Get-NavAppInfo -Path $appFile | ConvertTo-Json -Depth 99 } -argumentList (Get-BcContainerPath -containerName $containerName -path $destFile) | ConvertFrom-Json - #Remove-Item -Path $destFile + Remove-Item -Path $destFile + $appJson.Version = "$($appJson.Version.Major).$($appJson.Version.Minor).$($appJson.Version.Build).$($appJson.Version.Revision)" $appJson | Add-Member -NotePropertyName 'Id' -NotePropertyValue $appJson.AppId.Value if ($appJson.Dependencies) { - $appJson.Dependencies | % { if ($_) { + $appJson.Dependencies | ForEach-Object { if ($_) { $_ | Add-Member -NotePropertyName 'Id' -NotePropertyValue $_.AppId - $_ | Add-Member -NotePropertyName 'Version' -NotePropertyValue $_.MinVersion.ToString() + $_ | Add-Member -NotePropertyName 'Version' -NotePropertyValue "$($_.MinVersion.Major).$($_.MinVersion.Minor).$($_.MinVersion.Build).$($_.MinVersion.Revision)" } } } } diff --git a/Common/Invoke-gh.ps1 b/Common/Invoke-gh.ps1 index 07aaa4b71..e0e66593c 100644 --- a/Common/Invoke-gh.ps1 +++ b/Common/Invoke-gh.ps1 @@ -6,6 +6,8 @@ #> function invoke-gh { Param( + [parameter(mandatory = $false, ValueFromPipeline = $true)] + [string] $inputStr = "", [switch] $silent, [switch] $returnValue, [parameter(mandatory = $true, position = 0)][string] $command, @@ -21,7 +23,7 @@ function invoke-gh { $arguments += "$_ " } } - cmdDo -command gh -arguments $arguments -silent:$silent -returnValue:$returnValue + cmdDo -command gh -arguments $arguments -silent:$silent -returnValue:$returnValue -inputStr $inputStr } Export-ModuleMember -Function Invoke-gh diff --git a/Common/Invoke-git.ps1 b/Common/Invoke-git.ps1 index 61dea8fb3..a48b33f97 100644 --- a/Common/Invoke-git.ps1 +++ b/Common/Invoke-git.ps1 @@ -6,6 +6,8 @@ #> function invoke-git { Param( + [parameter(mandatory = $false, ValueFromPipeline = $true)] + [string] $inputStr = "", [switch] $silent, [switch] $returnValue, [parameter(mandatory = $true, position = 0)][string] $command, @@ -21,6 +23,6 @@ function invoke-git { $arguments += "$_ " } } - cmdDo -command git -arguments $arguments -silent:$silent -returnValue:$returnValue + cmdDo -command git -arguments $arguments -silent:$silent -returnValue:$returnValue -inputStr $inputStr } Export-ModuleMember -Function Invoke-git diff --git a/HelperFunctions.ps1 b/HelperFunctions.ps1 index 3f270fa5e..714b51162 100644 --- a/HelperFunctions.ps1 +++ b/HelperFunctions.ps1 @@ -75,7 +75,8 @@ function CmdDo { [string] $command = "", [string] $arguments = "", [switch] $silent, - [switch] $returnValue + [switch] $returnValue, + [string] $inputStr = "" ) $oldNoColor = "$env:NO_COLOR" @@ -88,6 +89,9 @@ function CmdDo { $pinfo.FileName = $command $pinfo.RedirectStandardError = $true $pinfo.RedirectStandardOutput = $true + if ($inputStr) { + $pinfo.RedirectStandardInput = $true + } $pinfo.WorkingDirectory = Get-Location $pinfo.UseShellExecute = $false $pinfo.Arguments = $arguments @@ -96,7 +100,10 @@ function CmdDo { $p = New-Object System.Diagnostics.Process $p.StartInfo = $pinfo $p.Start() | Out-Null - + if ($inputStr) { + $p.StandardInput.WriteLine($inputStr) + $p.StandardInput.Close() + } $outtask = $p.StandardOutput.ReadToEndAsync() $errtask = $p.StandardError.ReadToEndAsync() $p.WaitForExit();