Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install several .NET Core SDK versions on Azure Devops

Is it possible to install multiple versions of the .NET Core SDK using azure-pipelines.yml on Azure DevOps? If yes, how can I do so?

I'm trying to build a Blazor Server App using ElectronNET. On my local machine, I can run electronize build /target win without any problems. But when running the build on Azure DevOps, it fails with the following error:

The specified framework 'Microsoft.NETCore.App', version '2.2.0' was not found.
  - The following frameworks were found:
      3.0.0-preview7-27912-14 at [/opt/hostedtoolcache/dotnet/shared/Microsoft.NETCore.App]

My azure-pipelines.yml looks like this:

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: DotNetCoreInstaller@0
  displayName: Install .NET Core 2.2 SDK
  inputs:
    packageType: 'sdk'
    version: '2.2.401'

- script: |
    dotnet tool install ElectronNET.CLI -g
  displayName: 'Install global tool ElectronNET.CLI'

- task: DotNetCoreInstaller@0
  displayName: Install Latest .NET Core 3.0 SDK
  inputs:
    packageType: 'sdk'
    version: '3.0.100-preview7-012821'

- script: |
    cd MyProject
    electronize build /target win
  displayName: 'Build Windows app with ElectronNET'
like image 639
mu88 Avatar asked Aug 09 '19 11:08

mu88


1 Answers

I tested with your pipeline yaml and found azure task DotNetCoreInstaller@0 would override the previously installed dotnet core sdk. I replaced DotNetCoreInstaller@0 with task UseDotNet@2 to install the both versions of the dotnet core sdks, and the error was gone.

steps:
- task: UseDotNet@2
  displayName: Install .NET Core 2.2 SDK
  inputs:
    packageType: 'sdk'
    version: '2.2.401'
like image 140
Levi Lu-MSFT Avatar answered Oct 21 '22 21:10

Levi Lu-MSFT