MSBuild support for T4 templates in Visual Studio 2017 RTM

I found the right solution.

Turns out that the T4 SDK is now included as part of Visual Studio 2017 (and not part of the separate Modeling SDK as it has been in the past), BUT you have to install it via the Visual Studio extension development toolset in the VS2017 installer (Text Template Transformation feature).

Once this is installed, you can use MSBuild to transform templates by importing the relevant targets into the MSBuild project:

<PropertyGroup>
    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
    <TransformOnBuild>True</TransformOnBuild>
    <TransformOutOfDateOnly>false</TransformOutOfDateOnly>
</PropertyGroup>

<!-- add AFTER import for $(MSBuildToolsPath)\Microsoft.CSharp.targets -->
<Import Project="$(VSToolsPath)\TextTemplating\Microsoft.TextTemplating.targets" />

This solved my problem and also removes the need for the separate unofficial NuGet package.