将Azure Pipelines与多目标项目一起使用时出现错误NETSDK1061

编程入门 行业动态 更新时间:2024-10-28 17:28:32
本文介绍了将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 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

本文发布于:2023-11-05 11:42:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1560747.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:出现错误   目标   项目   Azure   Pipelines

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!