.net-core - NU1100 : Unable to resolve 'System.Reflection.TypeExtensions (>= 4.5.1)' for '.NETStandard,Version=v1.3'

标签 .net-core azure-devops nuget .net-standard asp.net-core-cli

我正在尝试 to migrate我从 AppVeyor 到 Azure DevOps 的小型 OSS 项目几乎完成了所有工作,但现在 getting this errordotnet restore 步骤上:

NU1100: Unable to resolve 'System.Reflection.TypeExtensions (>= 4.5.1)' for '.NETStandard,Version=v1.3'.

尽管我清楚地看到System.Reflection.TypeExtensions支持 .NET 标准 1.3:

.NETStandard 1.3
    System.Reflection (>= 4.3.0)
    System.Resources.ResourceManager (>= 4.3.0)
    System.Runtime (>= 4.3.0)

我做错了什么?

更新: my YAML file看起来像这样:

trigger:
- master

pool:
  vmImage: 'windows-2019'

variables:
  solution: 'JWT.sln'
  buildConfiguration: 'Release'
  buildPlatform: 'Any CPU'
  dotNetVersion: '2.2.106'

steps:
- task: DotNetCoreInstaller@0
  displayName: Install .NET Core v$(dotNetVersion)
  inputs:
      version: $(dotNetVersion)

- task: DotNetCoreCLI@2
  displayName: 'Restore NuGet packages'
  inputs:
    command: 'restore'
    projects: '**/*.csproj'
    feedsToUse: config
    nugetConfigPath: NuGet.config

- task: DotNetCoreCLI@2
  displayName: 'Build solution'
  inputs:
    command: 'build'
    projects: '$(solution)'
    configuration: '$(buildConfiguration)'

- task: DotNetCoreCLI@2
  displayName: Run .NET Core tests
  inputs:
    command: 'test'
    projects: 'tests/**/JWT.Tests.Core.csproj'
    arguments: ' -c $(buildConfiguration) --no-build --no-restore'
    testRunner: VSTest
    testResultsFiles: '**/*.trx'
    testResultsFormat: 'xUnit'
    failTaskOnFailedTests: true

- task: DotNetCoreCLI@2
  displayName: Run .NET Framework tests
  inputs:
    command: 'test'
    projects: 'tests/**/JWT.Tests.NetFramework.csproj'
    arguments: ' -c $(buildConfiguration) --no-build --no-restore'
    testRunner: VSTest
    testResultsFiles: '**/*.trx'
    testResultsFormat: 'xUnit'
    failTaskOnFailedTests: true

- task: DotNetCoreCLI@2
  displayName: Package NuGet package
  inputs:
    command: pack
    packagesToPack: 'src/**/*.csproj'
    configuration: $(BuildConfiguration)
    nobuild: true

- task: PublishBuildArtifacts@1
  displayName: Publish build artifacts

更新 2:我尝试分别恢复 .NET Core 和 .NET Framework 的包,但没有成功:

  displayName: 'Restore NuGet packages for .NET Core'
  inputs:
    command: 'restore'
    projects: '**/*.csproj'
    feedsToUse: config
    nugetConfigPath: NuGet.config

- task: NuGetCommand@2
  displayName: 'Restore NuGet packages for .NET Framework'
  inputs:
    command: 'restore'
    restoreSolution: $(solution)
    feedsToUse: config
    nugetConfigPath: NuGet.config

- task: DotNetCoreCLI@2
  displayName: 'Build solution'
  inputs:
    command: 'build'
    projects: '$(solution)'
    configuration: '$(buildConfiguration)'

但有效的是显式恢复包的原始 MSBuild:

- task: MSBuild@1
  displayName: Build solution
  inputs:
    solution: $(solution)   
    msbuildArguments: /restore /t:build /p:CreatePackage=true /p:NoPackageAnalysis=true /p:PackageOutputPath=$(Build.ArtifactStagingDirectory)\artifacts
    configuration: $(BuildConfiguration)
    maximumCpuCount: true

最佳答案

我认为您的 dotnet 恢复任务不是 dotnet 恢复,而是某种 msbuild/NuGet 恢复?

特别是,从日志的最后 20 行来看,我假设这个错误与这个包无关,只是这个包是它尝试恢复的第一个包,所以这是它出错的地方,真正的问题更多是关于 https://github.com/NuGet/Home/issues/4821 的变体类似的东西。

诊断步骤 1:将构建代理容器更改为没有 visual studio 的容器,看看是否修复了还原错误。

我确信 (1) 恢复步骤对于 dotnet 核心工具链是多余的,并且 (2) 您必须使用 dotnet 核心工具链在您的开发桌面上构建?

所以我认为迁移到 Azure 的问题可能是,(1) 如何构建正确的管道并不明显,以及 (2) dotnet core/msbuild/nuget 交互中可能存在一些错误。

关于.net-core - NU1100 : Unable to resolve 'System.Reflection.TypeExtensions (>= 4.5.1)' for '.NETStandard,Version=v1.3' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56043733/

相关文章:

c# - Serilog 异步文件日志记录 - 如何添加滚动

uwp - 开发运维 : Error CS0234: The type or namespace name 'ApplicationModel' does not exist in the namespace 'Windows'

azure - 无法加载私有(private) Azure DevOps NuGet 源的源错误服务索引

c# - 为什么 nuget 安装一堆系统命名空间引用?

c# - 错误 : NU1100: Unable to resolve 'MicrosoftOfficeCore (>= 15.0.0)' for 'net5.0'

entity-framework - 为什么 EF Core 使用此存储过程总是返回 -1?

c# - 可空引用类型和 ToString() 重载

.net-core - .Net Core 3.1 可以在 Orange Pi Zero 上运行吗?

azure - 在 Azure Pipeline 中使用 terraform 进行 ArgoCD 引导

.net - Azure DevOps nuget 工件延迟