Unexpected token function when executing custom Azure DevOps Pipeline Task - azure-devops

The custom Azure pipeline task that has the issue can be found here and has been created by following this tutorial. The task tests are working without any issue, so the task is actually running and calling my external package dependency.
After packaging and publishing the task on the VisualStudio Marketplace and using it in my Azure Devops Release Pipeline (using the default Hosted VS2017 agent) I get the following error output:
2019-05-28T06:03:34.4430730Z ##[error]Unhandled: Unexpected token function
2019-05-28T06:03:34.4438636Z ##[debug]Processed: ##vso[task.issue type=error;]Unhandled: Unexpected token function
2019-05-28T06:03:34.4439433Z ##[debug]Processed: ##vso[task.complete result=Failed;]Unhandled: Unexpected token function
The issue occurs when I call a 3rd-party npm package (like directline-jabber in this case). I suspect the node runtime is not accepting my async / await but when I output the node version on the build agent it outputs v10.15.3.

The issue was caused by the package readdirp that heavily relies on the NodeJS filesystem (fs). I expect that those functions fail because they are either not supported or running behind the NodeJS version that is used in their tasks package.

Related

VSTFS build failed at Publish step

I am using the VSTFS CI/CD pipeline to automate my .NET Core 5.0 with Angular 12 web application.
It failing the build at Publish step (see below screenshot) with error:
'npm' is not recognized as an internal or external command,
2021-12-13T20:19:46.9855025Z operable program or batch file.
2021-12-13T20:19:46.9917349Z D:\TFSBuildAgent\_work\58\s\src\WebUI\WebUI.csproj(85,5): error MSB3073: The command "npm install" exited with code 9009.
2021-12-13T20:19:47.0482106Z ##[error]Error: C:\Program Files\dotnet\dotnet.exe failed with return code: 1
2021-12-13T20:19:47.0496257Z ##[error]Dotnet command failed with non-zero exit code on the following projects :
What could be the issue?
Thanks
It looks like npm is not found by the agent. Make sure Node is installed globally on the machine and npm has been added to the system wide path environment variable.
Or add the Node Tool Installer task to your workflows.
I fixed the issue by deleting the npm publish tag in WebUI project file.

2.170.1\Modules\DTAExecutionHost.exe' failed with exit code 1

I am trying to run my automation pipeline on Private hosted agent and getting error as Test Run Failed.
Error: The process 'C:\agent_work_tasks\VSTest_ef087383-ee5e-42c7-9a53-ab56c98420f9\2.170.1\Modules\DTAExecutionHost.exe' failed with exit code 1
Vstest failed with error. Check logs for failures. There might be failed tests.
Error: The process 'C:\agent_work_tasks\VSTest_ef087383-ee5e-42c7-9a53-ab56c98420f9\2.170.1\Modules\DTAExecutionHost.exe' failed with exit code 1 Vstest failed with error. Check logs for failures. There might be failed tests.
Based on the error message, the reason for this issue should be that the VSTest task supported .Net Framework 4.6.2 from version 2.170.1.
You need to check the .NET framework version installed on the build agent machine. If the .NET framework version installed on the machine is 4.6.1 or less than that then can you please try upgrading the .Net framework version to 4.6.2.
Here is a doc about the requirement about the Visual Studio test task:
If you're using a Windows self-hosted agent, be sure that your machine
has this prerequisite installed:
.NET Framework 4.6.2 or a later version
In addition, you can try to use the Visual Studio test task version 1.

Carthage copy-frameworks fails in Azure DevOps pipeline

My project uses Carthage and builds successfully locally, but when I try to build it with an Azure DevOps pipeline on a Microsoft Hosted Agent I get this error:
The following build commands failed:
PhaseScriptExecution Carthage\ Copy\ Frameworks /Users/runner/Library/Developer/Xcode/DerivedData/My-Scheme-euhffgcbmkrrcmfffhaqpabtlubp/Build/Intermediates.noindex/My-Scheme.build/Release-iphoneos/My-Scheme.build/Script-DB5433C1239AF75F00C0B252.sh
(1 failure)
[error] Error: /usr/bin/xcodebuild failed with return code: 65
This is my Carthage Copy Frameworks Build Phase:
/usr/local/bin/carthage copy-frameworks
My guess is that something is different about the configuration of the Azure machine but I don't know what or how to fix it.
I'm also getting this error:
❌ fatal error: /Applications/Xcode_10.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: Input file: /Users/runner/Library/Developer/Xcode/DerivedData/My-Scheme-euhffgcbmkrrcmfffhaqpabtlubp/Build/Products/Release-iphoneos/Realm.framework.dSYM/Contents/Resources/DWARF/Realm changed since opened (Undefined error: 0)
Even if Carthage causes no problems locally, if your scheme builds multiple targets that run the carthage copy-frameworks command, the agent machine may throw an error like the one above: Realm changed since opened (Undefined error: 0).
It seems that the same files are being accessed simultaneously because multiple targets are being built in parallel. In my case, carthage copy-frameworks was being run for my app target and my test target. A fix for this is to have your scheme only build the app target:
Product > Scheme > Edit Scheme > Build (n targets) > Target to Remove > Select -

Enabling self-contained causes dotnet publish to fail with private NuGet

Enabling a self-contained publish causes an error when authenticating with a private NuGet feed. Without "--self-contained true" everything runs fine, with it the error below appears.
What can I do to resolve this?
##[section]Starting: Publish
==============================================================================
Task : .NET Core
Description : Build, test, package, or publish a dotnet application, or run a custom dotnet command
Version : 2.154.6
Author : Microsoft Corporation
Help : [Learn more about this task](https://go.microsoft.com/fwlink/?linkid=832194) or [see the .NET Core documentation](https://learn.microsoft.com/dotnet/core/)
==============================================================================
[command]C:\Windows\system32\chcp.com 65001
Active code page: 65001
[command]C:\agent\_work\_tool\dotnet\dotnet.exe publish C:\agent\_work\195\s\redacted.csproj --self-contained true --runtime win-x64 --configuration release --output C:\agent\_work\195\a\redacted
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restoring packages for C:\agent\_work\195\s\redacted.csproj...
Restore completed in 40.71 ms for C:\agent\_work\195\s\redacted.csproj.
Restore completed in 0.51 ms for C:\agent\_work\195\s\redacted.csproj.
Restore completed in 1.17 ms for C:\agent\_work\195\s\redacted.csproj.
Restoring packages for C:\agent\_work\195\s\redacted.csproj...
C:\agent\_work\_tool\dotnet\sdk\2.2.105\NuGet.targets(114,5): error : Unable to load the service index for source https://pkgs.dev.azure.com/redacted/_packaging/redacted/nuget/v3/index.json. [C:\agent\_work\195\s\redacted.csproj]
C:\agent\_work\_tool\dotnet\sdk\2.2.105\NuGet.targets(114,5): error : Response status code does not indicate success: 401 (Unauthorized). [C:\agent\_work\195\s\redacted.csproj]
##[error]Error: The process 'C:\agent\_work\_tool\dotnet\dotnet.exe' failed with exit code 1
##[error]Dotnet command failed with non-zero exit code on the following projects : C:\agent\_work\195\s\redacted.csproj
##[section]Finishing: Publish
error : Response status code does not indicate success: 401
(Unauthorized).
This error is caused by that in Azure Devops, for authenticating to VSTS feed, the Dotnet.exe only supports dotnet restore and dotnet nuget push commands. So, try running dotnet restore task first.
Update:
Since you have executed the dotnet restore before running dotnet publish. The auth issue should be caused by the dotnet publish task. While you execute --self-contained true, this means that except for the default files which you have locally, it also tries to get files from the other path including your private feed. For accessing private feed, it needs credential. Without credential, the private feed will refuse the get request. And then, it may cause this error.
And also, dotnet publish include an implicit restore step but will not have the system credentials in place. So, even if you have run dotnet restore successfully in the earlier step, it can also fail with non-authenticated because the credential is cleaned up after the previous task is finished.
You can add --no-restore to the arguments to avoid implicit restore. For more details, please check this doc: implicit restore that runs during publish.

Buildpacks error

I am running an application at IBM Bluemix DevOps and while deploying I am getting this error:
App staging failed in the buildpack compile phase.
On checking logs I found this:
How do I get rid of this problem?
You're trying to use a node npm module which you might not have declared as a dependency. Add gulp to your package.json as show in in the car-dashboard sample you are referencing.