3
votes

--Fixed it... Geez this stuff is Janky.
Microsoft link to explain what to do https://docs.microsoft.com/en-us/aspnet/core/migration/21-to-22?view=aspnetcore-2.2&tabs=visual-studio

I had to remove the version tag from the Microsoft.AspNetCore.All references in the csproj file.

<ItemGroup>
  <PackageReference Include="Microsoft.AspNetCore.All" **DELETE Version Version="2.2.0" />

--Edit 12/4 I I installed on my PC .netcore to 2.2, Now it fails the same. I didn't change a setting in my Project. I am specifying in my project settings to use 2.1 not 2.2. It appears in the YAML where i set the .netcore version is not applying.

- task: DotNetCoreInstaller@0
  displayName: 'Use .NET Core Tool Installer'
  inputs:
    version: 2.1.500

I am not sure what to do now.

-- I get following error when building in azure devops or publish from VS to an Azure app service. Visual Studio builds it fine.

(Restore target) -> 2018-12-04T01:30:44.4900171Z D:\a\1\s\cbw.services\cbw.mvc.services.csproj : error NU1202: Package Microsoft.AspNetCore.All 2.2.0 is not compatible with netcoreapp2.1 (.NETCoreApp,Version=v2.1). Package Microsoft.AspNetCore.All 2.2.0 supports: netcoreapp2.2 (.NETCoreApp,Version=v2.2)

My Build YAML

resources:
- repo: self
queue:
  name: Hosted VS2017
steps:
- task: DotNetCoreInstaller@0
  displayName: 'Use .NET Core Tool Installer'
  inputs:
    version: 2.1.500
- task: NuGetToolInstaller@0
  displayName: 'Use NuGet 4.9.1'
  inputs:
    versionSpec: 4.9.1
#- task: NuGetCommand@2
#  displayName: 'NuGet restore'
#  inputs:
#    restoreSolution: '***.sln'
#    feedsToUse: config
#    nugetConfigPath: 'NuGet.config'
#    externalFeedCredentials: <Name of the NuGet service connection>
- task: DotNetCoreCLI@2
  displayName: Restore
  inputs:
    command: restore
    projects: '**/*.sln'
    feedsToUse: config
    nugetConfigPath: NuGet.config
- task: DotNetCoreCLI@2
  displayName: Build
  inputs:
    projects: '**/*.sln'
    arguments: '--configuration $(BuildConfiguration)'
- task: DotNetCoreCLI@2
  displayName: Test
  inputs:
    command: test
    projects: '**/*Tests/*.csproj)'
    arguments: '--configuration $(BuildConfiguration)'
#- task: DotNetCoreCLI@2
#  displayName: Publish
#  inputs:
#    command: publish
#    publishWebProjects: True
#    arguments: 'release --output $(build.artifactstagingdirectory)'
- task: DotNetCoreCLI@2
  displayName: 'dotnet publish'
  inputs:
    command: 'publish'
    publishWebProjects: True
    projects:  '**/*.sln'
    arguments: release -o $(build.artifactStagingDirectory)
    zipAfterPublish: True
    modifyOutputPath: false
- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'
- task: AzureRmWebAppDeployment@3
  inputs:
    azureSubscription: 'Azure CBW Dev'
    WebAppName: 'cbwServicesDev'
    Package: $(System.artifactstagingdirectory)/**/*.zip 
1
the error suggests you need dotnet core 2.2 (not 2.1) on the build agent?4c74356b41
It looks like Asp Net Core 2.2.0 has alreade released in nuget. But .NET Core 2.2 has not yet released officially...Aries
@Aries I seem to recall they did the exact same thing for ASP.NET Core 2.1!Cocowalla

1 Answers

1
votes

You need to add the .NET Core SDK installer task to your build.

Edit: It needs to be the first task, or at least before any build task.

A good post by Scott Hanselman walks you through this problem.

enter image description here

enter image description here