为什么要针对旧的Microsoft.NetCore.App版本还原ArtifactoryNuget @ 1管道任务?

问题描述 投票:0回答:1

我正在使用ArtifactoryNuget @ 1任务从JFrog Artifactory恢复NugetPackages。我的Azure DevOps管道在一周前(2020年1月31日)开始突然失败,原因是使用Microsoft.NetCore.App 2.1.14版还原了人工任务,其中DotNetCoreCLI @ 2任务在使用2.1.15版后进行了还原。

我从DotNetCoreCLI @ 2任务中得到的实际错误是:NETSDK1061: The project was restored using Microsoft.NETCore.App version 2.1.14, but with current settings, version 2.1.15 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.

我正在为.Net Core部署项目进行自包含部署,因此已经为此项目文件进行了设置。

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
    <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
  </PropertyGroup>
  ...

管道的配置如下:

- task: ArtifactoryNuGet@1
  inputs:
    command: 'restore'
    artifactoryService: 'xxxx'
    solutionPath: 'xxxx.sln'
    targetResolveRepo: nuget

- task: DotNetCoreCLI@2
  inputs:
    command: 'build'
    projects: xxxx.csproj'
    arguments: '--configuration Release --runtime win10-x64 --no-restore 

以前,一切工作都很好,但是现在我无法获得在Azure DevOps(本地生成作品)中正确生成解决方案的解决方案。我最好的猜测是DevOps管道计算机已使用2.1.15运行时进行了更新,但是JFrog ArtifactoryNuget任务由于某些原因无法利用,最终使用2.1.14。

我试图从task source code中查看如何选择版本,但我认为这涉及Nuget内部。我也尝试使用<RuntimeFrameworkVersion>显式设置它,但是这导致ArtifactoryNuGet @ 1任务甚至使用旧版本2.1.1。 nuget存储库本身是一个虚拟存储库,结合了nuget.local和nuget.remote。

问题:

  • 为什么突然断了?是因为Azure管道计算机中的版本更新还是其他原因?
  • 如果使用“ TargetLatestRuntimePatch”时其他任务使用2.1.15,为什么ArtifactoryNuGet @ 1会获得2.1.14版本?
  • 是否有错误消息所建议的为ArtifactoryNuGet @ 1任务指定运行时标识符(例如win10-x64)?

谢谢!

.net-core azure-devops nuget artifactory
1个回答
0
投票

通常,在项目文件中将TargetLatestRuntimePatch设置为true时,它将要求安装最新的补丁。

因此,请确保Artifactory中存在版本Microsoft.NetCore.App version 2.1.15。根据您的描述,您的JFrog Artifactory服务似乎最新的补丁是version 2.1.14

如果您遇到这种情况,请尝试此:

<PropertyGroup>
   <TargetFramework>netcoreapp2.1</TargetFramework>
   <RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
   <RuntimeFrameworkVersion>2.1.14</RuntimeFrameworkVersion>
</PropertyGroup>

<ItemGroup>
   <PackageReference Update="Microsoft.NETCore.App" Version="2.1.14" />
</ItemGroup> 

如果不起作用,请参考下面的链接以进行进一步的故障排除:

© www.soinside.com 2019 - 2024. All rights reserved.