Azure DevOps build throws error where localhost does not on .NET Core 2.2

New Contributor

I'm updating a backend of a website that's been running stable for the last 2 years. Some minor update has been asked which I got running on my localhost (about 5 lines of code update), but my devops build pipeline is throwing errors:

 

Package Microsoft.AspNetCore.Identity.EntityFrameworkCore 2.2.0 is not compatible with netcoreapp2.2 (.NETCoreApp,Version=v2.2). Package Microsoft.AspNetCore.Identity.EntityFrameworkCore 2.2.0 supports: netstandard2.0 (.NETStandard,Version=v2.0)
Package Microsoft.EntityFrameworkCore.SqlServer 2.2.4 is not compatible with netcoreapp2.2 (.NETCoreApp,Version=v2.2). Package Microsoft.EntityFrameworkCore.SqlServer 2.2.4 supports: netstandard2.0 (.NETStandard,Version=v2.0)
One or more packages are incompatible with .NETCoreApp,Version=v2.2.

 

 

I was expecting everything to work fine, considering I got it to work on my localhost.

I'm not too keen on updating everything to the latest version of .NET, because I really don't want to rewrite too much code that is working fine as is for an update of 5 lines of code.

 

Looks like the fail happens because of the NuGet package restore during my build, which is triggered by a task in yml. My yml file I'm building my project:

 

# ASP.NET Core
# Build and test ASP.NET Core projects targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/dotnet-core

name: $(Build.SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r)

trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/myprojectname.API.csproj'
  buildConfiguration: 'Release'

steps:
- task: UseDotNet@2
  displayName: 'Use .NET Core sdk'
  inputs:
    packageType: sdk
    version: 2.2.203
    installationPath: $(Agent.ToolsDirectory)/dotnet
    
    
- task: NuGetCommand@2
  inputs:
    command: 'restore'
    restoreSolution: '**/*.sln'
    feedsToUse: 'select'
    
- script: dotnet restore
- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'
    clean: true
- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'

 

How can I get the build to work again without having to upgrade to the latest version of .NET. or I also went through some reference websites like Microsoft or learn DevOps to get error fixed but did not come up with the results.

0 Replies