Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable #line directives being written to the T4 generation output file

Tags:

I have encountered a small problem with my T4 code generation.

I have broken my T4 templates up into separate files and placed them in various directories, I have done this so parts of my code generation may be re-used in multiple projects, e.g. model generation, repository generation and service generation all include a core EntityGeneration.tt file.

Unfortunately, when TextTemplating resolves my nested includes, it builds up a long #line pre-processor directive in its generated .cs file, combining all of the relative paths to the lowest level included file.

Unfortunately, as this path is built up with relative paths, it ends up needlessly long, so long in fact that it exceeds the maximum path length (Windows 7).

Here is the line at fault from the generated code in case you are interested:

#line 3 "C:\VS2010\AlbatrossTravelGroup\ASC\AlbatrossTravelGroup.ASC.BusinessRules\Services\Contracts\..\..\..\..\AlbatrossTravelGroup.BusinessRules\Services\Contracts\..\..\..\AlbatrossTravelGroup.Models\Repositories\Contracts\..\..\../AlbatrossTravelGroup.Common/CodeGeneration.tt"

My question is this, how can I disable these directives being written to the generated code file? Failing that, how can I avoid this problem without changing my file structure?

like image 721
Lukazoid Avatar asked Oct 25 '11 09:10

Lukazoid


People also ask

What is disable on my phone?

Disabling an app will remove it from the apps screen and stop it from running in the background. Disabled apps will no longer receive updates. Depending on where you bought your device, different apps may be preinstalled.


1 Answers

Visual Studio 2012 adds the linePragmas="false" template directive:

<#@ template language="C#" linePragmas="false" #>

http://msdn.microsoft.com/en-us/library/gg586945(v=vs.110).aspx

Still not sure how to do this in VS2010 which I'm stuck with at work.

like image 103
RichardTowers Avatar answered Sep 24 '22 11:09

RichardTowers