mcs:找不到元数据文件



我正试图使用在ubuntu命令行上运行一个csharp程序

mcs hello.cs

它可以工作,但我想使用nugeti下载的nugetCLI和以下内容:

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  /reference:Mailjet.Client.dll /reference:Newtonsoft.Json.dll hello.cs

对于这种格式,我们需要确保Mailjet.Client.dllNewtonsoft.Json.dll位于存在hello.cs的同一文件夹中。

(将netstandard1.x文件夹中的两个程序集复制到存在hello.cs文件的文件夹中(

此外:您还可以指定具有完整路径的引用,如:

mcs  /reference:path/Mailjet.Client.dll /reference:path/Newtonsoft.Json.dll hello.cs

最新更新