diff --git a/changelogs/fragments/588-nuget-requirement-patch.yaml b/changelogs/fragments/588-nuget-requirement-patch.yaml new file mode 100644 index 00000000..73fe362d --- /dev/null +++ b/changelogs/fragments/588-nuget-requirement-patch.yaml @@ -0,0 +1,5 @@ +--- +minor_changes: + - This issue fixes installation of requirements as it requires a confirmation when installed as a depedency to PowershellGet. + Installing it by itself prevents this confirmation dialog and allows required components to be installed + (https://github.com/ansible-collections/community.windows/issues/147). diff --git a/plugins/modules/win_psmodule.ps1 b/plugins/modules/win_psmodule.ps1 index 78851914..4579f03a 100644 --- a/plugins/modules/win_psmodule.ps1 +++ b/plugins/modules/win_psmodule.ps1 @@ -101,6 +101,10 @@ Function Install-PrereqModule { $job = Start-Job -ScriptBlock { $ErrorActionPreference = 'Stop' + if (-not (Get-PackageProvider -ListAvailable | Where-Object { ($_.name -eq 'Nuget') -and ($_.version -ge "2.8.5.201") }) ) { + Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force | Out-Null + } + $Repository = $using:Repository foreach ($info in $using:ToInstall) {