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
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.
1