Mark Cassar
Mark Cassar

Reputation: 1852

T4MVC increasing compile time drastically in ASP.Net MVC

I am using T4MVC to generate templated files for MVC and I have noticed that it is increasing my build time drastically. If I take a look at the Output window, it firsts builds the referenced projects quite fast (around 5 seconds) and then when it comes to building the MVC web application, it takes very long.. nothing is shown within the Output window until it finishes, which takes around 45 seconds.

I have just installed the T4MVC from Nuget, does it compile automatically on build? Does it take so long? Any ideas on what I can do to reduce compile time and use T4MVC as it is a great tool for maintainability?

Upvotes: 1

Views: 157

Answers (2)

Mark Cassar
Mark Cassar

Reputation: 1852

I have found the reason why it was taking so long to build and it was due to having the MvcBuildViews set to true within the project .csproj file. Building all the views was taking much of the compile time.

Upvotes: 1

David Ebbo
David Ebbo

Reputation: 43193

That should not be happening. T4MVC does its generation at design time. i.e. each time you save the .tt file or choose 'Run Custom Tool', it regenerate sources.

But when you build, it's essentially out of the picture, and the sources that it generated are built with the rest, and should not be adding any measurable time.

So I suspect something else might be going on here. Questions:

  • Do you also see this when building from the cmd line using msbuild?
  • Do you see this on a clean new MVC project where you just added T4MVC?

Upvotes: 0

Related Questions