当前位置: 动力学知识库 > 问答 > 编程问答 >

visual studio - Microsoft C# command line compiler not finding .dll in external directory

问题描述:

I would like to compile a C# program from the command line in a Linux terminal. My csc.exe is added to my Path and works correctly. The directory layout is as follows:

|-- Program.cs

|-- Otherfiles.cs

|-- bin

| |-- Debug

| | |-- Newtonsoft.Json.dll

From the top directory, I use the following command to compile:

csc *.cs /r:./bin/Debug/Newtonsoft.Json.dll

--> error CS2001: Source file 'r:bin/Debug/Newtonsoft.Json.dll' could not be found

Is there a better way to do what I'm trying to do here, or will I just have to copy the .dll files I want into the same directory as Program.cs, as is done in this question?

网友答案:

The /reference argument is only used to indicate the name of the assembly.

To specify additional directories to search for assembly files use the /lib argument:

csc *.cs /r:Newtonsoft.Json.dll /lib:"./dir with spaces/need quotes", ./bin/Debug

Use /lib to specify the directory in which one or more of your assembly references is located. The /lib topic also discusses the directories in which the compiler searches for assemblies.

分享给朋友:
您可能感兴趣的文章:
随机阅读: