Trying to build some output at runtime based on T4 templates. I have the template, it seems to be working fine, until I try to build it via msbuild. At this point, the templates are getting the top-level namespace instead of the directory-specific namespace that Visual Studio 2019 is giving them. This means that if I build the code in VS, I get one thing, and if I build the code in our CI tools, I get a totally different thing. Obviously, this isn't going to work.
I have
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v16.0\TextTemplating\Microsoft.TextTemplating.targets" />
in my csproj file, but when I run msbuild, I get output like this:
ExecuteTransformations:
Performing full T4 transformation
Performing full T4 preprocessing
Preprocessing template Templates\MyMaster.tt...
Preprocessing template Templates\Pdf\MyType.tt...
and all of the generated cs files are in the Root namespace. My expectation is that they get the same as Visual Studio, which would be Root.Templates and Root.Templates.Pdf.
The csproj for the files look like this:
<Content Include="Templates\MyMaster.tt">
<Generator>TextTemplatingFilePreprocessor</Generator>
<LastGenOutput>MyMaster.cs</LastGenOutput>
</Content>
Any way to get the pre-build to have the correct namespaces would be great. I'd rather not try to fall back to a pre-build script that re-mangles the generated cs files