将Azure Pipelines与多目标项目一起使用时出现错误NETSDK1061 [英] Using Azure Pipelines with multi targeting projects I get error NETSDK1061

查看:101
本文介绍了将Azure Pipelines与多目标项目一起使用时出现错误NETSDK1061的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

完整的错误在这里:

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上,它不想进行编译. 我在网上找到的所有建议的解决方案都无济于事,包括:

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>

以下是yaml文件的一部分:

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>

推荐答案

不久前,我遇到了同样的问题,我注意到的一件事是,用于还原软件包的nuget版本已固定为4.3.0(I认为这是默认建议).我尝试使用这样的更新版本:

I had the same problem not so long ago and one thing that I noticed was that the nuget version used to restore the packages was fixed to 4.3.0 (I think it was a default suggestion). I tried to use a newer version like this:

- task: NuGetToolInstaller@0
  inputs:
    versionSpec: '>=4.3.0'
    checkLatest: true

更改后,构建已修复.在日志中,我注意到正在使用版本5.2.0,尽管在本地我只能获得版本5.1.0(带有"nuget update -self").

After the change, the build was fixed. In the logs I noticed that the version 5.2.0 was being used, although locally I could get only the version 5.1.0 (with 'nuget update -self').

这篇关于将Azure Pipelines与多目标项目一起使用时出现错误NETSDK1061的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆