The current .NET SDK does not support targeting .NET Standard 2.0 when targeting multiple platforms

Viewed 73

I have an existing Azure DevOps pipeline that was working fine, then stopped building with an error "The current .NET SDK does not support targeting .NET Standard 2.0". My initial thought is whether I should install .NET Standard 2.0 before the VSBuild task. I have a task "Use .NET Core sdk 5.x". Should I repurpose this or create a new "Use .NET Core sdk" task? If so, should the version be "2.1.x" to install netstandard2.0? We need to target multiple platforms such as

<TargetFrameworks>net45;net461;netcoreapp2.0;netstandard2.0;</TargetFrameworks>

yml:
  - task: NuGetToolInstaller@1
    displayName: Use NuGet 5.8.0
    inputs:
      versionSpec: 5.8.0
      checkLatest: true
  - task: NuGetInstaller@0
    name: NuGetInstaller_1
    displayName: NuGet restore **\*.sln
    inputs:
      solution: '**\*.sln'
      nugetConfigPath: .nuget/NuGet.Config
      nuGetVersion: 3.5.0.1829
  - task: UseDotNet@2
    displayName: Use .NET Core sdk 5.x
    inputs:
      version: 5.x
      performMultiLevelLookup: true
  - task: DotNetCoreCLI@2
    displayName: dotnet restore
    inputs:
      command: restore
      projects: '**/*.csproj'
      selectOrConfig: config
      nugetConfigPath: .nuget/NuGet.Config
  - task: VSBuild@1
    name: VSBuild_2
    displayName: Build solution **\*.sln
    inputs:
      platform: $(BuildPlatform)
      configuration: $(BuildConfiguration)
      clean: true
      msbuildArchitecture: x64
1 Answers

The current .NET SDK does not support targeting .NET Standard 2.0 when targetting multiple platform

To resolve this issue, you need to check the global.json file for your project, like below:

{
  "projects": [ "src", "test" ],
  "sdk": {
    "version": "2.1.301"
  }
}

Then you should install the specific SDK version instead of the Use .NET Core sdk 5.x.

  - task: UseDotNet@2
    displayName: Use .NET Core sdk 2.1.301
    inputs:
      version: 2.1.301
      performMultiLevelLookup: true
Related