Visual Studio - Post-build event for merging .cs files
Why do you need one .cs file? If you're trying to create a single class, you can use partial classes ... although that doesn't sound like a terrible idea if you have 9000 lines of code.
How do you want the merge to happen? If it's just a concatenation:
copy Foo.cs + Bar.cs Output.cs
I suspect you want something a little smarter - in which case you should write a small merge tool and then run that tool on a post-build event.
Can you give us more details on why you want to do this? There might be a better approach.
source to share
There is nothing to do about it. But building the tool should be easy enough.
Besides using directives that must be included at the top, you should just add the files.
As a duplicate using the directive, only the warning is:
- Capture leading using statements to the beginning of your output from each file.
- Add the remainder of each file to the output queue.
eg. the following compilations with one duplicate warning using
:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;
namespace ConsoleApplication1 {
class X1 {
public static void Do() {
Console.WriteLine("Hello world");
}
}
}
namespace ConsoleApplication1 {
class Program {
static void Main(string[] args) {
X1.Do();
}
}
}
source to share