在dotnet cli中添加DLL引用

时间:2016-06-05 20:58:12

标签: c# .net command-line-interface

是否可以使用.net核心cli工具引用c#/ .net nuget包或dll? https://github.com/dotnet/cli 这些文档似乎都没有解释如何做到这一点。

2 个答案:

答案 0 :(得分:2)

只需编辑project.json文件即可添加引用。只需在那里添加所有参考和nugets。然后,您可以使用cli命令使用

将它们下载到项目中
dotnet restore

这是一个示例project.json文件。在依赖项下,您可以看到一些nugets。在框架程序集下,您可以看到DLL引用System.Data。

{
  "dependencies": {
    "EntityFramework": "6.1.3",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "Microsoft.Dnx.Runtime": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
    "PimProject.Common": "1.0.0"
  },
  "frameworks": {
    "dnx451": {
      "dependencies": {
      },
      "frameworkAssemblies": {
        "System.Data": "4.0.0.0"
      }
    }
  },
  "dotnet": {
    "dependencies": {
      "System.Data.SqlClient": "4.0.0-rc2-23530",
        "System.Data":  "4.0.0"
    }
  },
   "version": "1.0.0-*",
  "description": "Class Library",
  "authors": [ "sadams" ],
  "tags": [ "" ],
  "projectUrl": "",
  "licenseUrl": ""
}

答案 1 :(得分:1)

从版本1.0.1开始,dotnet cli允许使用add命令添加对包和项目的引用:

dotnet add package EntityFramework

要在 Proj 中添加对项目 Proj2 的引用,请移至Proj文件夹并使用

dotnet add reference "..\Proj2\Proj2.csproj"
相关问题