microsoft / tfs-cli

Cross-platform CLI for Microsoft Team Foundation Server and Visual Studio Team Services
MIT License
369 stars 132 forks source link

tfx build tasks upload gives error no task.json in specified directory At C:\Users\pkuijper\AppData\Roaming\npm\tfx.ps1:24 char:5 #459

Open pkuijper opened 2 months ago

pkuijper commented 2 months ago

node version 22.3.0 npm version 10.8.1

PS C:\temp\SampleTask> tfx build tasks upload --task-path C:\temp\SampleTask
[37m[90mTFS Cross Platform Command Line Interface v0.17.0[37m[39m
[37m[90mCopyright Microsoft Corporation[37m[39m
node.exe : [41merror: Error: no task.json in specified directory[49m
At C:\Users\pkuijper\AppData\Roaming\npm\tfx.ps1:26 char:5
+     & "node$exe"  "$basedir/node_modules/tfx-cli/_build/tfx-cli.js" $ ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: ([41merror: Err... directory[49m:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

File structure:

--- SampleTask
    |--- images
          |--- extension-icon.png
    |--- sampletask
          |--- ps_modules
                |--- ....
          |--- sample.ps1
          |--- task.json
    |--- vss-extension.json
    |--- test.sample-build-release-task-0.0.1.vsix

I tested the task.json content on https://jsonlint.com/, and it is valid. if i open file "test.sample-build-release-task-0.0.1.vsix" as a zip it contains the task.json file.

i followed steps https://learn.microsoft.com/en-us/azure/devops/extend/develop/add-build-task?view=azure-devops and the steps in https://4bes.nl/2021/02/21/create-a-custom-azure-devops-powershell-task/

I login to our tfs server successfully with the command "tfx login --auth-type pat --token **** --service-url https://mytfsserver/mycollections" but uploading the task fails with command "tfx build tasks upload --task-path C:\temp\SampleTask"

DenisRumyantsev commented 1 month ago

Hi @pkuijper I cannot reproduce your issue using node version 22.3.0, npm version 10.8.1, and tfx version 0.17.0 (currently the latest one). Is it possible that tfx cannot read the task.json file due to lack of access rights? Can you try to run it as administrator?