NU1100:无法为“ .NETStandard,Version = v1.3”解析“ System.Reflection.TypeExtensions(> = 4.5.1)”

时间:2019-05-08 15:05:03

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

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

  

NU1100:无法为'.NETStandard,Version = v1.3'解析'System.Reflection.TypeExtensions(> = 4.5.1)'。

尽管我清楚地看到System.Reflection.TypeExtensions支持.NET Standard 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

2 个答案:

答案 0 :(得分:0)

我认为您的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交互中可能存在一些错误。

答案 1 :(得分:0)

这是我的结局having working

trigger:
- master

pool:
  vmImage: 'windows-2019'

variables:
  solution: 'JWT.sln'
  buildConfiguration: 'Release'
  buildPlatform: 'Any CPU'
  coreVersion: '2.2.106'
  nugetVersion: '4.9.4'

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

- task: DotNetCoreCLI@2
  displayName: 'Restore NuGet packages for .NET Core'
  inputs:
    command: 'restore'
    projects: '**/*.csproj'

- task: NuGetToolInstaller@0
  displayName: Install NuGet v$(nugetVersion)
  inputs:
    versionSpec: $(nugetVersion)
    checkLatest: true

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

- task: DotNetCoreCLI@2
  displayName: 'Build solution'
  inputs:
    command: 'build'
    projects: '$(solution)'
    arguments: '-c $(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