Skip to content
Open
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": "Breaking Change",
"description": "Use AWS.Tools.* Powershell Modules for AWSPowershellModuleScript if available"
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,43 @@ try {

Assert-VstsPath -LiteralPath $tempDirectory -PathType 'Container'

# install the module if not present (we assume if present it is an an autoload-capable
# location)
# Check for modular AWS powershell module first
Write-Host (Get-VstsLocString -Key 'TestingAWSModuleInstalled')
if (!(Get-Module -Name AWSPowerShell -ListAvailable)) {
Write-Host (Get-VstsLocString -Key 'AWSModuleNotFound')

# AllowClobber is not available in Install-Module in the Hosted agent (but is in the
# Hosted 2017 agent). We always install/update the latest NuGet package
# provider to work around Install-Module on the Hosted agent also not having -Force and
# producing the error
#
# 'Exception calling “ShouldContinue” with “2” argument(s): “Windows PowerShell is in NonInteractive mode.'
#
Write-Host (Get-VstsLocString -Key 'InstallingAWSModule')
Install-PackageProvider -Name NuGet -Scope CurrentUser -Verbose -Force
$installModuleCmd = Get-Command Install-Module
if ($installModuleCmd.Parameters.ContainsKey("AllowClobber")) {
Install-Module -Name AWSPowerShell -Scope CurrentUser -Verbose -AllowClobber -Force
if (Get-Module -Name AWS.Tools.Common -ListAvailable) {
Write-Host (Get-VstsLocString -Key 'ModularAWSModuleFound')
if(Get-Module -Name AWS.Tools.SecurityToken -ListAvailable) {
Import-Module -Name AWS.Tools.SecurityToken
}
else {
Install-Module -Name AWSPowerShell -Scope CurrentUser -Verbose -Force
Write-Host (Get-VstsLocString -Key 'SecurityTokenModuleNotFound')
}
}

Import-Module -Name AWSPowerShell
else {
# install the module if not present (we assume if present it is an an autoload-capable
# location)
if (!(Get-Module -Name AWSPowerShell -ListAvailable)) {
Write-Host (Get-VstsLocString -Key 'AWSModuleNotFound')

# AllowClobber is not available in Install-Module in the Hosted agent (but is in the
# Hosted 2017 agent). We always install/update the latest NuGet package
# provider to work around Install-Module on the Hosted agent also not having -Force and
# producing the error
#
# 'Exception calling “ShouldContinue” with “2” argument(s): “Windows PowerShell is in NonInteractive mode.'
#
Write-Host (Get-VstsLocString -Key 'InstallingAWSModule')
Install-PackageProvider -Name NuGet -Scope CurrentUser -Verbose -Force
$installModuleCmd = Get-Command Install-Module
if ($installModuleCmd.Parameters.ContainsKey("AllowClobber")) {
Install-Module -Name AWSPowerShell -Scope CurrentUser -Verbose -AllowClobber -Force
}
else {
Install-Module -Name AWSPowerShell -Scope CurrentUser -Verbose -Force
}
}

Import-Module -Name AWSPowerShell
}

###############################################################################
# If credentials and/or region are not defined on the task we assume them to be
Expand Down
2 changes: 2 additions & 0 deletions src/tasks/AWSPowerShellModuleScript/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@
"messages": {
"GeneratingScript": "Generating script.",
"TestingAWSModuleInstalled": "Checking install status for AWS Tools for Windows PowerShell module.",
"ModularAWSModuleFound": "AWS.Tools.Common found. Assuming all needed AWS.Tools modules are already installed.",
"SecurityTokenModuleNotFound": "AWS.Tools.SecurityToken module not found. You will not be able to use a service connection specifying a role ARN.",
"AWSModuleNotFound": "AWS Tools for Windows PowerShell module not found.",
"InstallingAWSModule": "Installing AWS Tools for Windows PowerShell module to current user scope",
"ConfiguringRegionFromTaskConfiguration": "Region discovered from task configuration",
Expand Down