-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using task PowershellTask@2 to invoke a pscore script in a YAML pipeline generates a dotnet error #15175
Comments
Hi @max-zaytsev , thank you for taking a look at this issue. I've also opened up a ticket (2108190040004024) with azure devops support to see if I can get quicker resolution. I've looked at the yaml pipeline definition and my powershell script but couldn't find anything I'm providing that's a -V. [CmdletBinding()]
param(
[Parameter(Mandatory = $true, HelpMessage = 'Powershell repository name to set or register')]
[string] $RepositoryName,
[Parameter(Mandatory = $true, HelpMessage = 'Azure Devops feed URL to use as repository source')]
[string] $RepositorySourceLocation
)
begin {}
process {
try
{
[string] $BuildDefinition = $ENV:BUILD_DEFINITIONNAME
if ([string]::IsNullOrEmpty($ENV:SYSTEM_ACCESSTOKEN))
{
Write-Error "Build pipeline: $BuildDefinition needs to have access to SYSTEM_ACCESSTOKEN environment variable"
}
else
{
$AZDOCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList @('buildagent', (ConvertTo-SecureString -String $ENV:SYSTEM_ACCESSTOKEN -AsPlainText -Force))
}
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -bor [Net.SecurityProtocolType]::Tls13
Write-Host "Searching for repository: $($RepositoryName)"
$PrivateRepository = Get-PSRepository -Name $RepositoryName -ErrorAction SilentlyContinue -Verbose:$false
if ($null -eq $PrivateRepository)
{
$PrivateRepository = Get-PSRepository -Verbose:$false | Where-Object { ($_.SourceLocation -ieq $RepositorySourceLocation) -and ($_.Name -ine $RepositoryName) }
if ($null -ne $PrivateRepository)
{
Write-Host "Unregistering repository $($RepositoryName)"
Unregister-PSRepository -Name $RepositoryName
}
Write-Host "Registering repository $($RepositoryName) name with SourceLocation to $($RepositorySourceLocation)"
Register-PSRepository -Name $RepositoryName -SourceLocation $RepositorySourceLocation -InstallationPolicy Trusted -Credential $AZDOCredential
}
else
{
if (($PrivateRepository.SourceLocation -ine $RepositorySourceLocation) -or ($PrivateRepository.InstallationPolicy -ine 'Trusted'))
{
Write-Host "Updating repository $($RepositoryName) because its InstallationPolicy and SourceLocation do not match expected values"
Set-PSRepository -Name $RepositoryName -InstallationPolicy Trusted -SourceLocation $RepositorySourceLocation -Credential $AZDOCredential
}
else
{
Write-Host "Found repository: $($RepositoryName) and no updates are needed"
}
}
}
catch {
throw $_
}
finally {
Get-Variable -Scope local | Remove-Variable -ErrorAction SilentlyContinue
}
}
end {}
|
Hi @tristanbarcelon It doesn't look like a task issue. Is this reproducible if you run your ps script manually on the same machine? |
my name or user name is not @tristanbarcalon my user is
@***@***.*** ***@***.***> if you make any info out of
I will chk account thx
…On Sun, Sep 19, 2021, 14:20 Maxim Zaytsev ***@***.***> wrote:
Hi @tristanbarcelon <https://github.com/tristanbarcelon> It doesn't look
like a task issue. Is this reproducible if you run your ps script manually
on the same machine?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#15175 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AUFZPOLUWS3ZWS6NWXQ3DJDUCYZXZANCNFSM5COHW4FA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Hi @max-zaytsev, looks like powershell team confirmed this as an issue with PowershellGet so it's not an issue with powershell task. |
Required Information
Entering this information will route you directly to the right team and expedite traction.
Question, Bug, or Feature?
Type: Bug
Enter Task Name: Powershell
list here (V# not needed): 2
Environment
Server - Azure Pipelines
Please reach out to me in private so I can provide account name, team project name, build definition name, and build number.
Agent - Hosted:
I'm using pool with vmImage: 'ubuntu-latest' in yaml pipeline. I've tried using private agents as well and the same error persists .
Issue Description
When calling a powershell script via pwsh, I get an unexpected error about an option: -V which I'm never setting at all in my script or in the YAML task.
Task logs
Please reach out to me privately so I can provide you a zip file of the task logs.
Error logs
##[debug]/usr/bin/pwsh arg: . '/home/vsts/work/_temp/a132de4b-03fd-42f2-bb22-8aecb6d3cd96.ps1'
##[debug]exec tool: /usr/bin/pwsh
##[debug]arguments:
##[debug] -NoLogo
##[debug] -NoProfile
##[debug] -NonInteractive
##[debug] -Command
##[debug] . '/home/vsts/work/_temp/a132de4b-03fd-42f2-bb22-8aecb6d3cd96.ps1'
/usr/bin/pwsh -NoLogo -NoProfile -NonInteractive -Command . '/home/vsts/work/_temp/a132de4b-03fd-42f2-bb22-8aecb6d3cd96.ps1'
Id Name PSJobTypeName State HasMoreData Location
1 94558a0b-00d0-… NotStarted False
Searching for repository: PrivatePSGallery
Registering repository PrivatePSGallery name with SourceLocation to https://pkgs.dev.azure.com/myaccount/_packaging/myfeedname/nuget/v2
Unknown option: -V
The text was updated successfully, but these errors were encountered: