I have a Visual Studio Project that is using a MSBuild task to generate some code files. (The basis are xml files, and the generated code is quite lengthy, but noting special, just a lot of boilerplate.)

I’m not sure how I should handle the generated files:

  • Not include generated files in the project, and use MSBuild to make sure they get compiled (by adding respective <Compile...> tags to the <Target>).

  • Include generated files in the project, but exclude them from source control.

Any other options? Are there issues with these options? Experiences so far? Recommendations or best practices?


1 Answer 1


Personally I include only the source files WRT source control. Its a rare case when generated files should be added to source control - maybe if they were generated once and never changed, and the generation step is lengthy or complex, otherwise I can't think of a good reason.

For compilation - if they need to be added to the project then I tend to add them - I prefer not to have hidden compilation files as part of the project as I prefer to know what its really building without any surprises. I do tend to put generated files in a filtered folder though so they are tucked away from daily view though.

  • I think that “not to have hidden compilation files as part of the project” is a good argument.
    – Martin
    Commented Nov 17, 2014 at 13:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.