I’m using T4 templating to generate some .config files in a project I’m working on.
I’ve set up a pre-build task to look for all .tt files in the solution directory, and then execute the TextTransform command-line tool, so that the code is freshly generated on each build.
However, I’m now having “Access Denied” errors because (for example) when it tries to execute TextTransform on the Web.UAT.tt file, the Web.UAT.Config file is under source-control in TFS, and thus write protected.
Ordinarily I would select the .Config file in Visual Studio, and do the File->Source Control->Exclude From Source Control thing. Unfortunately, this does not appear as an option for any file which shows up as “nested” beneath another file!
i.e. I can exclude web.tt, but not web.config… I can exclude default.aspx but not default.aspx.cs.
Does anyone have any ideas about how I can exclude the lower level nested files from Source Control, but keep the top level ones?
Thanks!
I’m assuming you’re using TFS here.
You’re not going to be able to do this perfectly – since Visual Studio will automatically add any new item added to a project to source control. Your best solution is to look at using MSBuild and issuing a checkout for the output file before running the template (but then you’ll likely have to check-in again afterwards). Having a quick look there is http://msbuildextensionpack.codeplex.com/ which I’ve seen mentioned for the purposes of doing this.
Failing that, there is another way.
The problem with this will be somebody else loading the project for the first time, their Visual Studio will automatically create the output file if they run the .TT – in that case, they would either need to repeat this process (from step 2) or would need to manually create a stub .config file of the correct name (I would suggest before even loading the project) so that the project sees it and doesn’t attempt to re-source-control it.