You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're getting an error "Cannot process argument transformation on parameter 'Value'. Cannot convert value to type System.String." when Set-BuildEnvironment calls Set-AzurePipelinesVariable with the value of ProjectName which is an array.
Quick fix: since Set-AzurePipelinesVariable requires a string, you should cast the value explicitly:
Root cause: we've been using BuildHelpers for a long time with no problems -- even on non-module projects. Today we upgraded from 2.0.3 to 2.0.16 and this new discovery case in Get-ProjectName caused the problem.
#PSD1 in root of project but name doesn't match#very ick or just an icky time in Azure Pipelineselseif ( $PSDs=Get-ChildItem-Path $Path"*.psd1" )
{
if ($PSDs.count-gt1) {
Write-Warning"Found more than one project manifest in the root folder"
}
$result=$PSDs.BaseName
}
Until now, we've been falling through to the default $result = Split-Path $Path -Leaf value, which was fine, because we're in a multi-checkout project, so our folder is named with the project name.
Now, our ScriptAnalyzerSettings.psd1 and our RequiredModules.psd1 and a couple of other similar configuration files are being treated as the project name(s) -- resulting in multiple items being returned, all of which are wrong -- and this error when the call to Set-AzurePipelinesVariable assumes a string result.
My recommendation is to fix the call to Set-AzurePipelinesVariable as I suggested above, but also to consider that if you found multiple results from looking at psd1 files, they are definitely not the right value and you should keep looking (and fall through to the folder name).
ErrorRecord :
Exception :
Type : System.Management.Automation.ParentContainsErrorRecordException
Message : Cannot process argument transformation on parameter 'Value'. Cannot convert value to type System.String.
HResult : -2146233087
CategoryInfo : InvalidData: (:) [Set-AzurePipelinesVariable], ParentContainsErrorRecordException
FullyQualifiedErrorId : ParameterArgumentTransformationError,Set-AzurePipelinesVariable
InvocationInfo :
MyCommand : Set-AzurePipelinesVariable
ScriptLineNumber : 126
OffsetInLine : 70
HistoryId : 1
ScriptName : C:\Program Files\WindowsPowerShell\Modules\BuildHelpers\2.0.16\Public\Set-BuildEnvironment.ps1
Line : Set-AzurePipelinesVariable -Name $prefixedVar -Value $BuildHelpersVariables[$VarName]
PositionMessage : At C:\Program Files\WindowsPowerShell\Modules\BuildHelpers\2.0.16\Public\Set-BuildEnvironment.ps1:126 char:70
+ … esVariable -Name $prefixedVar -Value $BuildHelpersVariables[$VarName]
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PSScriptRoot : C:\Program Files\WindowsPowerShell\Modules\BuildHelpers\2.0.16\Public
PSCommandPath : C:\Program Files\WindowsPowerShell\Modules\BuildHelpers\2.0.16\Public\Set-BuildEnvironment.ps1
CommandOrigin : Internal
ScriptStackTrace : at Set-BuildEnvironment, C:\Program Files\WindowsPowerShell\Modules\BuildHelpers\2.0.16\Public\Set-BuildEnvironment.ps1: line 126
at <ScriptBlock>, D:\Agents\Agent1\_work\17\s\InvokeBuildTasks\Initialize.ps1: line 4
at <ScriptBlock>, D:\Agents\Agent1\_work\17\s\SharedInfrastructureModules\Bicep.build.ps1: line 22
at <ScriptBlock><End>, C:\Program Files\WindowsPowerShell\Modules\InvokeBuild\5.8.0\Invoke-Build.ps1: line 655
at <ScriptBlock>, D:\Agents\Agent1\_work\17\s\SharedInfrastructureModules\init.ps1: line 24
at <ScriptBlock>, D:\Agents\Agent1\_work\_temp\59cf28f5-e8a3-41af-b6d3-6b2866b97e99.ps1: line 3
at <ScriptBlock>, <No file>: line 1
The text was updated successfully, but these errors were encountered:
We're getting an error "Cannot process argument transformation on parameter 'Value'. Cannot convert value to type System.String." when
Set-BuildEnvironment
callsSet-AzurePipelinesVariable
with the value of ProjectName which is an array.Quick fix: since
Set-AzurePipelinesVariable
requires a string, you should cast the value explicitly:BuildHelpers/BuildHelpers/Public/Set-BuildEnvironment.ps1
Line 126 in 5b712c4
Needs to be:
or:
Root cause: we've been using BuildHelpers for a long time with no problems -- even on non-module projects. Today we upgraded from 2.0.3 to 2.0.16 and this new discovery case in
Get-ProjectName
caused the problem.Until now, we've been falling through to the default
$result = Split-Path $Path -Leaf
value, which was fine, because we're in a multi-checkout project, so our folder is named with the project name.Now, our
ScriptAnalyzerSettings.psd1
and ourRequiredModules.psd1
and a couple of other similar configuration files are being treated as the project name(s) -- resulting in multiple items being returned, all of which are wrong -- and this error when the call to Set-AzurePipelinesVariable assumes a string result.My recommendation is to fix the call to Set-AzurePipelinesVariable as I suggested above, but also to consider that if you found multiple results from looking at psd1 files, they are definitely not the right value and you should keep looking (and fall through to the folder name).
The text was updated successfully, but these errors were encountered: