40

Yes, I know .NET Core 3.0 is still in preview. I would like to build this on Azure Pipelines.

Is there an easy way to do this?

Currently getting this error:

/usr/share/dotnet/sdk/2.2.105/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.TargetFrameworkInference.targets(137,5): error NETSDK1045: The current .NET SDK does not support targeting .NET Core 3.0. Either target .NET Core 2.2 or lower, or use a version of the .NET SDK that supports .NET Core 3.0.

edit

I found official documentation about this:

https://learn.microsoft.com/en-us/azure/devops/pipelines/languages/dotnet-core?view=azure-devops

KoalaBear
  • 2,755
  • 2
  • 25
  • 29
  • 1
    Update: It is now 3 weeks after core 3.0 release, and Azure (DevOps) Pipelines haven't been updated with core 3.0 build support. And the "UseDotNet@2" task won't install core 3.0 unless you check "includePreviewVersions". – yzorg Oct 17 '19 at 16:02

7 Answers7

50

You can install the .Net core SDK 3.0 during the pipeline with .Net Core SDK Installer task:

- task: UseDotNet@2
  displayName: 'Install .net core 3.0 (preview)'
  inputs:
    packageType: sdk
    version: '3.0.100-preview6-012264'
    installationPath: $(Agent.ToolsDirectory)/dotnet

I specified the last preview version of .net core sdk 3.0, you can put an earlier version, you can find here the versions list.

Another option is to specify 3.0.x and enable the preview versions:

version: 3.0.x
includePreviewVersions: true

Installation results:

enter image description here

Shayki Abramczyk
  • 36,824
  • 16
  • 89
  • 114
  • 3
    Cool, you were one second before me. This is indeed the best solution, the most recent version can be found here: https://dotnetcli.blob.core.windows.net/dotnet/Sdk/master/latest.version – Robin Krom Jun 13 '19 at 06:17
  • 1
    Important note: There is a version selector for the build task in DevOps pipelines. I did not have the latest version of the task selected (did not realise they tasks are versioned, nice feature). There is an info that specified the task version I had selected would not work with latest versions of .net core. I also could not see the include preview option. Changing the version of the task showed more options and the warning disappeared. – Stephen Price Oct 04 '19 at 23:47
  • How did you edit the .yml file here? I can't seem to find an option via the UI ? – Azy Sır Oct 25 '19 at 03:37
  • @AzySır what do you mean? – Shayki Abramczyk Oct 25 '19 at 04:53
  • What does the @2 mean on the end of UseDotNet ? – Daniaal Dec 18 '19 at 10:48
  • @Daniaal It's the task version, currently has 0, 1 and 2 – Shayki Abramczyk Dec 19 '19 at 08:35
  • @ShaykiAbramczyk Ahh, thank you. I was thinking it was a version of .Net Core. I tried searching the docs but could not find anything. – Daniaal Dec 19 '19 at 10:22
16

You can get the latest .NET Core 3 SDK by supplying 3.x instead of a specific version. Also note includePreviewVersions: true, which is required to make this work.

- task: UseDotNet@2
  displayName: 'Use dotnet sdk 3.x'
  inputs:
    version: 3.x
    includePreviewVersions: true

And you'll end up with something like this:

enter image description here

Source: .NET Core Tool Installer task

Travis Troyer
  • 730
  • 6
  • 9
  • Yep this is the way to go - yes you can build from a 3.0-previewX SDK image, but downloading and setting up the container image added another 60 seconds to the build process. – alv Aug 08 '19 at 11:20
  • Which build agent would you use for this? – johnstaveley Sep 23 '19 at 07:21
11

In case someone is using Web GUI instead of yaml files. It's possible to set up Agent Specification with windows-2019 value.

enter image description here

Such steps as dotnet test will start using .Net Core 3.0:

enter image description here

Evgenii Kosiakov
  • 545
  • 12
  • 21
  • 2
    I can't find how you do this? I have an Azure hosted agent. Never mind, found it! It's found if you edit the build step where you choose Agent pool. Thanks! – carl-johan.blomqvist Oct 21 '19 at 13:05
  • 1
    When you edit the pipeline, select "Pipeline". It's the top item, above "Get sources" and the "Agent" header. – gregsdennis Jun 06 '20 at 02:10
6

You can also install the SDK via the "old" Pipeline editor. Add a new task and search for the ".NET Core SDK Installer." Then switch the version at the top to the latest preview version and it will offer you more options, like the "Include Preview Versions" check box. You'll still have to type in the version you want manually.

Screenshot of my task:

vezunchik
  • 3,669
  • 3
  • 16
  • 25
1

You can specify .net core SDK version with the .NET Core Tool Installer Task. But I dont think it allows 3.0 yet apparently it does, so you probably need to create a container with 3.0 and use that as a build environment. That would work.

https://learn.microsoft.com/en-us/azure/devops/pipelines/process/container-phases?view=azure-devops&tabs=yaml

sample yaml:

resources:
  containers:
  - container: inflation
    image: yyy
    endpoint: xxx

jobs:
- job: inflate_infrastructure
  container: inflation << has to match the container name above
  pool:
    vmImage: 'Ubuntu-16.04'
  steps:
  - zzz

4c74356b41
  • 69,186
  • 6
  • 100
  • 141
1

I use .net core 2.2 but, it released .net core 3.0 preview 6 yesterday. you can use config below. I suggest inspecting release-metadata serves.

steps:
- task: UseDotNet@2
  displayName: 'Use .NET Core sdk'
  inputs:
    packageType: sdk
    version: 3.0.0-preview5
    installationPath: $(Agent.ToolsDirectory)/dotnet
Zhaph - Ben Duguid
  • 26,785
  • 5
  • 80
  • 117
1

You can add task Use .NET Core and insert needed version in Version field like this 3.0.100-preview9-014004, mark Include Preview Versions as checked.

Execute this task before any other .NET Core tasks.

A. Gladkiy
  • 3,134
  • 5
  • 38
  • 82