4

Thanks in advance for your help, I appreciate it! I am looking for some direction on successfully referencing a normal (Non-ASP NET) Class Library FROM an ASP.NET 5 project and have it successfully publish. The catch is that the Class Library uses references to packages brought in from Nuget.

Here are the details and how to reproduce:

  1. New ASP.NET 5 Solution and Website.
  2. Change reference to dnx46
  3. Remove dnxcore.
  4. Add a new Class Library and target .NET 4.6.
  5. Add a nuget package to the Class Library (For Example, add EntityFramework 6.1.3)
  6. Issue Command "dnu wrap .
  7. Add the dependency to the the web project.json:

    "frameworks": { "dnx46": { "dependencies": { "ClassLibrary": "1.0.0-*" } } }

  8. At this point, we have the "ClassLibrary" "wrapped" in the "wrap" folder.

  9. The solution and project starts up without an issue, all dependencies are found and resolved. Everything compiles and it runs on IIS Express without issue.

Now if you try and perform a "Local Publish" to deploy to IIS, it will complain that the reference to "EntityFramework 6.1.3" found within the "wrap" project.json cannot be resolved.

After trying this out multiple ways, I think it's because the "EntityFramework" DLL from the nuget packages folder never officially gets wrapped. Somehow this doesn't cause an issue when running on IIS Express but causes an issue when publishing. Although I've used "EntityFramework" as an example, you could have used any reference from Nuget.

Has anyone experienced this before, and if so, how did you resolve it?

Erik Funkenbusch
  • 92,674
  • 28
  • 195
  • 291
MBeutel
  • 41
  • 2
  • Were you ever able to overcome this? – Josh Schultz Dec 02 '15 at 05:05
  • possibly related: http://stackoverflow.com/questions/34079129/asp-net5-dnx-unable-to-resolve-reference-when-published-but-can-debug#comment56014468_34079129 – qbik Dec 08 '15 at 04:14
  • Yes, I was finally able to overcome this. For some reason, the project.jsons created in the "wrap" folder by the referenced assemblies had the "frameworks" reference to net46. For some reason this worked no problem when running from Visual Studio but failed during publishing. The fix, or workaround, that I found was that I had to change the entry in the project.json file created for the wrapped assembly to "dnx46". I do not know why this worked, nor if it is truly a bug, but it allowed us to publish our ASP.NET 5 Websites which referenced .NET 4.6 assemblies. – MBeutel Dec 09 '15 at 11:37

0 Answers0