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



我正在使用ArtifactoryNuget@1任务从JFrog Artifactory恢复NugetPackages。我的 Azure DevOps 管道在一周前(2020 年 1 月 31 日(开始突然失败,原因是使用版本 2.1.14 还原项目 Microsoft.NetCore.App 其中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。

我试图从任务源代码中查看如何选择版本,但我认为这会进入 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(?

谢谢!

注意:标记的答案是该问题的非最佳解决方法,直到某些方法实际修复它。

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

因此,请确保Microsoft.NetCore.App version 2.1.15版本存在于Artifactory中。根据您的描述,似乎最新的补丁正在您的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> 

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

  • 如何解决 .net 核心生成错误NETDSDK1061和警告MSB3277
  • 独立部署运行时前滚

相关内容

最新更新