Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use "old" dependencies with ASP.NET 5

Tags:

asp.net-core

I've created a new project using a clean install of VS 2015 Enterprise RC1, and I'm trying to add a Nuget package for Mandrill which is built against .NET 4.

When I build the project i get an error from DNX Core 5.0 that the namespace cannot be found:

All packages are already installed and there is nothing to restore.
NuGet package restore finished.
1>------ Build started: Project: WebApplication3, Configuration: Debug Any CPU ------
1>C:\Projects\WebApplication3\src\WebApplication3\MessageServices.cs(5,7,5,15): DNX Core 5.0 error CS0246: The type or namespace name 'Mandrill' could not be found (are you missing a using directive or an assembly reference?)
1>
1>  Build failed.
1>           0 Warning(s).
1>           1 Error(s).
1>
1>  Time elapsed 00:00:00.1404086
1>
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========

Rather than add as a global dependency, I've tried to add it just to the dnx451 framework within project.json, with the same result.

"frameworks": {
    "dnx451": {
        "dependencies": {
            "Mandrill": "1.3.1"
        }
    },
    "dnxcore50": { }
},

Is it even possible to use .NET 4 packages with ASP.NET 5? If so, what's required?

like image 688
mattdwen Avatar asked Apr 30 '15 23:04

mattdwen


1 Answers

Probably the Mandrill package doesn't support CoreCLR. You have two options:

  1. Remove support for CoreCLR from your package by removing the dnxcore50 section in project.json
  2. Use conditional compilation and exclude the calls to the Mandrill api. Example: #if DXNCORE50 ... or #if DNX451
like image 78
Victor Hurdugaci Avatar answered Nov 15 '22 11:11

Victor Hurdugaci