Azure-pipelines-tasks: Deploy TestAgent task fails on 'CopyFilesToTestAgent' with mesg: The term 'net' is not recognized as the name of a cmdlet

Created on 16 Feb 2018  路  16Comments  路  Source: microsoft/azure-pipelines-tasks

Environment

  • Server - VSTS or TFS on-premises?

    • TFS on-premises version: 15.117.27024.0
  • Agent - Private:

    • Windows Server 2016, agent version: 2.124.0
  • Powershell version: 5.1.14393.1715

Issue Description

As title says. 'CopyFilesToTestAgent' fails with error (one of few errors acctually, logs below) 'The term 'net' is not recognized as the name of a cmdlet'.
Running net command from powershell results in similar error.
psnetcommandshot
This issue seems duplicate but it's resolution wasn't helpful at all.

Running

Error logs

CopyFilesToTestAgent_ErrorLogs.txt

Worker_20180216-120653-utc.log

2018-02-16T12:07:19.5411869Z ##[warning]Task 'CopyFilesToTestAgent' for machine DEVDWCL4:5985's Error : System.AggregateException: Failed to execute the powershell script. Consult the logs below for details of the error.
2018-02-16T12:07:19.5411869Z ##[debug]Processed: ##vso[task.issue type=warning;]Task 'CopyFilesToTestAgent' for machine DEVDWCL4:5985's Error : System.AggregateException: Failed to execute the powershell script. Consult the logs below for details of the error.
2018-02-16T12:07:19.5411869Z Failed to connect to the path \DEVDWCL4 with the user siidev\gswiecdev for copying.
2018-02-16T12:07:19.5411869Z The term 'net' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
2018-02-16T12:07:19.5411869Z +At line:1 char:15
2018-02-16T12:07:19.5411869Z + $dtl_mapOut = net use $dtl_machineShareName /user:'siidev\gswiecdev' ...
2018-02-16T12:07:19.5411869Z + ~~~
2018-02-16T12:07:19.5411869Z CategoryInfo :ObjectNotFound: (net:String) [], CommandNotFoundException
2018-02-16T12:07:19.5411869Z FullyQualifiedErrorId :CommandNotFoundException
2018-02-16T12:07:19.5411869Z ---> System.Management.Automation.RuntimeException: Failed to connect to the path \DEVDWCL4 with the user siidev\gswiecdev for copying. ---> System.Management.Automation.RuntimeException: Failed to connect to the path \DEVDWCL4 with the user siidev\gswiecdev for copying.
2018-02-16T12:07:19.5411869Z --- End of inner exception stack trace ---

Test

All 16 comments

Maybe it would be better to use New-PSDrive command instead of 'net use'? I don't see a point using an old cmd net use command here. Or maybe I'm wrong thinking that 'net use' command is used here?

@acesiddhu this bug looks trivial, but I'm stuck with it. Do you have any suggestions how could I try to work around this problem? As you can see above - net command doesn't work, but net.exe promptly does something in the background, but no result is returned to ps console.

@asranja any suggestions?

can you check if path environment variable has C:\Windows\System32. also make sure you don't override that variable in ur build definition

@acesiddhu of course, I did that check before issuing this bug. Path env variable has c:\Windows\System32 entry. I also added C:\Windows\System32\wbem to the path, that is actually where net.exe is located. As you can see net.exe command can be executed (means it is on the path)
Additional logs with path command executed(path has needed entries, and is not overridden in build definition) logs_122.zip

@asranja does net runs on remote machine? or build machine?

@acesiddhu Yes. The command net.exe should be under C:\Windows\System32 itself. @swiec can you browse to the folder and check for net.exe there (which I am assuming you would have already done). Also, what happens you run "net.exe use /?"

@asranja in fact net.exe is located where you have pointed (C:\Windows\System32), but it doesn't change anything.

You can't see what happens when you run "net.exe use /?" . Because it is promptly executed in background (some window is opened for split-second) and no result is returned to the ps console.
I'm assuming that this is due to a fact, that you guys are using old cmd command instead of New-PSDrive (see: https://www.howtogeek.com/132354/how-to-map-network-drives-using-powershell/)

Running from powershell command "net.exe use m: \devdwcl4\siilqadeploy" works fine (as fine as you can expect) - opens old cmd prompt to provide credentials and maps network share. So I assume that "net.exe use /?" works also fine - it simply prompts cmd window, shows help and closes - in split-second

Well, I did struggle some more, and again I did run into a wall.
I have added global powershell alias using this tip:
https://stackoverflow.com/questions/24914589/how-to-create-permanent-powershell-aliases
Alias is "New-Alias net net.exe -Scope Global"
To assert this olution I have even added cmd command that runs 'powershell get-command net use' in the same build - result as expected.
psgetcommandnetuse

Path environment variable is also ok as you can see in added build steps logs.
logs_133.zip

But problem in DeployTestAgent persists!

@asranja @acesiddhu is there any way to debug this task execution?

@swiec Can you try and run "C:\windows\system32\net.exe use /?" via cmd instead of powershell and see if it works fine.

@asranja @acesiddhu

Yes, it works ok on both machines - build server (where build agent is installed), and target machine (where test agent supposed to be deployed).

netusebuildserver
netusedevdwcl4

Are you sure that execution of 'net use' command is root cause here, there are several other errors messages in this task, as you can see in logs:

  1. 'Failed to connect to the path \DEVDWCL4.siidev.pl with the user siidev\gswiecdev for copying.'
    faildtoconnect

  2. 'Test agent source path 'C:\agent10_w_tasks\DeployVisualStudioTestAgent_52a38a6a-1517-41d7-96cc-73ee0c60d2b6\2.1.8\TestExecution.zip' is not accessible to the test machine.'
    testagentsourecepatherror

Path variable is not overridden during build execution:
pathvariablesetup

@swiec is it possible to have skype call to resolve this issue?
If yes, please drop a mail to devops_tools at microsoft dot com.

@nigurr sure - mail sent
[edit]
Hope it was received, because I've got an answer from one of recipient groups:
'The group tri only accepts messages from people in its organization or on its allowed senders list, and your email address isn't on the list.'

@swiec we received your email. We will try reaching you as early as possible.

@nigurr Any chance that any action take place regarding this topic? I'm stuck. Today I found that running Build Agent as process instead of running as service helps with "The term 'net is not recognized issue". But it's just workaround which drove me to another immediate stop -> https://github.com/Microsoft/vsts-tasks/issues/6580 . Which in my opinion proofs that root cause wasn't removed. And running build agent as service still ends up with above error.

@swiec, i have mailed for appropriate time to have skype call. Please check your mail. We are available from 10 AM IST to 5 PM IST. Please let us know free time on Monday

Was this page helpful?
0 / 5 - 0 ratings