mu88
mu88

Reputation: 5384

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'

Upvotes: 12

Views: 9457

Answers (1)

Levi Lu-MSFT
Levi Lu-MSFT

Reputation: 30333

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'

Upvotes: 13

Related Questions