0

After updating QueryAzureDevOpsExtensionVersion@3 to version 4 and the same for PackageAzureDevOpsExtension, I started getting errors in PackageAzureDevOpsExtension.

All errors looked something like that:

error: Error: Part Name 'Myproject/node_modules/azure-pipelines-tasks-azure-arm-rest-v2/openssl/OpenSSL License.txt' is invalid. Please check the following:  0 [
  "error: Error: Part Name 'Myproject/node_modules/azure-pipelines-tasks-azure-arm-rest-v2/openssl/OpenSSL License.txt' is invalid. Please check the following: ",
  'error: 1. No whitespace or any of these characters: #^[]<>?',
  'error: 2. Cannot end with a period.',
  'error: 3. No percent-encoded / or \\ characters. Additionally, % must be followed by two hex characters.',
  ''

That part of the pipeline now looks like this:

 - task: QueryAzureDevOpsExtensionVersion@4
                name: QueryVersion
                displayName: 'Query Extension Version'
                inputs:
                  connectTo: 'VsTeam'
                  connectedServiceName: 'Clipper-Marketplace-Admin'
                  publisherId: '$(publisherId)'
                  extensionId: '$(extensionId)'
                  versionAction: ${{ parameters.updateKind }}                     
                    
 - task: PackageAzureDevOpsExtension@4
   inputs:
                  rootFolder: '$(Build.SourcesDirectory)/AzurePipelinesTasks'
                  patternManifest: 'my-project-vss-extension.json'
                  publisherId: '$(publisherId)'
                  extensionId: '$(extensionId)'
                  extensionName: '$(extensionName)'
                  extensionVersion: '$(QueryVersion.Extension.Version)'
                  updateTasksVersion: true
                  updateTasksVersionType: ${{ parameters.updateKind }}
                  extensionVisibility: 'private' # Change to public if you're publishing to the marketplace
                  extensionPricing: 'free'

What can cause these errors in the pipeline? The reason why I'm updating the pipeline is because there's some issue with the latest typescript version which causes an issue with compiling the code. After updating packages, I started failing in the package stage because of errors like the above.

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
CodeMonkey
  • 11,196
  • 30
  • 112
  • 203
  • The question about referencing the variable in a different stage, see the Q you tagged me in. Set the dependencies between the 2 jobs and use the following syntax: `dependencies.JobA.outputs['Query.Extension.Version']`. See also: https://stackoverflow.com/a/73609482/736079 – jessehouwing Dec 05 '22 at 13:59
  • @jessehouwing I did reference the output in version 3 when there was an output variable with a name I can output and then I used a script to set it in a var like you showed me.. now with version 4 there is no output field like in version 3? – CodeMonkey Dec 05 '22 at 14:09
  • It just uses a default output parameter. No need to specify the name anymore. It's auto named `{name of the task}.Extension.Version`. Across stages prepend `dependencies.{jobname}.` and set the dependencies of the jobs correctly. – jessehouwing Dec 05 '22 at 14:16
  • Removed the bits about passing the version across stages, since that's a separate question. Can you either log a new question , if you still have that issue? – jessehouwing Dec 05 '22 at 14:34

1 Answers1

0

It looks like azure-pipelines-tasks-azure-arm-rest-v2 was updated to v3 in the past week. I just compared @^2 with @^3 and it indeed now includes a file with spaces in the name:

\node_modules\azure-pipelines-tasks-azure-arm-rest-v2\openssl

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---          05/12/2022    15:27           2318 HashInfo.txt
-a---          05/12/2022    15:27        2267136 libeay32.dll
-a---          05/12/2022    15:27           6404 OpenSSL License.txt
-a---          05/12/2022    15:27         548352 openssl.exe
-a---          05/12/2022    15:27           2722 ReadMe.txt
-a---          05/12/2022    15:27         385536 ssleay32.dll

I've personally solved that in 2 ways in the past.

  1. Delete the offending files
  2. Rename the offending file, replacing with _.

You have a 3rd option:

  1. Downgrade to azure-pipelines-tasks-azure-arm-rest-v2@^2

I don't know what the limitation is in this case, I've just worked around it so far. Recommend commenting on the bug in the tfx repo.

Until then, add a pwsh script prior to running package or publish to remove the spaces:

dir -recurse | where {-Not $_.PsIscontainer -AND $_.name -match " "} | foreach { 
    $New=$_.name.Replace(" ","_")
    Rename-Item -path $_.Fullname -newname $New -passthru
}   

You can also comment on the bug with the repo that hosts azure-pipelines-tasks-azure-arm-rest-v2.

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
  • but this file is not something I added myself.. its from another package which is not mine and I have no control over. How can I tell it in tfxinstaller@4 to take the tfx I had (version 12)? Now I pass the version like this: "0.x" – CodeMonkey Dec 05 '22 at 14:10
  • About 1 and 2, I can't since the files are at the node modules and its not something I commit to the repo, but the step of the pipeline that does npm install is the one who creates everything.. About downgrading, I don't have this package in package.json, but it did appear in package-lock after doing "npm i". I'm not sure if there's a package in the package.json I can downgrade for this? – CodeMonkey Dec 05 '22 at 15:44
  • Just add a step in the pipeline to patch the `node_modules`. I'm guessing some package you depend on has an updated peer. You can find out through the `package-lock.json`. Nor `tfx` nor the `azure-devops-extension-tasks` can fix the fact your dependency has a file that `tfx` deems illegal. – jessehouwing Dec 05 '22 at 16:06
  • What do you mean with the patching of the node_modules? not sure how to.. – CodeMonkey Dec 05 '22 at 16:19
  • btw with these changes in tfx should the example here be updated as well? https://learn.microsoft.com/en-us/azure/devops/extend/develop/add-build-task?view=azure-devops – CodeMonkey Dec 05 '22 at 20:02
  • After `npm install` run the PowerShell script above before running the package step. You can do that both locally and on the server. You could convert it into a bit of bash/shell script and put that in your package.json. PowerShell happens to be my hammer for such situations. – jessehouwing Dec 05 '22 at 20:08
  • That example has already been updated. – jessehouwing Dec 05 '22 at 20:09
  • I have added the script right after the npm install in the first run and publish stage but I still get the same errors. Is it enough that I added it only as a step to the pipeline? The error is still about the same file: /node_modules/azure-pipelines-tasks-azure-arm-rest-v2/openssl/OpenSSL License.txt'. Is it possible that the script doesn't access the node modules? – CodeMonkey Dec 06 '22 at 09:13