9

How do I update my on-premise, Azure Devops Pipeline tasks to include the new MSBuild v17 and Visual Studio 2022 build tasks?

I found the updated MSBuild task here:
https://github.com/microsoft/azure-pipelines-tasks/tree/master/Tasks/MSBuildV1

I found the old MSBuild v16 task installed here:
C:\Program Files\Azure DevOps Server 2020\Tools\Deploy\TfsServicingFiles\Tasks\Individual\MSBuildV1\

What is the proper method to update this?

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
Nathan Goings
  • 1,145
  • 1
  • 15
  • 33

3 Answers3

4

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.

  1. 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.
  2. 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.

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
4

Until we can update our DevOps version itself, we installed Build Tools 2022 and set the msbuild path (instead of the version) in the build task settings:

MSBuild Location

Ian Horwill
  • 2,957
  • 2
  • 24
  • 24
-1

make sure your path is correct in the MSBuild.exe task. This will work 100%.

Path to MSBuilde => C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe

Platform => $(BuildPlatform)

Configuration => $(BuildConfiguration)

qaguru
  • 81
  • 2
  • 5
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/31385267) – Pierre P. Mar 30 '22 at 15:07