microsoft / azure-pipelines-agent

Azure Pipelines Agent 🚀
MIT License
1.72k stars 864 forks source link

Using the latest azure-pipelines-agent v2.193.1 on premises - Does not recognize Visual Studio 2022 RC #3567

Closed rizi closed 2 years ago

rizi commented 2 years ago

Agent Version and Platform

2.193.1, I downloaded this version from your github repository and installed it on our self hosted (on premises) azure devops server (17.143.28621.4 (AzureDevOps2019) on windows.

Visual Studio 2022 Enterprise RC has been installed before I installed the new agent.

We are using "classic builds" (not yaml builds) and all tasks (like visual studio build task or visual studio test task) still using VS 2019 instead of VS 2022.

We are selected 'latest version' in the visual studio build task, but that does not have any effect.

Settings --> Agent pools --> Default --> I see the new installed agent (2.193.1), but under capabilities it still only shows VS 2019 and MSBuild 16.

I would expected that under capabilities VS 2022 and MSBuild 17 should be listed as well?

Can you point me in the right direction to make our azure devops server/pipeline agent use VS 2022 instead of VS 2019?

This seems to be related: https://github.com/microsoft/azure-pipelines-tasks/issues/15051#issuecomment-945600008

br

rizi commented 2 years ago

@bruzkovsky

ghost commented 2 years ago

Hello @rizi, could you please attach full debug logs of your execution of visual studio build task?

rizi commented 2 years ago

Hello @rizi, could you please attach full debug logs of your execution of visual studio build task?

@tatyana-kostromskaya

I think at least two ps1 scripts(maybe more) need to be changed to support VS 2022 (17.x): https://github.com/microsoft/azure-pipelines-agent/blob/master/src/Misc/layoutbin/powershell/Add-VisualStudioCapabilities.ps1

https://github.com/microsoft/azure-pipelines-agent/blob/master/src/Misc/layoutbin/powershell/CapabilityHelpers/VisualStudioFunctions.ps1

Could you please tell me how to get a full log. Do I have to set a special variable for a full log or something else? Br

ghost commented 2 years ago

To get debug log, you need to run your pipeline with variable system.debug = true.

I think at least two ps1 scripts(maybe more) need to be changed to support VS 2022 (17.x): https://github.com/microsoft/azure-pipelines-agent/blob/master/src/Misc/layoutbin/powershell/Add-VisualStudioCapabilities.ps1

Yes, we need to additionally change these scripts to have correct list of capabilities, but VisualStudio capabilities should not affect "VisualStudio build task" because it contains its own logic to get latest installed versions of VS and msbuild.

rizi commented 2 years ago

To get debug log, you need to run your pipeline with variable system.debug = true.

rawlog.txt

I think at least two ps1 scripts(maybe more) need to be changed to support VS 2022 (17.x): https://github.com/microsoft/azure-pipelines-agent/blob/master/src/Misc/layoutbin/powershell/Add-VisualStudioCapabilities.ps1

Yes, we need to additionally change these scripts to have correct list of capabilities, but VisualStudio capabilities should not affect "VisualStudio build task" because it contains its own logic to get latest installed versions of VS and msbuild.

@tatyana-kostromskaya azure_issue here we go: https://drive.google.com/file/d/1wOIU0hDsHDCqoK3skSDMJGOLBSCeDS1V/view?usp=sharing -->I uploaded the log to my google drive as well, just to be sure ;)

I would also expect to see Visual Studio 2022 in the drop down box (Visual Studio Versions), see the attached picture.

I think the tasks on the azure devops server (on premises) need to be updated as well, have a look at this issue (https://github.com/microsoft/azure-pipelines-tasks/issues/15051#issuecomment-945600008), but it seems this has only be done for azure devops services and not for the on premises version, what do you think (as I already mentioned, all tasks are affected (build, restore, test, ..)?

Thx for your time an patience!

ghost commented 2 years ago

For on-premise solutions (Azure DevOps Server) tasks updates are deployed with Azure DevOps Server updates, that should be updated manually. Unfortunately, releases of Azure DevOps Server may not contain latest versions of tasks.

I can only suggest you to update all tasks you are interested in manually. I can provide you ready build of tasks and instructions how to update these tasks in your organization.

rizi commented 2 years ago

For on-premise solutions (Azure DevOps Server) tasks updates are deployed with Azure DevOps Server updates, that should be updated manually. Unfortunately, releases of Azure DevOps Server may not contain latest versions of tasks.

I can only suggest you to update all tasks you are interested in manually. I can provide you ready build of tasks and instructions how to update these tasks in your organization.

@tatyana-kostromskaya Yes, please tell me how to update the tasks and where I can find them, so I can download and install them on our on premises server.

Do I need a new version of azure-pipelines-agent as well, or just the tasks you will provide to me?

Br

ghost commented 2 years ago

Do I need a new version of azure-pipelines-agent as well, or just the tasks you will provide to me?

No, to get new versions of tasks worked you will need just to publish these tasks to your organization. To get correct list of capabilities you will need a new version of agent, but it will be released in a several weeks.

@rizi which tasks do you interested in?

rizi commented 2 years ago

Do I need a new version of azure-pipelines-agent as well, or just the tasks you will provide to me?

No, to get new versions of tasks worked you will need just to publish these tasks to your organization. To get correct list of capabilities you will need a new version of agent, but it will be released in a several weeks.

@rizi which tasks do you interested in?

@tatyana-kostromskaya VsBuild, MsBuild,MsTestV2, please also provide me how to do update the tasks correctly.

One more question: what are the capabilities for the build agents used for? When do I need to update the build agents and when do I need to update the build tasks?

Br

ghost commented 2 years ago

One more question: what are the capabilities for the build agents used for? When do I need to update the build agents and when do I need to update the build tasks?

List of capabilities of agents are mostly used to create demands for running pipelines by users, and as far as I know usually tasks don't relay on capabilities. Mostly to get new features and options in tasks you need to update tasks (or update your Azure DevOps Server, but new feature may appear there with some delay). Every release of agent have new fixes for bugs and/or new features. You can find details about each release on releases page. So if you don't need any of new features or bug fixes you don't have to update them manually, you can just wait for new release of Azure DevOps server and update it.

MsTestV2

Didn't you mean VsTestV2?

please also provide me how to do update the tasks correctly.

Here are zip achieves with latest versions of the tasks: MSBuildV1.zip VSBuildV1.zip VsTestV2.zip

To update these tasks in your organization please follow the instruction:

  1. Unpack achieves to any location.
  2. Install Node.js
  3. Install tfx-cli : For Linux/OSX: sudo npm install -g tfx-cli For Windows: npm install -g tfx-cli
  4. Sign in with your account to Azure DevOps.
  5. Create a personal access token or use existing one. To create new token: a. Click on “User Settings” in the upper right corner of the page; b. Select “Personal access tokens”; c. In the opened window, click on the “+ New Token” button; d. Enter any name for your access token and choose “Full Access”; e. Copy and save your token!
  6. Run command from a command line - tfx build tasks upload -u https://<YOUR_ORGANISATION>.visualstudio.com/DefaultCollection -t <YOUR_PERSONAL_ACCESS_TOKEN> --task-path <PATH_TO_UPDATED_TASK> PATH_TO_UPDATED_TASK - path to folder of unpacked task
ghost commented 2 years ago

In future you can build these tasks by your self. These tasks are stored in the public repo: https://github.com/microsoft/azure-pipelines-tasks Here you can find instruction with prerequisites and commands for building these tasks: https://github.com/microsoft/azure-pipelines-tasks/blob/master/docs/contribute.md#prerequisites-node-and-npm

rizi commented 2 years ago

In future you can build these tasks by your self. These tasks are stored in the public repo: https://github.com/microsoft/azure-pipelines-tasks Here you can find instruction with prerequisites and commands for building these tasks: https://github.com/microsoft/azure-pipelines-tasks/blob/master/docs/contribute.md#prerequisites-node-and-npm

Thank you very much.

durandt commented 2 years ago

Do I need a new version of azure-pipelines-agent as well, or just the tasks you will provide to me?

No, to get new versions of tasks worked you will need just to publish these tasks to your organization. To get correct list of capabilities you will need a new version of agent, but it will be released in a several weeks.

@rizi which tasks do you interested in?

Hi, do you have the timeline of when the new tasks will be installed to existing devops orgs?

Regards,

Thibault

durandt commented 2 years ago

PS: I newly installed a new v2.194.0-agent with the newly released Visual Studio Enterprise 2022 and the agent did not detect capabilities for MSBuild, VSTest and VisualStudio

durandt commented 2 years ago

PPS: Sorry just found #3569 , will follow there. But let us know if you have any timeline.

jessehouwing commented 2 years ago

I've blogged a few alternatives to self-building the tasks including an option to download them straight from an active Azure DevOps organization:

https://jessehouwing.net/adding-visual-studio-2022-to-azure-devops-server-2020/

$tasksToDownload = @("VSBuild", "VsTest", "VsTestPlatformToolInstaller", 
                  "MSBuild", "DotNetCoreInstaller", "DotNetCoreCLI")

$org = "<<insert source org>>"
$pat = "<<insert PAT | Agent Pool (Manage)>>"
$projectCollectionUri = "https://yourtfs/yourcollection"

$url = "https://dev.azure.com/$org"
$header = @{authorization = "Basic $([Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(".:$pat")))"}

$tasks = Invoke-RestMethod -Uri "$url/_apis/distributedtask/tasks" -Method Get -ContentType "application/json" -Headers $header | ConvertFrom-Json -AsHashtable

foreach ($taskName in $tasksToDownload)
{
    $taskMetadatas = $tasks.value | ?{ $_.name -ieq $taskName }
    foreach ($taskMetadata in $taskMetadatas)
    {
        $taskid = $taskMetadata.id
        $taskversion = "$($taskMetadata.version.major).$($taskMetadata.version.minor).$($taskMetadata.version.patch)"
        $taskZip = "$taskName.$taskid.$taskversion.zip"
        Invoke-WebRequest -Uri "$url/_apis/distributedtask/tasks/$taskid/$taskversion" -OutFile $taskZip -Headers $header

        & tfx build tasks upload --task-zip-path "$taskZip" --service-url $projectCollectionUri
    }
}