Question

I have multiple C# sources files (around 50) in a directory. What I want to do is to compile all of them separately, i.e. so that each of them should generate its own executable file. (Some of the files are one or 2 directories deep.)

Currently what i am doing is

csc *.cs /recurse:*.cs

The problem here is that CSC tries to compile all of the files together and finds multiple instance of the method Main. I know this is the correct behavior but this it's not what I'm looking for.

Is writing a batch script my only option or can I do some kind of single command wildcard magic to compile all of the files separately?

Was it helpful?

Solution

Using a simple bat for loop like

for /R %f in (*.cs) do csc %f 

should do

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top