Extension
I've published a pre-built extension that packages a copy of the current task versions from Azure DevOps (service).
This will allow you to install the tasks risk-free alongside Microsoft's older versions.
Do it yourself
You have 2 options.
- Download the tasks from an existing Azure DevOps organization (cloud version). Then use tfx or PowerShell to upload the upgraded tasks to your Azure DevOps server.
- Build the tasks from source and publish them to your Azure DevOps server.
I've outlined the process in a blog post:
https://jessehouwing.net/adding-visual-studio-2022-to-azure-devops-server-2020/
The script below is the safest, as it used the exact versions that were pushed to Azure DevOps service.
$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
}
}
Required agent version
You will need to install the most recent agent from the azure-pipelines-agent repository for it to auto-detect Visual Studio 2022, or alternatively add the capabilities to the agent manually.
You may need to force Azure DevOps Server to not downgrade back to its preferred agent version. You can do so by setting the following environment variable at the system level on your server before launching the agent:
AZP_AGENT_DOWNGRADE_DISABLED=true
These tricks will work for most tasks in the azure-pipelines-tasks repository, as long as it doesn't depend on a UI extension or service connection type that isn't available in your version of Azure DevOps Server.