-
Notifications
You must be signed in to change notification settings - Fork 137
Calling Register-PSRepository or Set-PSRepository triggers the error Unknown Option: -V in Powershell Core running on Ubuntu Linux #661
Comments
Did you try the workaround mentioned in #619 (comment)? |
Hi @SteveL-MSFT , Are you referring to the workaround which used -SkipValidate? I did not try that because that was referring to Register-PackageSource and not Register-PSRepository. In my particular situation, I only needed to ensure that the Azure Devops backed private feed was was present to ensure subsequent steps are able to install/update specific powershell modules from that feed. Is Register-PSRepository invoking dotnet behind the scenes? I'm also not using nuget or dotnet to push or install any nuget package. Do I need to install the nuget credential provider (via https://raw.githubusercontent.com/microsoft/artifacts-credprovider/master/helpers/installcredprovider.sh or https://raw.githubusercontent.com/microsoft/artifacts-credprovider/master/helpers/installcredprovider.ps1) and set the VSS_NUGET_EXTERNAL_FEED_ENDPOINTS env variable for Register-PSRepository or Set-PSRepository to work in addition to providing the Credential parameter? |
Thanks @tristanbarcelon! From what we understand you are trying to use the credential provider and the credential provider for PowerShellGetv2 is a bit finicky and we have not been maintaining it. In PowerShellGetv3 we intent to add persistent credential (WIP PR) support soon so it might be better to wait for that and move to v3. In the meantime, if you want to connect to a private feed, you can do so with the |
Hi @StevenBucher98, we're actually setting the -Credential parameter when calling Register-PSRepository or Set-PSRepository cmdlets in the setprivatepsgallery.ps1 above. I'm just not sure why I get the error below when setting -Verbose parameter to $false within the script and this only happens in pscore and ubuntu 18.04 and 20.04.
I want to explicitly set -Verbose to $false for all built-in PSCore cmdlets we reference in our scripts and utilize Write-Verbose instead of Write-Host in the script/functions we write to minimize the amount of log data to sift through in our pipelines. For example, if we invoke our custom script setprivatepsgallery.ps1 with -Verbose set to $true, we would like to avoid these kinds of messages from Get-PSRepository. Main motivating reason for setprivatepsgallery.ps1 was to decouple our pipeline from psgallery outages. Since Azure Devops nuget feeds does not support upstreaming of powershellgallery.com, we've written a script we run on a schedule that looks at a hashtable of psmodules we utilize and mirrors specific versions in the nuget feed. Version range syntax is similar to that of a nuget package reference. [HashTable] $ModulesToSync = @{
'AzurePipelinesPS' = '(3.0.13,4.0.7]'
'Carbon' = '(2.9.2,2.10.2]'
'dbatools' = '(1.0.101,1.2)'
'MSI' = '3.3.4'
'NameIT' = '(2.1.1,2.3.2]'
'powershell-yaml' = '(0.4.1,0.4.2]'
'PSOneTools' = '[1.0,2.4]'
'RabbitMQTools' = '[1.0,1.5]'
'SqlServer' = '[21.0.17099,21.1.18256]'
'VcRedist' = '(2.0.181,3.0.273]'
'VenafiTppPS' = '(1.2.3,2.2.7]'
'ImportExcel' = '[6.5,7.3]'
'VSSetup' = '[1.0,2.2]'
'PSRabbitMQ' = '[0.3.1,0.3.5]'
'VSTeam' = '(6.4.6,7.5)'
'Az.Accounts' = '2.5.1'
'Az.KeyVault' = '3.4.5'
'Az.ApplicationInsights' = '1.2.0'
'Az.Resources' = '4.2.0'
'AWS.Tools.Common' = '4.1.14'
'AWS.Tools.EC2' = '4.1.14'
'AWS.Tools.ECR' = '4.1.14'
'AWS.Tools.EKS' = '4.1.14'
'AWS.Tools.Route53' = '4.1.14'
'AWS.Tools.S3' = '4.1.14'
'AWS.Tools.Elasticache' = '4.1.14'
'Join-Object' = '2.0.2'
'MicrosoftTeams' = '[2.0.0,2.6.0]'
'NtObjectManager' = '[1.0,1.2.0)'
'Bicep' = '[1.0.0,2.0.0]'
'VenafiPS' = '[3.0,3.1]'
'MarkdownToHtml' = '1.0'
'ComputerManagementDsc' = '[8.0,8.5]'
'ServiceNow' = '[1.8,3.0]'
} |
After taking a closer look at this issue, I think this is a bug originating from here: PowerShellGetv2/src/PowerShellGet/public/psgetfunctions/Get-CredsFromCredentialProvider.ps1 Line 122 in 5aba753
For now I'd suggest not using the -Credential parameter when using Register-PSRepository or Set-PSRepository. Again, we're working on improving this scenario in PowerShellGet v3 so that it's smoother and more streamlined. Please follow us there for our upcoming releases so you can grab the credential persistence changes when they get pushed there. Also let us know if you're running into any other issues with this particular scenario. |
Hi @alerickson, I have pscore 7.1.4 on Windows and Ubuntu and could not find Install-Resource cmdlet/function. Which module contains Install-Resource? Update: @alerickson After a little bit more digging, I found this stackoverflow article. Did you want me to use Get-PackageSource, Register-PackageSource, Unregister-PackageSource, Install-Package cmdlets from PackageManagement in lieu of Get-PSRepository, Register-PSRepository, Unregister-PSRepository, Install-Module functions from PowershellGet and that would fix the After using Register-PackageSource to add the azure devops feed, I can't seem to remove it anymore in Windows using Unregister-PackageSource. Is this information being stored in a file or registry key for me to remove manually? It also seems to me that using Register-PSRepository creates/updates a $ENV:APPData\Nuget\nuget.config file similar to what nuget.exe and dotnet nuget would have done. Furthermore, Register-PSRepository/Unregister-PSRepository also adds/removes an entry to the same store used by PackageManagement except that it has a ProviderName of PowershellGet. |
Hi @tristanbarcelon, Please give this a try and let us know if that resolves your issue. |
Prerequisites
Steps to reproduce
Somebody also mentioned in a PowershellGetV2 issue that they also see the "Unknown option: -V" error.
Azure Devops team is also able to repro the error on hosted agents and I'm able to repro it on my private Azure devops agents. I filed an Azure Devops issue initially, thinking this was a problem with the PowershellV2 task. I have also confirmed that pwsh is not installed as a dotnet global tool. pwsh was installed on private Azure Devops agents via apt package manager
For a mininum repro, reduce the script down to just this and execute in Ubuntu 18.04.5 or 20.04.*, just as long as myorg and myfeed are replaced with a valid Azure Devops nuget v2 feed and a valid Azure Devops personal access token with scope to read the nuget feed.
Expected behavior
I expect it to create or update a repository named PrivatePSGallery on Ubuntu machines 18.04.* or 20.04.* using Powershell Core 7.1.x, 7.0.x releases.
Actual behavior
Error details
Environment data
Visuals
No response
The text was updated successfully, but these errors were encountered: