Thursday, February 18, 2016

IEnumerable missing from platform 5.4 class lib

I was converting some code to use the new project templates for .net platform 5.4.  I love how it is setup for sharing by default by producing nuget packages.  I'll have to setup a private nuget server for my sharing code and I'll be sure to write about that when I get there.

Interestingly, the first couple projects I created had no minimal problems and I was able to produce nuget packages quite easily.  Yay.

This time around, however, I was refactoring out some models and interfaces for my web application and I ran in an interesting error...

The type 'IEnumerable<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

So, I'm thinking it must be some other error in the project, surely IEnumerable is in there somewhere, right?  WRONG!

Googling around found minimal information that was complete so I figured I'd put together the pieces.  This post got me in the right direction.

 Before:

 "frameworks": {
    "net451": {
      "dependencies": {
        "System.ComponentModel.Annotations": "4.0.0"
      }
    },
    "dotnet5.4": {
      "dependencies": {
        "Microsoft.CSharp": "4.0.1-beta-23516",
        "System.Collections": "4.0.11-beta-23516",
        "System.ComponentModel.Annotations": "4.0.11-beta-23516",
        "System.Linq": "4.0.1-beta-23516",
        "System.Runtime": "4.0.21-beta-23516",
        "System.Threading": "4.0.11-beta-23516"
      }
    }
  }

After:

  "frameworks": {
    "net451": {
      "dependencies": {
        "System.ComponentModel.Annotations": "4.0.0"
      },
      "frameworkAssemblies": {
        "System.Runtime": "4.0.10.0"
      }
    },
    "dotnet5.4": {
      "dependencies": {
        "Microsoft.CSharp": "4.0.1-beta-23516",
        "System.Collections": "4.0.11-beta-23516",
        "System.ComponentModel.Annotations": "4.0.11-beta-23516",
        "System.Linq": "4.0.1-beta-23516",
        "System.Runtime": "4.0.21-beta-23516",
        "System.Threading": "4.0.11-beta-23516"
      }
    }
  }

No comments:

Post a Comment