简体   繁体   English

如何将.NET类库的引用添加到vNext项目

[英]How to add a reference of a .NET class library to a vNext Project

I have an ASP.Net 5 project in which I wish to reference a number of .Net class libraries. 我有一个ASP.Net 5项目,我希望在其中引用一些.Net类库。 However, I've had a lot of issues doing this successfully. 但是,我成功地做了很多这样的问题。

My project directory looks something like this: 我的项目目录看起来像这样:

WebProject
  NetLibrary1
  NetLibrary2
  NetLibrary3
  src
    Web Project Code
  wrap
    DevExpress.Data.v14.1
      project.json
    .
    .
    NetLibrary1
      project.json

The wrap folder contains a folder for each DLL that is referenced in the web project, and inside each one of those folders is a project.json file that I guess "wraps" the DLL into a faked Nuget package for the vNext project to consume. wrap文件夹包含web项目中引用的每个DLL的文件夹,并且每个文件夹中都有一个project.json文件,我猜这个文件“包装”到一个伪造的Nuget包中供vNext项目使用。

My problem is that I seem unable to successfully wrap 2 of my NetLibrary projects so that my vNext project can reference them. 我的问题是我似乎无法成功包装我的两个NetLibrary项目,以便我的vNext项目可以引用它们。 I attempt to add the references by right-clicking and it puts the Project names in my Web's project.json file in the following manner: 我尝试通过右键单击添加引用,并按以下方式将项目名称放在Web的project.json文件中:

"frameworks": {
"dnx451": {
  "dependencies": {
    "NetLibrary1": "1.0.0-*",
    "NetLibrary2": "1.0.0-*"
  }
 }
}

But then when it tries to restore the packages it says: "Unable to locate NetLibrary1 >= 1.0.0-*". 但是当它试图恢复包时,它说:“无法找到NetLibrary1> = 1.0.0- *”。

I'm incredibly frustrated having to deal with bleeding-edge technology like this and I'm looking for a clear method to fix my reference woes. 我非常沮丧地不得不处理像这样的尖端技术,我正在寻找一种明确的方法来解决我的参考问题。

Thanks for any responses! 谢谢你的回复!

You want to add old class library Foo.csproj to Bar.xproj as reference. 您希望将旧类库Foo.csproj添加到Bar.xproj作为参考。 It can be done without uploading packages in Beta8 but it is not simple as it should be. 它可以在不上传Beta8的软件包的情况下完成,但它并不简单。

  1. Go too Foo.csproj folder, type: dnv wrap Foo.csproj . 去太Foo.csproj文件夹,输入: dnv wrap Foo.csproj
  2. You should now have some files generated, for me it was Foo/wrap/Foo/project.json . 你现在应该生成一些文件,对我来说它是Foo/wrap/Foo/project.json Go to your solution in Visual Studio, Add -> Existing project -> project.json . 转到Visual Studio中的解决方案, Add -> Existing project -> project.json
  3. Now you have some more files, including Foo.xproj which is available in Visual Studio solution, but it does not build. 现在你有了更多的文件,包括Visual Studio解决方案中提供的Foo.xproj ,但它没有构建。
  4. Open cmd in Foo dir and execute dnv restore . 在Foo目录中打开cmd并执行dnv restore
  5. After 4) completes with no error and Foo.xproj can be built you can now go to Bar.xproj and add Foo.xproj as reference. 4)完成后没有错误,可以构建Foo.xproj,现在可以转到Bar.xproj并添加Foo.xproj作为参考。
  6. Open cmd in Bar directory and execute dnv restore . 在Bar目录中打开cmd并执行dnv restore
  7. You can now build Bar.xproj 您现在可以构建Bar.xproj

I really hope that this will be easier in final version. 我真的希望在最终版本中这会更容易。

I found the answer to my question in JimmyD's response in this link 我在JimmyD的回答中找到了我的问题的答案

Issue Adding Reference to Class library project 问题添加对类库项目的引用

The actual marked response in that question wasn't working but fortunately browsing to the project DLL in the actual file structure did. 该问题中实际标记的响应不起作用,但幸运的是在实际文件结构中浏览到项目DLL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM