How to add project reference to ASP.NET Core 1.0 M

2019-01-26 15:10发布

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?

1条回答
Deceive 欺骗
2楼-- · 2019-01-26 15:24

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.

查看更多
登录 后发表回答