完整的错误在这里:
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.
在本地,一切看起来都很好,但是在Azure上它不想编译。 我在网上找到的所有建议解决方案都无济于事,包括:
- script: dotnet restore
- setting the <RuntimeFrameworkVersion>2.2.104</RuntimeFrameworkVersion> to the version I use.
- setting the <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
以下是yaml文件的一部分:
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'
项目文件包含以下内容:
<PropertyGroup>
<TargetFrameworks>netcoreapp2.2;net45</TargetFrameworks>
<LangVersion>latest</LangVersion>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
</PropertyGroup>
答案 0 :(得分:1)
不久前我遇到了同样的问题,我注意到的一件事是,用于还原软件包的nuget版本已固定为4.3.0(我认为这是默认建议)。我试图使用这样的更新版本:
- task: NuGetToolInstaller@0
inputs:
versionSpec: '>=4.3.0'
checkLatest: true
更改后,构建已修复。在日志中,我注意到正在使用版本5.2.0,尽管在本地我只能获得版本5.1.0(带有“ nuget update -self”)。