Closed RainerMuehlberger closed 4 years ago
@RainerMuehlberger - What version of the PowerShell task are you running?
I am having difficulty trying to reproduce the issue. Are the � characters in your comment what you are actually seeing? Is it possible that somehow some control characters are getting their way into run_tfs_build.ps1 and that is what is causing the issue?
Hello Tommy,
ok.
We are using the following PS-Version:
PS C:\Users\adm-muehlbergerr> $PSVersionTable
Name Value
PSVersion 5.1.14409.1018
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14409.1018
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
I’ve reproduced it with a (staging) agent version 2.153.1
(we upgraded our TFS2017 two weeks ago and are using now Azure DevOps Server 2019, but I think, it’s not important)
Ok.
I created a small example with the issue:
Batch script task with the following line:
powershell "%~dp0%test.ps1" 2>&1
Powershell script “test.ps1” with the content:
#################################################################################################
#################################################################################################
$ExportTarget = "do_export"
$wrenv_exe = Join-Path (get-item env:"WIND_HOME").Value -ChildPath "wrenv.exe"
$vsvars32_bat = Join-Path (get-item env:"VS100COMNTOOLS").Value -ChildPath "vsvars32.bat"
if(-Not (Test-Path -Path $wrenv_exe) ) { write-error "wrenv.exe ($wrenv_exe) does not exist"; exit 1;}
if(-Not (Test-Path -Path $vsvars32_bat) ){ write-error "vsvars32.bat ($vsvars32_bat) does not exist"; exit 1;}
$MakeCommand = "make -C $TOP_DIR $ExportTarget DEBUG:=OFF"
echo " - MakeCommand: $MakeCommand"
$MakeCommand | & "$vsvars32_bat" "&&" "$wrenv_exe" "-p" "vxworks-6.8" 2>&1
The “wrenv.exe” is a shell of the realtime compiler Windriver.
For testing I replaced the “MakeCommand” with a simple “ls” command
"ls" | & "$vsvars32_bat" "&&" "$wrenv_exe" "-p" "vxworks-6.8" 2>&1
This is the output of the build:
==============================================================================
Task : Batch script
Description : Run a Windows command or batch script and optionally allow it to change the environment
Version : 1.1.7
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/batch-script
==============================================================================
C:\b02_w\4\s>powershell "C:\b02_w\4\s\test.ps1" 2>&1
Setting environment for using Microsoft Visual Studio 2010 x86 tools.
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.
C:\b02_w\4\s>���ls
C:\b02_w\4\s>vsvars32.bat : '���ls' is not recognized as an internal or external command,
At C:\b02_w\4\s\test.ps1:16 char:8
"ls" | & "$vsvars32_bat" "&&" "$wrenv_exe" "-p" "vxworks-6.8" 2>&1
+ CategoryInfo : NotSpecified: ('���ls' is not ...ternal command,
:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
operable program or batch file.
This issue doesn’t appear if I use an older agent.
Mit freundlichen Grüßen / Kind regards / Tisztelettel / 致以诚挚的问候
i. A. Rainer Mühlberger
Principal DevOps Engineer – Infrastructure & Architecture (IA)
Research & Development (R&D)
KUKA Deutschland GmbH
Zugspitzstraße 140, 86165 Augsburg / Germany www.kuka.com Rainer.Muehlberger@kuka.com T +49 821 797‑2552 F +49 821 797‑XX
Geschäftsführung / Board of Directors: Klaus König (Vors.), David Fuller, Ursula Urbas
Sitz und Registergericht / Registered Office: Augsburg HRB 14914
Diese E-Mail kann vertrauliche und/oder rechtlich geschützte Informationen enthalten. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of contents of this e-mail is strictly forbidden.
From: Tommy Petty notifications@github.com Sent: Dienstag, 3. September 2019 20:15 To: microsoft/azure-pipelines-agent azure-pipelines-agent@noreply.github.com Cc: Muehlberger, Rainer Rainer.Muehlberger@kuka.com; Mention mention@noreply.github.com Subject: Re: [microsoft/azure-pipelines-agent] Error in using "&" in powershell v5.1 (#2398)
@RainerMuehlberger https://github.com/RainerMuehlberger - What version of the PowerShell task are you running?
I am having difficulty trying to reproduce the issue. Are the � characters in your comment what you are actually seeing? Is it possible that somehow some control characters are getting their way into run_tfs_build.ps1 and that is what is causing the issue?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/microsoft/azure-pipelines-agent/issues/2398?email_source=notifications&email_token=AJU5ZOXC4VQQTJ57NCEQWVTQH2ST5A5CNFSM4IOICE2KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5ZC2JA#issuecomment-527576356 , or mute the thread https://github.com/notifications/unsubscribe-auth/AJU5ZOQC3DJ4WH5MM7WM4FLQH2ST5ANCNFSM4IOICE2A . https://github.com/notifications/beacon/AJU5ZOX4ZRTSFRVA2GBIPSTQH2ST5A5CNFSM4IOICE2KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5ZC2JA.gif
@RainerMuehlberger - I am still unable to reproduce.
Here is my setup:
PS C:\agent> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.18362.145
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.18362.145
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
I tried to reproduce your case as close as possible, but I don't have wrenv or vsvars32.bat, so I created a test.bat and test.ps1 with the following contents:
test.bat
powershell "%~dp0%test.ps1" 2>&1
test.ps1
$foo = "C:\Users\jopetty\AppData\Local\Microsoft\WindowsApps\python.exe"
echo "Hello World"
"ls" | & "$foo" "--version"
My task definition in my pipeline is:
steps:
- task: BatchScript@1
inputs:
filename: test.bat
Here is the output when I run my pipeline:
<1s
Starting: BatchScript
==============================================================================
Task : Batch script
Description : Run a Windows command or batch script and optionally allow it to change the environment
Version : 1.1.7
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/batch-script
==============================================================================
C:\agent\_work\2\s\test.bat
C:\agent\_work\2\s>powershell "C:\agent\_work\2\s\test.ps1" 2>&1
Hello World
Python 3.7.4
Finishing: BatchScript
Can you try my test.ps1 and see if that works for you, just change the contents of $foo to some .exe on your system?
Hello Tommy, sorry - I was busy with other tasks. I analyzed the problem and I'm sure, that it is caused by the old windriver shell. Yesterday I changed the implementation from powershell to batch script and it works now. Consequently we can close this issue now.
We are using the following code in powershell v5.1:
...
...
If we run it the following error occured:
C:\b01_w\101\s>���make -C C:/b01/_w/101/s do_export DEBUG:=OFF vsvars32.bat : '���make' is not recognized as an internal or external command, At C:\b01_w\101\s\Scripts\TFS\run_tfs_build.ps1:228 char:16
operable program or batch file.
The agent version 2.144.0 works fine without error.. I've tested the agent version 2.148.2. It is buggy. I've also tested 1.153 and the latest version 2.155. Both produces the same error. We are using TFS 2017 on premise.
best regards, Rainer Muehlberger