user536232
user536232

Reputation: 645

custom build for VS2010

I need to compile some files in my solution with an external command line compiler, and pass it's output (cs files) to the input of the C# compiler, so it will build them into the resulting assembly. Suggest approaches to achieve this task.

Upvotes: 1

Views: 592

Answers (2)

Paul
Paul

Reputation: 6218

I've run across this same problem before. The easist thing to do is to include the output file(s) in your project and call the generator from the pre-build event command line setting. There are many problems with this technique, it wrecks havoc on integrated source control and if your generator creates files dynamically it won't work. There are ways to get around this, compare the files from the generator before overwriting them so that only changes result in overwrites, and concat the files into a single .cs with a known name file for example. None of these are fun or satifactory IMHO.

I'd recommend if at all possible you look at using using T4 for this. You don't say whether the external generator is yours or not but if it is it shouldn't be too hard to convert. It is much cleaner, clearer, and easier to maintain the T4 than an externally linked tool.

Upvotes: 1

jcopenha
jcopenha

Reputation: 3975

You can use Project -> Settings -> Build Events -> Pre-build event to generate your CS file and then just make sure your CS file is included in your project and it should build just fine.

Upvotes: 1

Related Questions