Prabhasb
Prabhasb

Reputation: 3

Regardig Azure DevOps Msbuild task

We have a dedicated build server having visual studio 2019 installed on it. And We are using MSbuild task to compile the source code from this build server. Now, i have following questions:

  1. Do we really need visual studio installed on the build server to get the msbuild task to work?
  2. Is there any task available in azure devops market place which will install visual studio components on the fly and which will be used by msbuild task?

I think i didn't explained my requirement well in my post. my requirement is, the Azure DevOps build pipeline should install required visual studio build tools/compilers on the fly and they should be used by the msbuild task in the build pipeline. is this possible in Azure DevOps? so that i don't need to have visual studio installed on the build server.

Upvotes: 0

Views: 945

Answers (1)

jessehouwing
jessehouwing

Reputation: 114461

You can download the current version of the Build Tools from the Visual Studio Download site. That will install most compilers, sdks and toolkits to build your code. Some things do require full VS though, like the vstest task and gathering code coverage etc.

Manually installing the required .NET SDKs and possible other language frameworks you depend on will also do the trick, but there isn't one easy download link for that, in that case it all depends on the kind of solution you're building.

In most cases you'll still need a valid Visual Studio license, though if any of your team members own a Visual Studio Subscription, then you may install an extra copy of Visual Studio or the Build Tools on yous CI infrastructure.

enter image description here

You can download older versions of you have a Visual Studio Subscription:

enter image description here

I'm not aware of an extension that will do the installation in the workflow, the installation is still quite huge and downloads multiple additional components and may trigger a reboot requirement..

You can perform an unattended installation of the Build Tools. A sample PowerShell script can be found here:

function install-VS19BuildTools{
# add the workloads you want to install on your server

$AllArgs = "--quiet --add Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools --add Microsoft.VisualStudio.Workload.WebBuildTools --add Microsoft.VisualStudio.Workload.NetCoreBuildTools --add Microsoft.VisualStudio.Component.Windows10SDK.18362 --add Microsoft.Net.Component.4.7.TargetingPack --includeRecommended --wait"

$scriptRootPath = $PSScriptRoot
$vsToolsPath = Join-Path $scriptRootPath "vs_buildtools.exe"

$Result = Start-Process $vsToolsPath -ArgumentList $AllArgs -Wait
return $Result
}

install-VS19BuildTools

Microsoft uses a Packer script to provision the VHD for the Azure DevOps Hosted Agents. The scripts that build up the agent are shared to the public. The one that specifically install Visual Studio is here and here. You should be able to substitute the full visual studio installer with the build tools installer.

Upvotes: 1

Related Questions