I think I might finally have found a solution here. I got the idea when browsing how XAML files are mentioned in the project file for c# projects.
Let us assume a file A.tt
and B.tt
that use data from C.xml
and we would like to regenerate the code whenever C.xml
changes.
Edit the project file. Your definitions for A.tt
and B.tt
should look something like this:
<ItemGroup>
<None Include="A.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>A.cs</LastGenOutput>
<DependentUpon>C.xml</DependentUpon>
</None>
<None Include="B.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>B.cs</LastGenOutput>
<DependentUpon>C.xml</DependentUpon>
</None>
</ItemGroup>
Further, you will need (of course...)
<ItemGroup>
<None Include="C.xml" />
</ItemGroup>
And also the instruction to autogenerate A.cs
and B.cs
:
<Compile Include="A.cs">
<DependentUpon>A.tt</DependentUpon>
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
</Compile>
<Compile Include="B.cs">
<DependentUpon>B.tt</DependentUpon>
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
</Compile>
I believe most of this will already be done for you when you create the template file, so all you really have to add is the <DependentUpon>C.xml</DependentUpon>
parts to the ItemGroup
s for A.tt
and B.tt
.