如何从kproj引用的csproj [英] How to reference csproj from kproj

查看:192
本文介绍了如何从kproj引用的csproj的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是用 VS2015 ASP.NET vNext 玩耍,并就死在尝试添加引用从vNext类库(kproj),以在相同的溶液定期类库(的csproj)。 Visual Studio的2015年显示了以下错误消息:

I was playing around with VS2015 and ASP.NET vNext, and got stuck on trying to add a reference from vNext class library (kproj) to a regular class library (csproj) in the same solution. Visual Studio 2015 shows the following error message:

下面的项目不支持作为参考。

"The following projects are not supported as references".

是否有可能在所有添加引用从vNext类库的csproj?

Is it possible at all to add references to csproj from vNext class libraries?

推荐答案

注:KPM命令已取代DNU。

Note: The kpm command has been replaced by dnu.

的Visual Studio 2015年preVIEW(写这篇文章)配备了ASP.NET 5稳定版β1的。在这个版本中有没有办法从ASP.NET项目5引用的csproj项目。

Visual Studio 2015 Preview (as of writing this) comes with the ASP.NET 5 stable release beta1. In this version there is no way to reference a csproj project from an ASP.NET 5 project.

不过,在ASP.NET 5命令的发展饲料KPM包装已推出了支持从ASP.NET项目5个引用的csproj项目。见GitHub的问题#827 在ASPNET / KRuntime库和的 pull请求#875 该关闭的问题。

However, on the development feed of ASP.NET 5 the command kpm wrap was introduced to support referencing csproj-projects from ASP.NET 5 projects. See the github issue #827 in the aspnet/KRuntime repository and pull request #875 which closes the issue.

下面是一个例子,你将如何使用 KPM包装

Here is an example how you would use kpm wrap:

确保 KRuntime的最新版本安装(我的版本测试了这个(与 KVM列表命令检查) 1.0.0-beta2-10709 )。

Make sure the newest version of the KRuntime is installed (check this with the kvm list command) (I tested this with version 1.0.0-beta2-10709).

创建ASP.NET 5类库项目,我使用的名称ClassLibrary1的。

Create an ASP.NET 5 class library project, I used the name ClassLibrary1.

创建一个正常的csproj类库,我命名为ClassLibrary2(确保你把这个src文件夹中)。

Create a "normal" csproj class library, I named this ClassLibrary2 (make sure you put this in the src folder).

从命令行,从 solutiondirectory 运行命令

KPM包装。\\ SRC \\ ClassLibrary2

这给出了输出:

Wrapping project 'ClassLibrary2' for '.NETFramework,Version=v4.5'
 Source C:\Users\andersns\Source\ClassLibrary1\src\ClassLibrary2\ClassLibrary2.csproj
   Target C:\Users\andersns\Source\ClassLibrary1\wrap\ClassLibrary2\project.json
   Adding bin paths for '.NETFramework,Version=v4.5'
     Assembly: ../../src/ClassLibrary2/obj/debug/ClassLibrary2.dll
     Pdb: ../../src/ClassLibrary2/obj/debug/ClassLibrary2.pdb

现在在ClassLibrary1的的project.json(这是ASP.NET 5),您可以参考,ClassLibrary2添加这个:

Now in the project.json of ClassLibrary1 (which is ASP.NET 5) you can add a reference to ClassLibrary2 with this:

...
"dependencies": {
    "ClassLibrary2": ""
},
...

请注意: KPM包装没有正确地为我用​​CMD运行,我需要推出PowerShell来使其运行。

Note: kpm wrap did not run properly for me with cmd, I needed to launch powershell to make it run.

这篇关于如何从kproj引用的csproj的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆