clariuslabs / TransformOnBuild

Transform Text Templates On Build
Apache License 2.0
48 stars 17 forks source link

Error InvalidCastException on build #55

Closed paulohyy closed 5 years ago

paulohyy commented 5 years ago

I'm getting the following error when building the project: System.InvalidCastException: Cannot convert 'Microsoft.VisualStudio.TextTemplating.CommandLine.CommandLineHost' into 'System.IServiceProvider'

When running .tt inside Visual Studio, it works, but when building the project it throws that error.

<#
var serviceProvider = (IServiceProvider)this.Host;
#>

Any insights on how to resolve this?

mnaoumov commented 5 years ago

Basically, you wouldn't be able to resolve it because TransformOnBuild uses command line host which is not the one VisualStudio uses and console host doesn't work as a service provider