mcs:找不到元数据文件

我正在尝试使用

在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

yyj19860815 回答:mcs:找不到元数据文件

我认为您应该使用以下格式的命令:

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

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

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

此外:您还可以使用完整路径指定引用,例如:

mcs  /reference:path/Mailjet.Client.dll /reference:path/Newtonsoft.Json.dll hello.cs
本文链接:https://www.f2er.com/3117605.html

大家都在问