The complete error is here:
Error : NETSDK1061: The project was restored using Microsoft.NETCore.App version 1.0.0, but with current settings, version 2.2.0 would be used instead.
To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish.
Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore.
For more information, see https://aka.ms/dotnet-runtime-patch-selection.
Locally everything looks just fine, but on Azure it does not want to compile. All the proposed solutions that I have found online did not help, including:
- script: dotnet restore
- setting the <RuntimeFrameworkVersion>2.2.104</RuntimeFrameworkVersion> to the version I use.
- setting the <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
Below is a part of the yaml file:
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: 'src/MySolution.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@0
inputs:
versionSpec: '4.3.0'
- task: DotNetCoreInstaller@0
inputs:
packageType: 'sdk'
version: '2.2.104'
- script: dotnet restore $(solution)
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild@1
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
msbuildArchitecture: 'x64'
The project file contains the following:
<PropertyGroup>
<TargetFrameworks>netcoreapp2.2;net45</TargetFrameworks>
<LangVersion>latest</LangVersion>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
</PropertyGroup>