Error when I run the Visual studio run task in CI - azure-devops

I have a .net application and I am getting below error while running Visual studio task in CI pipeline.
##[error]No agent found in pool TEST APP which satisfies the following demand: visualstudio. All demands: msbuild, visualstudio, Agent.Version -gtVersion 2.115.0
Please let me know how to resolve this.

Your pool does not contain build agents with Visual Studio. You can check your polls and agents on the administration page: Agent pools.
You have to install and register a build agent on a server or virtual machine with visual studio.
Additionally, if your project on Azure DevOps Services, you can use MS Hosted build agents. Update your yaml to:
pool:
vmImage: windows-latest
or if you use classic build, update here:

Related

Azure pipelines - How to manage versions of the tasks?

I would like to understand how the tasks work in Azure pipeline, and where can I find the documentation for it.
I have a self-hosted agent where I have installed Terraform, Azure CLI and Azure Powershell.
There are some tasks defined for them, I actually have difficulties to find them in a documentation,for example with terraform, I have to go to azure release and simulate an action of adding task, then convert that in yaml and there I have the task name:
steps:
- task: ms-devlabs.custom-terraform-tasks.custom-terraform-release-task.TerraformTaskV3#3
displayName: 'Terraform : azurerm'
inputs:
command: custom
customCommand: import
environmentServiceNameAzureRM: 'something'
Also, some tasks asks to install some resources in order to use them, will it affect the resources of my self-hosted agent? for example if we have to install the task before using it ,will it affect somehow the version of my self-hosted terraform?
I have azure powershell installed in the self-hosted agent with an old version, but there is a task that in the version parameter has the latest version, but when executing the task it uses my old version.
How versions for tasks work? Can I use the latest version or az cli without installing it in the self-hosted agent but only with the tasks for the deployments only?
- task: AzurePowerShell#5
displayName: 'DevCode'
inputs:
#azureSubscription: 'something'
azureSubscription: 'something'
ScriptPath: 'something'
azurePowerShellVersion: LatestVersion
The same for az cli.
For the commonly used pipeline tasks published by Microsoft (such as Azure CLI task and Azure PowerShell task), you can find the related documents here.
All these tasks are open-source on the GitHub repository "microsoft/azure-pipelines-tasks".
For the Terraform task, you can find it on Marketplace here and this GitHub repository.
Normally, the tasks would not change the tools have installed on your self-hosted agent machine, also not automatically install the required tools. They just call the required tools have installed on the agent machine.
For example, when you run the Azure CLI task on your self-hosted agent, if you have installed the Azure CLI tool on the agent machine, the task will call the tool to run the specified scripts. If the Azure CLI tool has not installed on the machine, normally the task will go to failure since it cannot find the required Azure CLI tool on the machine.
You do not need to manage the versions of the tasks, you just use the tasks in your pipelines and select the available released versions of the tasks (latest versions are recommended). If a new version of a task is released, you can go to edit your pipelines to use the new version.

Anular test and build with Azure devops TFS issue while chrome-headless

I can use and install chrome-headless with puppeteer in azure devops by (dev.azure) but its not working in azure devops TFS.
Shows error that "chromium install is failed"
For this issue , if the task you installed is VSTS Chromium Build Task, then this task should not be applicable in TFS.
As stated in the task description: This task automates the Process of Installing Chromium on your Hosted Build Agent in VSTS so that you can run your javascript tests with a headless browser.
However, there is no hosted agent in TFS, only self-hosted agent. So chromium installation will fail . At present, chromium can only installed in azure devops service.

In VSO release Powershell task is failing while using 'Azure Pipelines' agent and same task is passing while using 'Hosted MSIT Fortify 2017' agent

Normal VSO release should work with the 'Azure Pipelines' agent. But it is failing in Azure Powershell task saying 'Could not find the modules: 'Az.Accounts'.. While same task is running with the 'Fortify' agent
Tried all possible agents other than 'Fortify'. Didn't work.
I had the same problem with version 4 of the task. I switched to 3 and it got fixed.
I came across a similar error using task Azure Powershell "Could not find the modules: 'Az.Accounts' with Version: '5.1.1' If the module was recently installed, retry after restarting the Azure Pipelines task agent".
My fix to this error is to use the latest version of azurePowerShellVersion,
azurePowerShellVersion: 'latestVersion'
For classic view:
select the latest version 4.* of task Azure Powershell
check latest installed verison for azure powershell version
If above fix does not work for you. For better troubleshooting, please post the full error message and the detailed settings of Azure Powershell task.

Installing the Visual Studio 2015 toolkit (v140) on a Microsoft hosted Azure Devops Build Pipeline Agent

I have a legacy solution that we've moved into an Azure Devops git repo and I am trying to setup a build pipeline for it. The solution is a mixture of v141 (2017) and v140 (2015) projects, which on my local machine I can just build in Visual Studio 2017 as long as I've installed the v140 toolset.
Ideally, I'd like to use a Microsoft provided agent but it seems like the vs2017-win2016 image does not include the v140 toolset by default. As this is not something we are planning to build very often, I attempted to install the v140 toolset using the 2017 installer:
pool:
vmImage: 'vs2017-win2016'
steps:
- task: PowerShell#2
displayName: 'Install Visual Studio v140 Toolset'
inputs:
targetType: 'inline'
script: |
Write-Output "Starting the installation process. This will take some time"
$installProcess = Start-Process -FilePath $(Build.SourcesDirectory)/External/VisualStudioBuildTools/installer.exe -ArgumentList "--add Microsoft.VisualStudio.Component.VC.140", "--quiet", "--wait", "--norestart" -Wait -PassThru
Write-Output "Install Completed with code $($process.ExitCode)"
- task: VSBuild#1
displayName: 'Build Debug [.sln]'
inputs:
solution: '$(Build.SourcesDirectory)/LegacySolution.sln'
vsVersion: '15.0'
configuration: 'Debug'
platform: 'x64'
When I run this in Azure Devops, the install process exits with code 0 (success) after about a minute. However, when it then tries to build the solution it fails with:
##[error]C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\Microsoft.Cpp.Platform.targets(67,5): Error MSB8020: The build tools for v140 (Platform Toolset = 'v140') cannot be found. To build using the v140 build tools, please install v140 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution".
Has anyone tried this before with any luck? The only other thing I can think of is to try to check in a copy of the v140 toolset and play with adding it correctly to the path, but I can see this being a major pain to get right!
Installing the Visual Studio 2015 toolkit (v140) on a Microsoft hosted Azure Devops Build Pipeline Agent
In generally you can't. If something requires admin access and you're using the hosted agent, you can't do that thing. I have test this command line in my local, I need to run the powershell with Administrator, otherwise, I will get a confirmation prompt.
Besides, MS replied:
VS has grown to a point, where installing multiple versions on the
same agent is not feasible any longer for us. Also, we notice problems
in side-by-side VS installations for certain project types. For these
reasons, we have decided to keep a single tool set going forward. If
you need multiple versions, then you would have to setup custom
agents. We are sorry that we cannot meet all of our customers'
requirements using a common hosted agent image.
So, to resolve this issue, we have to setup our private agent.
Hope this helps.

Configuring Sonarqube analysis in CI build in VSTS

I am trying to run sonarqube analysis on code commit itself .
I have added 1) prepare analysis configuration and 2) run code analysis, tasks in CI build.
But I am getting an error :
" No agent found in pool mypool which satisfies the specified demands: msbuild visualstudio java
Agent.Version -gtVersion 2.119.1"
Can anyone please guide on what the issue is ?
Thanks in Advance !
Configuring Sonarqube analysis in CI build in VSTS
According to the error message:
error : " No agent found in pool mypool which satisfies the specified
demands: msbuild visualstudio java Agent.Version -gtVersion 2.119.1"
Which means that your private agent does not meet all the demands you set, including msbuild, visualstudio, java, Agent.Version -gtVersion 2.119.1.
So, you should double check if your private agent has those demands, you could move those demands one by one, to check which one is not up to the requirements.
AFAIK, to configure Sonarqube analysis in CI build in Azure Devops, we need following demands:
Make sure the .NET Framework v4.6+ is installed
Make sure the Java Runtime Environment 8 is installed
Install the extension SonarQube from the marketplace
Check the document Analyzing with SonarQube Extension for VSTS-TFS for some details.
Hope this helps.