Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Devops - Hosted pool - ubuntu latest - How do i get ubuntu-latest to have the latest visual studio build tools (preview 2022)?

Our azure devops pipelines are configured to use hosted ubuntu-latest

vmImage: 'ubuntu-latest'

I am using Azure Functions that require the package: packages/microsoft.net.sdk.functions/4.0.0 The hosted ubuntu latest is throwing non compatible framework version error.

 /home/vsts/.nuget/packages/microsoft.net.sdk.functions/4.0.0/build/Microsoft.NET.Sdk.Functions.Build.targets(32,5):
 error : It was not possible to find any compatible framework version 
 /home/vsts/.nuget/packages/microsoft.net.sdk.functions/4.0.0/build/Microsoft.NET.Sdk.Functions.Build.targets(32,5):
 error : The framework 'Microsoft.NETCore.App', version
 '6.0.0-rc.1.21451.13' was not found.**

Azure devops error image

When changing the pool to run on an on premise build agent, I was able to install the latest build tools (the one that comes with visual studio 2022 preview) and everything works fine. My question is how do I get the ubuntu-latest to have the latest dotnet build tools?

This is the output of dotnet info of the ubuntu-latest agent.

2021-10-27T04:54:16.4629465Z .NET SDKs installed:
2021-10-27T04:54:16.4630372Z   2.1.302 [/usr/share/dotnet/sdk]
2021-10-27T04:54:16.4630865Z   2.1.403 [/usr/share/dotnet/sdk]
2021-10-27T04:54:16.4631327Z   2.1.526 [/usr/share/dotnet/sdk]
2021-10-27T04:54:16.4631821Z   2.1.617 [/usr/share/dotnet/sdk]
2021-10-27T04:54:16.4632292Z   2.1.701 [/usr/share/dotnet/sdk]
2021-10-27T04:54:16.4632746Z   2.1.818 [/usr/share/dotnet/sdk]
2021-10-27T04:54:16.4633218Z   3.1.120 [/usr/share/dotnet/sdk]
2021-10-27T04:54:16.4633687Z   3.1.202 [/usr/share/dotnet/sdk]
2021-10-27T04:54:16.4634147Z   3.1.302 [/usr/share/dotnet/sdk]
2021-10-27T04:54:16.4634616Z   3.1.414 [/usr/share/dotnet/sdk]
2021-10-27T04:54:16.4635086Z   5.0.104 [/usr/share/dotnet/sdk]
2021-10-27T04:54:16.4635541Z   5.0.208 [/usr/share/dotnet/sdk]
2021-10-27T04:54:16.4636008Z   5.0.303 [/usr/share/dotnet/sdk]
2021-10-27T04:54:16.4636462Z   5.0.402 [/usr/share/dotnet/sdk]
2021-10-27T04:54:16.4636703Z 
2021-10-27T04:54:16.4637082Z .NET runtimes installed:
2021-10-27T04:54:16.4637683Z   Microsoft.AspNetCore.All 2.1.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
2021-10-27T04:54:16.4638405Z   Microsoft.AspNetCore.All 2.1.5 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
2021-10-27T04:54:16.4639112Z   Microsoft.AspNetCore.All 2.1.12 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
2021-10-27T04:54:16.4639839Z   Microsoft.AspNetCore.All 2.1.24 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
2021-10-27T04:54:16.4640553Z   Microsoft.AspNetCore.All 2.1.30 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
2021-10-27T04:54:16.4641691Z   Microsoft.AspNetCore.App 2.1.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
2021-10-27T04:54:16.4642420Z   Microsoft.AspNetCore.App 2.1.5 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
2021-10-27T04:54:16.4643130Z   Microsoft.AspNetCore.App 2.1.12 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
2021-10-27T04:54:16.4643823Z   Microsoft.AspNetCore.App 2.1.24 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
2021-10-27T04:54:16.4644541Z   Microsoft.AspNetCore.App 2.1.30 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
2021-10-27T04:54:16.4645263Z   Microsoft.AspNetCore.App 3.1.4 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
2021-10-27T04:54:16.4645958Z   Microsoft.AspNetCore.App 3.1.6 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
2021-10-27T04:54:16.4646889Z   Microsoft.AspNetCore.App 3.1.20 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
2021-10-27T04:54:16.4647598Z   Microsoft.AspNetCore.App 5.0.4 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
2021-10-27T04:54:16.4648286Z   Microsoft.AspNetCore.App 5.0.9 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
2021-10-27T04:54:16.4648995Z   Microsoft.AspNetCore.App 5.0.11 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
2021-10-27T04:54:16.4649693Z   Microsoft.NETCore.App 2.1.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
2021-10-27T04:54:16.4650357Z   Microsoft.NETCore.App 2.1.5 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
2021-10-27T04:54:16.4651045Z   Microsoft.NETCore.App 2.1.12 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
2021-10-27T04:54:16.4651737Z   Microsoft.NETCore.App 2.1.24 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
2021-10-27T04:54:16.4652407Z   Microsoft.NETCore.App 2.1.30 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
2021-10-27T04:54:16.4653101Z   Microsoft.NETCore.App 3.1.4 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
2021-10-27T04:54:16.4653781Z   Microsoft.NETCore.App 3.1.6 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
2021-10-27T04:54:16.4654445Z   Microsoft.NETCore.App 3.1.20 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
2021-10-27T04:54:16.4655124Z   Microsoft.NETCore.App 5.0.4 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
2021-10-27T04:54:16.4655799Z   Microsoft.NETCore.App 5.0.9 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
2021-10-27T04:54:16.4656459Z   Microsoft.NETCore.App 5.0.11 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
2021-10-27T04:54:16.4656807Z 
like image 608
Pazza22 Avatar asked Mar 01 '23 10:03

Pazza22


1 Answers

use this in your pipeline definition:

- task: UseDotNet@2
  displayName: 'Use .NET Core sdk'
  inputs:
    version: 6.0.x
    includePreviewVersions: true

To explain, firstly Visual Studio only runs on Windows, so you can't install Visual Studio on Linux, but that's fine because you actually only want the .NET SDK. Secondly, both Visual Studio 2022 and .NET 6 are in preview.

Next, Azure DevOps have documented what software is pre-installed on all their hosted agents: https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops&tabs=yaml#software

If you follow the link to .NET Core SDK on Ubuntu 20.04 (latest), you see that they only pre-install Generally Available (GA; released) versions of the .NET SDK, not preview versions. After all, most customers building their production applications don't want the risk of using preview tools that might have bugs and break their builds.

So, if you want a preview .NET SDK, you need to explicitly install it as part of your build steps. The UseDotNet task does that, allowing you to specify a bunch of parameters, but in this case the most important two are version and include preview versions.

For other scenarios, for example anyone not using Azure Pipelines, the .NET team also have dotnet-install scripts, which you can download and execute in your pipeline.

For what it's worth, .NET 6 is having a launch party on the 9th to the 11th of November, and Visual Studio 2022 is having a launch event on the 8th of November. I don't know how quickly Azure DevOps will update their VM images with the newly released tools, but I guess it will be within days, so installing preview tooling in your build scripts won't be needed for much longer, unless you want to keep using preview tools. Note that once .NET 6 SDK's 6.0.100 goes GA, then the script that installs preview 6.0.x tooling will start installing the preview 6.0.200 previews

like image 100
zivkan Avatar answered Mar 04 '23 00:03

zivkan