6

I have a ASP.NET Core 1.0 MVC app in solution X and I have some common projects (.net 4.5.2 class libs) in solution Y.

I want to reference the projects in solution Y from my app, when I do so via add reference -> Browse .. I get:

.NET Core projects only support referencing .NET framework assemblies in 
this release. To reference other assemblies, 
they need to be included in a NuGet package and reference that package.

I then created a nuget package of those projects, added the folder that contains the nuget packages as a repo source and loaded the projects. This adds the projects successfully to my project.json, but 'nothing' else actually happens, I still can't use the code in my app.

Now ASP.NET Core is past its beta status, what is the official way of dealing with this?

user2713516
  • 2,983
  • 5
  • 23
  • 49
  • Are you targeting full .NET Framework or .NET Core? What's your project.json? – Tseng Jun 29 '16 at 18:48
  • I'm using the full .NET framework (net452) – user2713516 Jun 30 '16 at 05:53
  • Is the NuGet method the way to go for the future, or just temporary until they sort things out? we're using NancyFX right now, I was thinking about trying .NET Core but this is such a major turn off, I'm not sure it's work the effort – Thomas Dec 24 '16 at 23:22

1 Answers1

0

Many people have struggled with this issue and there is a long running thread on GitHub about it. Even the people using the latest RC3 build are reporting the same problem that you are having.

The only way I've been able to reference class library projects in an ASP.NET Core web application is to create both the web application and the class library projects in Visual Studio 2015 Update 2. And they all have to target .NET Framework 4.6.1.

I had to copy the code from my old class library projects to the new ones. But in the end I think I saved myself time by not having to mess with all the workarounds that don't seem to work for a lot of people.

Clint B
  • 4,610
  • 2
  • 18
  • 22
  • Ok, it's a (not so great) workaround. However, it would be nice if you could analyze it further by doing a DIFF between the old project and a the new to narrow it to the specific part or parts of the project that actually need to change to fix the problem. At the very least, post the DIFF (or a link to it) here so others can try to work it out. – NightOwl888 Jun 29 '16 at 21:24
  • I can't go higher than .net 4.5.2. because I also have a Azure Cloud Service project (that references the common projects) that limits the version to 4.5 – user2713516 Jun 30 '16 at 06:07
  • I tried changing the projects and webapp to 461 (and I created the projects in an update 3 solution but that didn't change anything for me... – user2713516 Jun 30 '16 at 06:18
  • @user2713516 - I haven't installed update 3 because my stuff is working and I don't want to take the chance of anything breaking. I've been struggling with this issue for 10 months and none of the workarounds I read about worked for me. Since update 2 came out at the same time as RC2, I'm thinking they go together. – Clint B Jun 30 '16 at 07:45
  • @NightOwl888 - Since RC2 was a major change and RC2 required you to install update 2, I'm thinking there were major changes that go far beyond the project files. For that reason I never considered trying to figure out why it works and I don't intend to. I've wasted so much time on this issue, I was happy just to have something working. – Clint B Jun 30 '16 at 07:51
  • What I did as a workaround before RC2 was to put the code that I needed from my old class libraries into a Web API 2 project. At least then I could continue development on my ASP.NET Core applications while waiting for full framework dll support. – Clint B Jun 30 '16 at 07:56
  • Thanks for the comments so far, I feel you in that I also have spend crazy time on asp.net vnext working with all kinds of workarounds. I've learned my lesson and won't be handling any 'beta' code soon unless its purely for fun. – user2713516 Jun 30 '16 at 10:31