.net-coreazure-devopsnuget.net-standardasp.net-core-cli

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


I'm trying to migrate my small OSS project from AppVeyor to Azure DevOps and got almost everything done but now getting this error on the dotnet restore step:

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

Spite I clearly see that System.Reflection.TypeExtensions supports .NET Standard 1.3:

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

What I'm doing wrong?

Update: my YAML file looks like this:

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

Update 2: I tried to restore packages for .NET Core and .NET Framework separately but it didn't work:

  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)'

What works though is raw MSBuild which restores packages explicitly:

- 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

Solution

  • Here's I ended up 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