Source Control and the CompartmentMapping.tt file

Aug 21, 2008 at 11:40 PM

I recently was almost burned by the use of Source Control and the CompartmentMapping.tt file.  I assume the CompartmentMapping.tt file is not added to any of the projects because it is a .tt file and is included in the builds of the projects which does not work.  The file is required to build the custom compartment mapping file.  Because the file was not part of my project nor the JaDAL project it was never added to source control which means my source control code did not actually contain all artifacts it required.  But, I have a solution that allows one to add the file to any project and not cause any problems during build and TT time!

Basically the idea is to add the file to the project and tell Visual Studio to ignore the file and do nothing with it.  We only want it physically in the same location for the compartment mapping generation but not to actually get it from this file.

In the project of choice perform the following.  For example in the JaDAL project under CompartmentMapping\Misc

  1. Add existing item
  2. browse to file location (JaDal\CompartmentMapping\misc\)
  3. Change file filter to All fils to see the .tt file.
  4. select the compartmentMapping.tt and click add
  5. After VS adds the file it will try to compile and add the .cs file.  don't worry about it as the next steps will take care of it.
  6. select the compartmentmapping.tt file in the project to modify its properties
  7. Make sure build Action is "none"
  8. Copy to Output Directory is "Do not copy"
  9. Custom Tool delete the text in this property.

complete!!!

Running the Transform all Templates will still work and build will continue to work. VS will ignore this file from here on out.

Coordinator
Oct 15, 2008 at 4:14 PM
That's a good idea and finally i did exactly that with the project in the source control. if you fetch the current JaDAL sources it should be fine.

Thanks
  Benjamin