【问题标题】:NU1100: Unable to resolve 'System.Reflection.TypeExtensions (>= 4.5.1)' for '.NETStandard,Version=v1.3'NU1100:无法解析“.NETStandard,Version=v1.3”的“System.Reflection.TypeExtensions (>= 4.5.1)”
【发布时间】:2019-09-26 08:44:06
【问题描述】:

我正在尝试 to migrate 我的从 AppVeyor 到 Azure DevOps 的小型 OSS 项目,并且几乎完成了所有工作,但现在 getting this error 在 dotnet 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

【问题讨论】:

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


【解决方案1】:

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

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

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

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

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

【讨论】:

  • 我更新了我的问题,发布了我的 YAML 管道文件。第二步是运行 `dotnet restore,它失败了,这让我很困惑。
【解决方案2】:

这是我最后的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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多