Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Bug Fix",
"description": "PowerShell: Invalid working directory produces cryptic error message and exits cleanup early."
}
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,20 @@ try {
'CONTINUE' { }
'SILENTLYCONTINUE' { }
default {
Write-Error (Get-VstsLocString -Key 'PS_InvalidErrorActionPreference' -ArgumentList $input_errorActionPreference)
Write-VstsTaskError (Get-VstsLocString -Key 'PS_InvalidErrorActionPreference' -ArgumentList $input_errorActionPreference)
}
}

$input_failOnStderr = Get-VstsInput -Name 'failOnStderr' -AsBool
$input_ignoreLASTEXITCODE = Get-VstsInput -Name 'ignoreLASTEXITCODE' -AsBool
$input_workingDirectory = Get-VstsInput -Name 'workingDirectory' -Require
Assert-VstsPath -LiteralPath $input_workingDirectory -PathType 'Container'
try {
Assert-VstsPath -LiteralPath $input_workingDirectory -PathType 'Container'
}
catch {
Write-VstsTaskError (Get-VstsLocString -Key 'PS_InvalidWorkingDirectory' -ArgumentList $input_workingDirectory)
throw $_
}

$scriptType = Get-VstsInput -Name 'scriptType' -Require
$input_arguments = Get-VstsInput -Name 'arguments'
Expand All @@ -216,11 +222,11 @@ try {
Assert-VstsPath -LiteralPath $input_filePath -PathType Leaf
}
catch {
Write-Error (Get-VstsLocString -Key 'PS_InvalidFilePath' -ArgumentList $input_filePath)
Write-VstsTaskError (Get-VstsLocString -Key 'PS_InvalidFilePath' -ArgumentList $input_filePath)
}

if (!$input_filePath.ToUpperInvariant().EndsWith('.PS1')) {
Write-Error (Get-VstsLocString -Key 'PS_InvalidFilePath' -ArgumentList $input_filePath)
Write-VstsTaskError (Get-VstsLocString -Key 'PS_InvalidFilePath' -ArgumentList $input_filePath)
}
}
else {
Expand Down Expand Up @@ -365,8 +371,12 @@ try {
}
finally {
if ($scriptType -And "$scriptType".ToUpperInvariant() -eq "INLINE") {
Write-Host "Cleaning up temporary script file $input_filePath"
Remove-Item -Path $input_filePath -Force
if ($input_filePath -And (Test-Path -Path $input_filePath)) {
Write-Host "Cleaning up temporary script file $input_filePath"
Remove-Item -Path $input_filePath -Force
} else {
Write-Host "Temporary script file does not exist, nothing to clean: $input_filePath"
}
}

Trace-VstsLeavingInvocation $MyInvocation
Expand Down
1 change: 1 addition & 0 deletions src/tasks/AWSPowerShellModuleScript/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
"PS_FormattedCommand": "Formatted command: {0}",
"PS_InvalidErrorActionPreference": "Invalid ErrorActionPreference '{0}'. The value must be one of: 'Stop', 'Continue', or 'SilentlyContinue'.",
"PS_InvalidFilePath": "Invalid file path '{0}'. A path to a .ps1 file is required.",
"PS_InvalidWorkingDirectory": "Invalid working directory path '{0}'.",
"PS_UnableToDetermineExitCode": "Unexpected exception. Unable to determine the exit code from powershell.",
"ConfiguringProxy": "Configuring proxy for AWSPowerShell module. Host {0}, port {1}",
"ProxyConfigError": "Failed to configure proxy, error {0}",
Expand Down