1
votes

I've started a new set of projects using VS 2015 and ASP.NET 5.

I'm experiencing problems with referencing certain nuget packages. For now I have issues referencing Autofac in the new AspNet 5 class library.

Adding "Autofac": "4.0.0-beta6-110" in project.json just gives me a yellow warning triangle in the references tree with a message saying "Errors - See Error List".

Looking into the Output gives me no errors. Building fails, the project gives me the following error:

Error The dependency Autofac >= 4.0.0-beta6-110 could not be resolved.

Worth knowing is that I've tested with different versions of Autofac so it might have resulted in some package cache hickups.

From an AspNet 5 Web project I also reference Autofac and that seems to work, but in the reference list, Autofac shows up as an ordinary reference (not nuget) showing Autofac 1.0.0 which is incorrect.

Is there anyway to clear dnx package cache? I've tried deleting the folder .dnx/packages without any results.

I can't see that I've done anything wrong inside my projects so there must be some other cause to this.

    {
  "version": "1.0.0-*",
  "description": "ProjectName Class Library",
  "authors": [ "author" ],
  "tags": [ "" ],
  "projectUrl": "",
  "licenseUrl": "",

  "dependencies": {
    "System.Collections": "4.0.10-beta-23019",
    "System.Linq": "4.0.0-beta-23019",
    "System.Threading": "4.0.10-beta-23019",
    "System.Runtime": "4.0.10-beta-23019",
    "Microsoft.CSharp": "4.0.0-beta-23019",
    "Autofac": "4.0.0-beta6-110"
  },

  "frameworks": {
    "dotnet": { }
  }
}

This is the error I get in the solution explorer:

Error message shown in class library

This is how it's getting presented in the web project (even though it uses Autofac 4.0)

enter image description here

1
Try clearing .dnx/packages (as you already mentioned) and project.lock.json files, then hit restore again. - Henk Mollema
Thanks, tried that but didn't work either :-( - honk
I wonder where Autofac 1.0.0 comes from, that's not even available on NuGet.. How does the project.json of your web app looks like? - Henk Mollema
I found out that my global.json was at least part of the issue. I've earlier referenced a .csproj project from asp.net 5. The .csproj project was wrapped and inside the wrap folder there was a reference to an old Autofac reference. I removed the global.json and the wrap folder and now the Autofac 1.0.0 issue is gone. Still has problem with the class library though - honk
Ah, you solved it. Targeting dnxcore50 works. Thank you! - honk

1 Answers

2
votes

Based on your comments, it looks like Autofac doesn't play nice with the dotnet Target Framework Moniker (TFM). Try targeting dnxcore50 in stead:

"frameworks": {
  "dnxcore50": { }
}