The nuget command failed with exit code(1) and error(Failed to retrieve information about 'skwas.MockHttp' from remote source - azure-devops

I have a build setup in Azure DevOps Pipelines. After adding this package 'skwas.MockHttp' I'm getting a build error in Azure DevOps pipelines.
##[error]The nuget command failed with exit code(1) and error(Failed to retrieve information about 'skwas.MockHttp' from remote source
'http://artifactory-prod.upc/artifactory/api/nuget/itest-and-nuget/FindPackagesById()?id='skwas.MockHttp'&semVerLevel=2.0.0'.
Any ideas how to resolve this error?

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.

Issue with ‘VsTest’ task in azure devops CI build

I am using sonarqube version 6.1 and i have sonarqube scanning task integrated with my azure CI build . I want to calculate code coverages too , so I have added VsTest task in my CI build (as mentioned in sonarqube-vsts integration documentation).
I am getting error in VsTest task when a build is queued . (All other sonarqube task is running fine)
The error is as below :
Error: The process ‘C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe’ failed with exit code 1
VsTest task failed.
Please let me know how can this be fixed . Build server I am using has VS2017 on it.
Here's the log :
Total tests: 14. Passed: 8. Failed: 6. Skipped: 0.
Test Run Failed.
Test execution time: 41.8253 Seconds
Results File: D:\VSTS Agent Folder\SO\41\s\TestResults\SC-DEOPSCI_MEA-DEVOPS1_2019-09-09_11_14_11.trx
##[warning]Vstest failed with error. Check logs for failures. There might be failed tests.
##[error]Error: The process 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe' failed with exit code 1
##[error]VsTest task failed.
Publishing test results to test run '1000042'
Test results remaining: 14. Test run id: 1000042
##[section]Async Command Start: Publish test results
Published Test Run : https://xyz.visualstudio.com/TipB/_TestManagement/Runs?runId=1000042&_a=runCharts
##[section]Async Command End: Publish test results
##[section]Finishing: VsTest - testAssemblies
The error shows that 6 tests failed. It is the expected behavior of Vstest task. When the tests failed, the task will fail too.
This may indicate that there is something going unexpectedly in your code. You should go back to your source code and fix the failed test cases. After they are fixed, you can rerun your pipeline.
If you didnot want failed tests to effect the next task after Vstest, You can change the Control option of the next task to run the this task even if the previous task has failed.

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.

Unexpected token function when executing custom Azure DevOps Pipeline Task

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.

VSTS Build Fails With Error: Set-Content : Could not find a part of the path 'D:\a\1\a\Publish\manifest.xml'

I am completely new to VSTS and am working my way through the Microsoft Parts Unlimited GitHub Guide here: https://microsoft.github.io/PartsUnlimited/pandp/200.1x-PandP-CICDQuickstartwithVSTS.html
The build of the project successfully completes on my machine without any issues. The build task is a PowerShell 'dotnet restore, build, test and publish' task. I tried using Version 2.0 instead of 1.0 but it still fails (with a slightly different error).
I've followed all the instructions in the guide and the build is failing with the error:
Copyright (C) Microsoft Corporation. All rights reserved. Restoring
packages for
d:\a\1\s\src\PartsUnlimitedWebSite\PartsUnlimitedWebsite.csproj...
Restore completed in 81.65 ms for
d:\a\1\s\src\PartsUnlimited.Models\PartsUnlimited.Models.csproj.
Restore completed in 18.55 ms for
d:\a\1\s\src\PartsUnlimitedWebSite\PartsUnlimitedWebsite.csproj.
Restore completed in 29.21 ms for
d:\a\1\s\src\PartsUnlimitedWebSite\PartsUnlimitedWebsite.csproj.
Generating MSBuild file
d:\a\1\s\src\PartsUnlimitedWebSite\obj\PartsUnlimitedWebsite.csproj.nuget.g.props.
Restore completed in 688.66 ms for
d:\a\1\s\src\PartsUnlimitedWebSite\PartsUnlimitedWebsite.csproj.
npm ERR! Cannot read property '0' of undefined
npm ERR! A complete log of this run can be found in:
npm ERR! C:\npm\cache_logs\2018-02-01T22_41_03_591Z-debug.log
d:\a\1\s\src\PartsUnlimitedWebSite\PartsUnlimitedWebsite.csproj(39,5):
error MSB3073: The command "npm install --loglevel=error" exited with
code 1.
Set-Content : Could not find a part of the path 'D:\a\1\a\Publish\manifest.xml'.
Process completed with exit code 1 and had 2 error(s) written to the error stream.
Where can I even begin to figure out what is causing this?