Skip to content

Commit 44ca7ee

Browse files
authored
Run the template commands (dotnet tool t4) only once (#184)
* Run the template commands (dotnet tool t4) only once. Otherwise, the commands would be run for each target framework, which sometimes could cause file lock errors (and degrades performance). This is based on this StackOverflow answer: https://stackoverflow.com/questions/50071932/how-do-i-call-my-script-before-all-the-builds-for-only-once-in-a-multi-targeting/50080946#50080946 * Follow-Up: Add comment.
1 parent cc1179f commit 44ca7ee

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Wasmtime.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ The .NET embedding of Wasmtime enables .NET code to instantiate WebAssembly modu
6868
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
6969
</ItemGroup>
7070

71-
<Target Name="RestoreTools" BeforeTargets="BeforeBuild">
71+
<Target Name="RunCodeTemplates" BeforeTargets="DispatchToInnerBuilds">
72+
<!-- Generate the code files from the T4 text templates.
73+
We use the "DispatchToInnerBuilds" target so that they are only run once when
74+
building the project, instead of for each target framework. -->
7275
<Exec Command="dotnet tool restore" />
73-
</Target>
74-
75-
<Target Name="RunCodeTemplates" BeforeTargets="BeforeBuild">
7676
<Exec Command="dotnet tool run t4 Linker.DefineFunction.tt" />
7777
<Exec Command="dotnet tool run t4 Function.FromCallback.tt" />
7878
</Target>

0 commit comments

Comments
 (0)