【发布时间】:2019-11-12 12:01:38
【问题描述】:
我正在尝试使用
在 ubuntu 命令行上运行 csharp 程序mcs hello.cs
它可以工作,但我想使用我通过 nuget CLI 下载的 nuget:
using Mailjet.Client;
using Mailjet.Client.Resources;
using System;
using Newtonsoft.Json.Linq;
namespace Mailjet.ConsoleApplication {
class Program {
static void Main(string[] args) {
RunAsync().Wait();
}
..........
然后我得到错误:
hello.cs(1,15): error CS0234: The type or namespace name `Client' does not exist in the namespace `Mailjet'. Are you missing an assembly reference?
hello.cs(2,15): error CS0234: The type or namespace name `Client' does not exist in the namespace `Mailjet'. Are you missing an assembly reference?
hello.cs(4,7): error CS0246: The type or namespace name `Newtonsoft' could not be found. Are you missing an assembly reference?
所以我参考了一个 SO 答案并尝试了这个
mcs /reference:Mailjet.Api.1.2.2 /reference:Newtonsoft.Json.9.0.1 hello.cs
现在我得到一个不同的错误
error CS0006: Metadata file `Mailjet.Api.1.2.2' could not be found
error CS0006: Metadata file `Newtonsoft.Json.9.0.1' could not be found
我尝试过其他方法,例如
mcs hello.cs -r:Mailjet.Api.1.2.2 -r:Newtonsoft.Json.9.0.1
但没有区别
这是我的目录结构
.
├── Mailjet.Api.1.2.2
│ ├── Mailjet.Api.1.2.2.nupkg
│ └── lib
│ ├── net45
│ │ └── Mailjet.Client.dll
│ └── netstandard1.1
│ └── Mailjet.Client.dll
├── Newtonsoft.Json.9.0.1
│ ├── Newtonsoft.Json.9.0.1.nupkg
│ ├── lib
│ │ ├── net20
│ │ │ ├── Newtonsoft.Json.dll
│ │ │ └── Newtonsoft.Json.xml
│ │ ├── net35
│ │ │ ├── Newtonsoft.Json.dll
│ │ │ └── Newtonsoft.Json.xml
│ │ ├── net40
│ │ │ ├── Newtonsoft.Json.dll
│ │ │ └── Newtonsoft.Json.xml
│ │ ├── net45
│ │ │ ├── Newtonsoft.Json.dll
│ │ │ └── Newtonsoft.Json.xml
│ │ ├── netstandard1.0
│ │ │ ├── Newtonsoft.Json.dll
│ │ │ └── Newtonsoft.Json.xml
│ │ ├── portable-net40+sl5+wp80+win8+wpa81
│ │ │ ├── Newtonsoft.Json.dll
│ │ │ └── Newtonsoft.Json.xml
│ │ └── portable-net45+wp80+win8+wpa81
│ │ ├── Newtonsoft.Json.dll
│ │ └── Newtonsoft.Json.xml
│ └── tools
│ └── install.ps1
├── hello.cs
├── hello.exe
└── tree.txt
14 directories, 22 files
请帮助我。我不想使用 Visual Studio IDE
【问题讨论】:
-
您是否特别需要直接使用
mcs而不是.NET Core SDK?后者将使这一切变得更加简单。但如果您确实想指定引用,则应指定要引用的 DLL 的完整路径。 -
@JonSkeet 你能提供一个完整路径的例子吗
-
鉴于你所拥有的,比如
Mailjet.Api.1.2.2/lib/netstandard1.1/Mailjet.Client.dll -
@JonSkeet 这是错误的语法:使用 Mailjet.Api.1.2.2/lib/netstandard1.1/Mailjet.Client.dll 显然不起作用。我收到语法错误。我想我没明白你的意思
-
不,不适用于
using指令 - 用于您尝试指定引用的命令行。当您指定要使用的其他程序集时,您需要指定文件的路径。
标签: c# visual-studio nuget