Marie M.
Marie M.

Reputation: 170

C# project building with csc in console - getting two errors on all classes

I'm trying to compile a whole C# project with csc in the console. The goal is to create a dll file and I used csc -target:library -out:xyz *.cs.

My project directory looks like this: the classes I wrote for the project, and then there's a \lib sub-directory in my project directory with other classes I referenced in my code.

Sadly, I'm getting tons of those errors:

for pretty much every class.

It's almost like the compiler ignores everything in the subdirectory. How do I include the library classes inside \lib with csc? Do I somehow need to tell csc the structure of the subdirectory?

Already googled a lot and really don't know what to do... I'd be very glad if someone could help me out here.

Upvotes: 0

Views: 899

Answers (1)

gtsiam
gtsiam

Reputation: 87

Running csc *.cs compiles all files in the current directory. If you want to also compile everything in a subdirectory, you can either manually specify the subdirectory, or you can use the -recurse option (documentation). For example:

csc -target:library -out:xyz -recurse:*.cs

This will compile all .cs files in the current directory. You can even specify a specific directory to recursively compile, if that is what you want:

csc -target:library -out:xyz -recurse:subdirectory/*.cs

This will compile all .cs files in the 'subdirectory' directory, and all directories below it.

Upvotes: 3

Related Questions