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

2k Views Asked by At

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
2

There are 2 best solutions below

0
abatishchev On BEST ANSWER

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
1
Chris F Carroll On

I think that your dotnet restore task is not a dotnet restore but somehow an msbuild / NuGet restore?

In particular, from the last 20 lines of the log, I hypothesise that this error has nothing to do with this package, it's just that this package was the very first one it tried to restore, so this is where it errored and the real issue is more a variant on https://github.com/NuGet/Home/issues/4821 kind of thing.

Diagnostic step 1: change the build agent container to one without visual studio and see if that fixes the restore error.

I'm certainly confident that (1) the restore step is redundant for dotnet core toolchain and and (2) you must be using the dotnet core toolchain to build on your dev desktops?

So I think the issues in moving to Azure may be, (1) it isn't obvious how to build the right pipeline and (2) there may be some bugs in dotnet core/msbuild/nuget interactions.