AndrewC
AndrewC

Reputation: 461

AutoMapper NU1001 fx/ dependency errors in a .NET Platform 5.4 Library

I am a new developer working with ASP.NET 5 (ASP.NET Core). In VS2015 I created a new class library project targeting .NET Platform 5.4 (dotnet5.4), and added the AutoMapper NuGet package, version 4.2.0.

I am getting the following errors, basically for all the System packages:

3>C:\Users\Andrew\OneDrive\Development\Visual Studio\APT\src\Fideles.Service\project.json : .NET Platform 5.4 error NU1001: The dependency fx/Microsoft.CSharp could not be resolved. 3>C:\Users\Andrew\OneDrive\Development\Visual Studio\APT\src\Fideles.Service\project.json : .NET Platform 5.4 error NU1001: The dependency fx/System.Collections could not be resolved. 3>C:\Users\Andrew\OneDrive\Development\Visual Studio\APT\src\Fideles.Service\project.json : .NET Platform 5.4 error NU1001: The dependency fx/System.Collections.Concurrent could not be resolved.

But I think according to the NuGet package description it should be supported: https://www.nuget.org/packages/AutoMapper/

As you can see from the screenshot these packages seem to be referenced twice; once correctly and once incorrectly with an fx/ prefix:

enter image description here

This is my project.json:

{
  "version": "1.0.0-*",
  "description": "Fideles.Services Class Library",
  "authors": [ "Andrew" ],
  "tags": [ "" ],
  "projectUrl": "",
  "licenseUrl": "",
  "frameworks": {
    "dotnet5.4": {
      "dependencies": {
        "Microsoft.CSharp": "4.0.1-beta-*",
        "System.Collections": "4.0.11-beta-*",
        "System.Linq": "4.0.1-beta-*",
        "System.Runtime": "4.0.21-beta-*",
        "System.Threading": "4.0.11-beta-*"
      }
    }
  },
  "dependencies": {
    "AutoMapper": "4.2.0",
    "Fideles.Common": "1.0.0-*",
    "Fideles.Data": "1.0.0-*"
  }
}

Any ideas? Thank you!

Upvotes: 1

Views: 968

Answers (2)

Devon Burriss
Devon Burriss

Reputation: 2532

If you don't mind interrupting your Visual Studio workflow you can get your application to build by doing the following.

  1. Make sure you have the new dotnet CLI installed (https://dotnet.github.io/getting-started/)
  2. Run dotnet restore from the command line in your project folder

This sorted out the the build errors. I then deleted my lock files and ran Clean and Rebuild on the solution for good measure.

Upvotes: 1

Damien Dennehy
Damien Dennehy

Reputation: 4064

The issue is that dotnet5.4 isn't supported by AutoMapper 4.2.0. Depending on what you're targeting it may be possible to change dotnet5.4 to something else (dnxcore50 for example).

I have the same issue on a number of my own libraries and I'm waiting for netstandard to take care of all this.

Upvotes: 1

Related Questions