Title: Error in Azure Pipeline when Get-ProjectName returns multiple items · Issue #134 · PowerShellOrg/BuildHelpers · GitHub
Open Graph Title: Error in Azure Pipeline when Get-ProjectName returns multiple items · Issue #134 · PowerShellOrg/BuildHelpers
X Title: Error in Azure Pipeline when Get-ProjectName returns multiple items · Issue #134 · PowerShellOrg/BuildHelpers
Description: 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....
Open Graph Description: 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...
X Description: We're getting an error "Cannot process argument transformation on parameter 'Value'. Cannot convert value to type System.String." when Set-BuildEnvironment calls Set-AzurePipe...
Opengraph URL: https://github.com/PowerShellOrg/BuildHelpers/issues/134
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Error in Azure Pipeline when Get-ProjectName returns multiple items","articleBody":"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.\r\n\r\nQuick fix: since `Set-AzurePipelinesVariable` requires a string, you should cast the value explicitly:\r\n\r\nhttps://github.com/RamblingCookieMonster/BuildHelpers/blob/5b712c4777f258b987672658af71488caa5f9ccc/BuildHelpers/Public/Set-BuildEnvironment.ps1#L126\r\n\r\nNeeds to be:\r\n\r\n```PowerShell\r\nSet-AzurePipelinesVariable -Name $prefixedVar -Value \"$($BuildHelpersVariables[$VarName])\"\r\n```\r\n\r\nor:\r\n\r\n```PowerShell\r\nSet-AzurePipelinesVariable -Name $prefixedVar -Value ([string]$BuildHelpersVariables[$VarName])\r\n```\r\n\r\n----\r\n\r\nRoot 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.\r\n```PowerShell\r\n #PSD1 in root of project but name doesn't match\r\n #very ick or just an icky time in Azure Pipelines\r\n elseif ( $PSDs = Get-ChildItem -Path $Path \"*.psd1\" )\r\n {\r\n if ($PSDs.count -gt 1) {\r\n Write-Warning \"Found more than one project manifest in the root folder\"\r\n }\r\n $result = $PSDs.BaseName\r\n }\r\n```\r\n\r\nUntil 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. \r\n\r\nNow, 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.\r\n\r\nMy 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).\r\n\r\n\r\n\r\n```log\r\n ErrorRecord : \r\n Exception : \r\n Type : System.Management.Automation.ParentContainsErrorRecordException\r\n Message : Cannot process argument transformation on parameter 'Value'. Cannot convert value to type System.String.\r\n HResult : -2146233087\r\n CategoryInfo : InvalidData: (:) [Set-AzurePipelinesVariable], ParentContainsErrorRecordException\r\n FullyQualifiedErrorId : ParameterArgumentTransformationError,Set-AzurePipelinesVariable\r\n InvocationInfo : \r\n MyCommand : Set-AzurePipelinesVariable\r\n ScriptLineNumber : 126\r\n OffsetInLine : 70\r\n HistoryId : 1\r\n ScriptName : C:\\Program Files\\WindowsPowerShell\\Modules\\BuildHelpers\\2.0.16\\Public\\Set-BuildEnvironment.ps1\r\n Line : Set-AzurePipelinesVariable -Name $prefixedVar -Value $BuildHelpersVariables[$VarName]\r\n PositionMessage : At C:\\Program Files\\WindowsPowerShell\\Modules\\BuildHelpers\\2.0.16\\Public\\Set-BuildEnvironment.ps1:126 char:70\r\n + … esVariable -Name $prefixedVar -Value $BuildHelpersVariables[$VarName]\r\n + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n PSScriptRoot : C:\\Program Files\\WindowsPowerShell\\Modules\\BuildHelpers\\2.0.16\\Public\r\n PSCommandPath : C:\\Program Files\\WindowsPowerShell\\Modules\\BuildHelpers\\2.0.16\\Public\\Set-BuildEnvironment.ps1\r\n CommandOrigin : Internal\r\n ScriptStackTrace : at Set-BuildEnvironment, C:\\Program Files\\WindowsPowerShell\\Modules\\BuildHelpers\\2.0.16\\Public\\Set-BuildEnvironment.ps1: line 126\r\n at \u003cScriptBlock>, D:\\Agents\\Agent1\\_work\\17\\s\\InvokeBuildTasks\\Initialize.ps1: line 4\r\n at \u003cScriptBlock>, D:\\Agents\\Agent1\\_work\\17\\s\\SharedInfrastructureModules\\Bicep.build.ps1: line 22\r\n at \u003cScriptBlock>\u003cEnd>, C:\\Program Files\\WindowsPowerShell\\Modules\\InvokeBuild\\5.8.0\\Invoke-Build.ps1: line 655\r\n at \u003cScriptBlock>, D:\\Agents\\Agent1\\_work\\17\\s\\SharedInfrastructureModules\\init.ps1: line 24\r\n at \u003cScriptBlock>, D:\\Agents\\Agent1\\_work\\_temp\\59cf28f5-e8a3-41af-b6d3-6b2866b97e99.ps1: line 3\r\n at \u003cScriptBlock>, \u003cNo file>: line 1\r\n\r\n```","author":{"url":"https://github.com/Jaykul","@type":"Person","name":"Jaykul"},"datePublished":"2022-09-14T14:26:11Z","url":"https://github.com/PowerShellOrg/BuildHelpers/issues/134"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2c148aea-fd84-fe88-b7bf-6172697261ea |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DE72:2CE323:D60E74:1251B17:6AFD384F |
| html-safe-nonce | a7075adcfa0aa326a9812084b7b9bcaa9dbc4aade76e2788ba558744310a9519 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERTcyOjJDRTMyMzpENjBFNzQ6MTI1MUIxNzo2QUZEMzg0RiIsInZpc2l0b3JfaWQiOiIyOTkwODYxMzU5NTI2MDAwNzE5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | ccbe5886c74e5b44aac83f14a4505adb59a1a8893fca0c78fc1d5ae7cb405da2 |
| hovercard-subject-tag | issue:1373081925 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShellOrg/BuildHelpers/134/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f48c2bda250d3064231c470dd807bcac8e956838210ae9476b069dd571d5a2d2/PowerShellOrg/BuildHelpers/issues/134 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f48c2bda250d3064231c470dd807bcac8e956838210ae9476b069dd571d5a2d2/PowerShellOrg/BuildHelpers/issues/134 |
| og:image:alt | 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... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Jaykul |
| hostname | github.com |
| expected-hostname | github.com |
| None | 065128366c233a9d57ff68ab6c96e25b99dd1b0ab70d23b70873d3dd6b5e4f19 |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShellOrg/BuildHelpers git https://github.com/PowerShellOrg/BuildHelpers.git |
| octolytics-dimension-user_id | 4895314 |
| octolytics-dimension-user_login | PowerShellOrg |
| octolytics-dimension-repository_id | 59748913 |
| octolytics-dimension-repository_nwo | PowerShellOrg/BuildHelpers |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 59748913 |
| octolytics-dimension-repository_network_root_nwo | PowerShellOrg/BuildHelpers |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 941021edf0c2ec58298f4a2c8f27ae507d129c92 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width