如何向ASP.NET Core 1.0 MVC项目添加项目引用

时间:2022-11-13 07:33:27

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.

我在解决方案X中有一个ASP.NET Core 1.0 MVC应用程序,我在解决方案Y中有一些常见的项目(.net 4.5.2类库)。

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

我想从我的应用程序中引用解决方案Y中的项目,当我这样做时通过添加引用 - >浏览..我得到:

.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.

然后我创建了这些项目的nuget包,添加了包含nuget包作为repo源的文件夹并加载了项目。这会将项目成功添加到我的project.json中,但实际上“没有”实际发生,我仍然无法在我的应用程序中使用该代码。

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

现在ASP.NET Core已经过了beta版状态,处理这个问题的官方方式是什么?

1 个解决方案

#1


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.

许多人都在努力解决这个问题,GitHub上有一个长期运行的线程。即使是使用最新RC3版本的人也报告了您遇到的同样问题。

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.

我能够在ASP.NET Core Web应用程序中引用类库项目的唯一方法是在Visual Studio 2015 Update 2中创建Web应用程序和类库项目。它们都必须以.NET Framework 4.6为目标0.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.

我不得不将旧的类库项目中的代码复制到新的类库项目中。但最后我认为我没有浪费所有似乎对许多人都没有用的解决方法,从而节省了自己的时间。

#1


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.

许多人都在努力解决这个问题,GitHub上有一个长期运行的线程。即使是使用最新RC3版本的人也报告了您遇到的同样问题。

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.

我能够在ASP.NET Core Web应用程序中引用类库项目的唯一方法是在Visual Studio 2015 Update 2中创建Web应用程序和类库项目。它们都必须以.NET Framework 4.6为目标0.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.

我不得不将旧的类库项目中的代码复制到新的类库项目中。但最后我认为我没有浪费所有似乎对许多人都没有用的解决方法,从而节省了自己的时间。