Exception calling "ShouldContinue" with "2" argument(s): "Windows PowerShell is in NonInteractive mode. Read and Prompt functionality is not available." #79
Description
If spent the last few days banging my head against the wall, trying to get Publish-Module
to work from under a TeamCity build. I've installed WMF5, downloaded nuget to C:\ProgramData\Microsoft\Windows\PowerShell\PowerShellGet\NuGet.exe
, but still getting an error:
Exception calling "ShouldContinue" with "2" argument(s): "Windows PowerShell is in NonInteractive mode. Read and Prompt functionality is not available."
I'm using version 1.0.0.1 of PowershellGet and PackageManagement.
[11:37:32] ##Get-Module PowershellGet
[11:37:32]
[11:37:32] ModuleType Version Name ExportedCommands
[11:37:32] ---------- ------- ---- ----------------
[11:37:32] Script 1.0.0.1 PowerShellGet {Find-DscResource, Find-Module, Find-Script, Get-Installed...
[11:37:32] ###Get-Module PackageManagement
[11:37:32] Binary 1.0.0.1 PackageManagement {Find-Package, Find-PackageProvider, Get-Package, Get-Pack...
[11:37:32] ###Get-Command -Name Publish-Module -Module PowerShellGet -Syntax
[11:37:32]
[11:37:32] Publish-Module -Name <string> [-RequiredVersion <version>] [-NuGetApiKey <string>] [-Repository <string>]
[11:37:32] [-FormatVersion <version>] [-ReleaseNotes <string[]>] [-Tags <string[]>] [-LicenseUri <uri>] [-IconUri <uri>]
[11:37:32] [-ProjectUri <uri>] [-WhatIf] [-Confirm] [<CommonParameters>]
[11:37:32]
[11:37:32] Publish-Module -Path <string> [-NuGetApiKey <string>] [-Repository <string>] [-FormatVersion <version>] [-ReleaseNotes
[11:37:32] <string[]>] [-Tags <string[]>] [-LicenseUri <uri>] [-IconUri <uri>] [-ProjectUri <uri>] [-WhatIf] [-Confirm]
[11:37:32] [<CommonParameters>]
Oddly enough, on my local machine, running the same commands gives me version 1.0.0.1 of both packages, but there is an additional -Force
parameter available. No idea why there are different arguments for the same versions. My local machine has PS 5.1, but the build agent has 5.0
Somehow, I managed to get one successful publish out of it, but it didn't work on other build agents. No idea why.
Expected Behavior
I expect it to publish the package. Or, failing that, tell me whats wrong and how to fix it.
If running in non-interactive mode, and nuget is not available, it should fail with a message along the lines of "The nuget package provider is not available. Please run Install-PackageProvider nuget
.".
Once we've figured out why -force
is available on some machines and not on others, the message could possibly be something like "The nuget package provider is not available. Please re-run the command with the -Force
parameter to install the provider automatically, or install it separately via Install-PackageProvider nuget
.".
Current Behavior
It fails with the exception Exception calling "ShouldContinue" with "2" argument(s): "Windows PowerShell is in NonInteractive mode. Read and Prompt functionality is not available."
Possible Solution
Steps to Reproduce (for bugs)
try
{
write-host "###`$PSVersionTable"
$PSVersionTable | Write-Output
write-host "###Get-Module"
Get-Module
write-host "###Get-Module -ListAvailable PowerShellGet,PackageManagement"
Get-Module -ListAvailable PowerShellGet,PackageManagement
write-host "###Get-PackageProvider"
Get-PackageProvider
write-host "###Get-PackageProvider -ListAvailable"
Get-PackageProvider -ListAvailable
$content = (Get-Content OctopusDSC/OctopusDSC.psd1)
$content = $content -replace "ModuleVersion = '[0-9\.]+'", "ModuleVersion = '%build.number%'"
Set-Content OctopusDSC/OctopusDSC.psd1 $content
Write-output "###Get-Content OctopusDSC/OctopusDSC.psd1"
$content
Write-output "###Import Modules"
Import-Module "C:\Program Files\WindowsPowerShell\Modules\PackageManagement"
Import-Module "C:\Program Files\WindowsPowerShell\Modules\PowerShellGet"
Write-output "###Ensuring nuget.exe is available"
If (-not (Test-Path "C:\ProgramData\Microsoft\Windows\PowerShell\PowerShellGet\NuGet.exe")) {
Write-output "Downloading latest nuget to C:\ProgramData\Microsoft\Windows\PowerShell\PowerShellGet\NuGet.exe"
if (-not (Test-Path "C:\ProgramData\Microsoft\Windows\PowerShell\PowerShellGet")) {
New-Item -type Directory "C:\ProgramData\Microsoft\Windows\PowerShell\PowerShellGet" | Out-Null
}
Invoke-WebRequest -Uri "http://go.microsoft.com/fwlink/?LinkID=690216&clcid=0x409" -OutFile "C:\ProgramData\Microsoft\Windows\PowerShell\PowerShellGet\NuGet.exe"
}
Write-output "###Get-Module PowershellGet"
Get-Module PowershellGet
Write-output "###Get-Module PackageManagement"
Get-Module PackageManagement
Write-output "###Get-Command -Name Publish-Module -Module PowerShellGet -Syntax"
Get-Command -Name Publish-Module -Module PowerShellGet -Syntax
Write-output "###Publish-Module -Path 'OctopusDSC'"
Publish-Module -Path "OctopusDSC" -NuGetApiKey "%PSGallery.ApiKey%" -verbose
}
catch
{
write-host $_
exit 1
}
Context
Your Environment
[17:06:24] ###Get-Module
[17:06:24]
[17:06:24] Name : Microsoft.PowerShell.Utility
[17:06:24] Path : C:\windows\system32\windowspowershell\v1.0\Modules\Microsoft.PowerShell.Utility\Microsoft.PowerShel
[17:06:24] l.Utility.psd1
[17:06:24] Description :
[17:06:24] Guid : 1da87e53-152b-403e-98dc-74d7b4d63d59
[17:06:24] Version : 3.1.0.0
[17:06:24] ModuleBase : C:\Windows\SysWOW64\WindowsPowerShell\v1.0
[17:06:24] ModuleType : Manifest
[17:06:24] PrivateData :
[17:06:24] AccessMode : ReadWrite
[17:06:24] ExportedAliases : {[CFS, CFS], [fhx, fhx]}
[17:06:24] ExportedCmdlets : {[Add-Member, Add-Member], [Add-Type, Add-Type], [Clear-Variable, Clear-Variable],
[17:06:24] [Compare-Object, Compare-Object]...}
[17:06:24] ExportedFunctions : {[ConvertFrom-SddlString, ConvertFrom-SddlString], [Format-Hex, Format-Hex], [Get-FileHash,
[17:06:24] Get-FileHash], [Import-PowerShellDataFile, Import-PowerShellDataFile]...}
[17:06:24] ExportedVariables : {}
[17:06:24] NestedModules : {Microsoft.PowerShell.Commands.Utility.dll, Microsoft.PowerShell.Utility}
[17:06:24]
[17:06:24] ###Get-Module -ListAvailable PowerShellGet,PackageManagement
[17:06:25]
[17:06:25] Name : PackageManagement
[17:06:25] Path : C:\Program Files (x86)\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\PackageManagement.psd1
[17:06:25] Description :
[17:06:25] Guid : 4ae9fd46-338a-459c-8186-07f910774cb8
[17:06:25] Version : 1.0.0.1
[17:06:25] ModuleBase : C:\Program Files (x86)\WindowsPowerShell\Modules\PackageManagement\1.0.0.1
[17:06:25] ModuleType : Binary
[17:06:25] PrivateData :
[17:06:25] AccessMode : ReadWrite
[17:06:25] ExportedAliases : {}
[17:06:25] ExportedCmdlets : {[Find-Package, Find-Package], [Get-Package, Get-Package], [Get-PackageProvider,
[17:06:25] Get-PackageProvider], [Get-PackageSource, Get-PackageSource]...}
[17:06:25] ExportedFunctions : {}
[17:06:25] ExportedVariables : {}
[17:06:25] NestedModules : {}
[17:06:25]
[17:06:25]
[17:06:25] Name : PowerShellGet
[17:06:25] Path : C:\Program Files (x86)\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PowerShellGet.psd1
[17:06:25] Description :
[17:06:25] Guid : 1d73a601-4a6c-43c5-ba3f-619b18bbb404
[17:06:25] Version : 1.0.0.1
[17:06:25] ModuleBase : C:\Program Files (x86)\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1
[17:06:25] ModuleType : Script
[17:06:25] PrivateData : {SupportedPowerShellGetFormatVersions, PackageManagementProviders}
[17:06:25] AccessMode : ReadWrite
[17:06:25] ExportedAliases : {[inmo, inmo], [fimo, fimo], [upmo, upmo], [pumo, pumo]}
[17:06:25] ExportedCmdlets : {}
[17:06:25] ExportedFunctions : {[Install-Module, Install-Module], [Find-Module, Find-Module], [Save-Module, Save-Module],
[17:06:25] [Update-Module, Update-Module]...}
[17:06:25] ExportedVariables : {}
[17:06:25] NestedModules : {}
[17:06:25]
[17:06:25] ###Get-PackageProvider
[17:06:46]
[17:06:46] Name : msi
[17:06:46] ProviderName : msi
[17:06:46] Features : {[file-extensions, System.Collections.Generic.List`1[System.String]], [magic-signatures,
[17:06:46] System.Collections.Generic.List`1[System.String]]}
[17:06:46] Version : 3.0.0.0
[17:06:46] ProviderPath : C:\Program Files (x86)\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageM
[17:06:46] anagement.MsiProvider.dll
[17:06:46] SupportedFileExtensions : {msi, msp}
[17:06:46] SupportedUriSchemes : {}
[17:06:46] DynamicOptions : {AdditionalArguments}
[17:06:46]
[17:06:46]
[17:06:46] Name : msu
[17:06:46] ProviderName : msu
[17:06:46] Features : {[file-extensions, System.Collections.Generic.List`1[System.String]], [magic-signatures,
[17:06:46] System.Collections.Generic.List`1[System.String]]}
[17:06:46] Version : 3.0.0.0
[17:06:46] ProviderPath : C:\Program Files (x86)\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageM
[17:06:46] anagement.MsuProvider.dll
[17:06:46] SupportedFileExtensions : {msu}
[17:06:46] SupportedUriSchemes : {}
[17:06:46] DynamicOptions : {}
[17:06:46]
[17:06:46]
[17:06:46] Name : PowerShellGet
[17:06:46] ProviderName : PowerShellGet
[17:06:46] Features : {[supports-powershell-modules, System.Collections.Generic.List`1[System.String]]}
[17:06:46] Version : 1.0.0.1
[17:06:46] ProviderPath : C:\Program Files (x86)\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1
[17:06:46] SupportedFileExtensions : {}
[17:06:46] SupportedUriSchemes : {}
[17:06:46] DynamicOptions : {PackageManagementProvider, Type, Scope, InstallUpdate...}
[17:06:46]
[17:06:46]
[17:06:46] Name : Programs
[17:06:46] ProviderName : Programs
[17:06:46] Features : {}
[17:06:46] Version : 3.0.0.0
[17:06:46] ProviderPath : C:\Program Files (x86)\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageM
[17:06:46] anagement.CoreProviders.dll
[17:06:46] SupportedFileExtensions : {}
[17:06:46] SupportedUriSchemes : {}
[17:06:46] DynamicOptions : {IncludeWindowsInstaller, IncludeSystemComponent}
[17:06:46]
[17:06:46] ###Get-PackageProvider -ListAvailable
[17:06:46]
[17:06:46] Name : msi
[17:06:46] ProviderName : msi
[17:06:46] Features : {[file-extensions, System.Collections.Generic.List`1[System.String]], [magic-signatures,
[17:06:46] System.Collections.Generic.List`1[System.String]]}
[17:06:46] Version : 3.0.0.0
[17:06:46] ProviderPath : C:\Program Files (x86)\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageM
[17:06:46] anagement.MsiProvider.dll
[17:06:46] SupportedFileExtensions : {msi, msp}
[17:06:46] SupportedUriSchemes : {}
[17:06:46] DynamicOptions : {AdditionalArguments}
[17:06:46]
[17:06:46]
[17:06:46] Name : msu
[17:06:46] ProviderName : msu
[17:06:46] Features : {[file-extensions, System.Collections.Generic.List`1[System.String]], [magic-signatures,
[17:06:46] System.Collections.Generic.List`1[System.String]]}
[17:06:46] Version : 3.0.0.0
[17:06:46] ProviderPath : C:\Program Files (x86)\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageM
[17:06:46] anagement.MsuProvider.dll
[17:06:46] SupportedFileExtensions : {msu}
[17:06:46] SupportedUriSchemes : {}
[17:06:46] DynamicOptions : {}
[17:06:46]
[17:06:46]
[17:06:46] Name : PowerShellGet
[17:06:46] ProviderName : PowerShellGet
[17:06:46] Features : {[supports-powershell-modules, System.Collections.Generic.List`1[System.String]]}
[17:06:46] Version : 1.0.0.1
[17:06:46] ProviderPath : C:\Program Files (x86)\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1
[17:06:46] SupportedFileExtensions : {}
[17:06:46] SupportedUriSchemes : {}
[17:06:46] DynamicOptions : {PackageManagementProvider, Type, Scope, InstallUpdate...}
[17:06:46]
[17:06:46]
[17:06:46] Name : Programs
[17:06:46] ProviderName : Programs
[17:06:46] Features : {}
[17:06:46] Version : 3.0.0.0
[17:06:46] ProviderPath : C:\Program Files (x86)\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageM
[17:06:46] anagement.CoreProviders.dll
[17:06:46] SupportedFileExtensions : {}
[17:06:46] SupportedUriSchemes : {}
[17:06:46] DynamicOptions : {IncludeWindowsInstaller, IncludeSystemComponent}