Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert integration of T4 code generation into project file #940

Merged
merged 2 commits into from
Jan 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions MoreLinq/MoreLinq.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@

<ItemGroup>
<None Include="..\COPYING.txt" Pack="true" PackagePath="$(PackageLicenseFile)" />
<None Include="*.g.tt" />
<None Update="Aggregate.g.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>Aggregate.g.cs</LastGenOutput>
Expand Down Expand Up @@ -248,33 +247,4 @@
</Compile>
</ItemGroup>

<Target Name="_CollectTextTemplates">
<ItemGroup>
<TextTemplate Include="%(None.Identity)" Condition="'%(None.Generator)' == 'TextTemplatingFileGenerator'">
<LastGenOutput>%(None.LastGenOutput)</LastGenOutput>
</TextTemplate>
</ItemGroup>
</Target>

<Target Name="_TransformTextTemplate" Inputs="$(TextTemplate)" Outputs="$(TextTemplateOutput)">
<Exec Command="dotnet t4 -h &gt; /dev/null" IgnoreExitCode="True" Condition="'$(WINDIR)' == ''">
<Output TaskParameter="ExitCode" PropertyName="_TestExitCode" />
</Exec>
<Exec Command="dotnet t4 -h &gt; NUL" IgnoreExitCode="True" Condition="'$(WINDIR)' != ''">
<Output TaskParameter="ExitCode" PropertyName="_TestExitCode" />
</Exec>
<Exec Command="dotnet tool restore" Condition="$(_TestExitCode) != 0" />
<Exec Command="dotnet t4 $(TextTemplate)" />
</Target>

<Target Name="TransformTextTemplates"
DependsOnTargets="_CollectTextTemplates">
<MSBuild Projects="$(MSBuildProjectFile)"
Targets="_TransformTextTemplate"
Properties="TextTemplate=%(TextTemplate.Identity);TextTemplateOutput=%(TextTemplate.LastGenOutput)" />
</Target>

<Target Name="_TransformTextTemplates"
AfterTargets="BeforeBuild" DependsOnTargets="TransformTextTemplates" />

</Project>
8 changes: 8 additions & 0 deletions MoreLinq/tt.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@echo off
pushd "%~dp0"
for /f "tokens=*" %%f in ('dir /s /b *.tt') do (
echo>&2 dotnet t4 "%%f"
dotnet t4 "%%f" || goto :end
)
:end
popd
4 changes: 4 additions & 0 deletions MoreLinq/tt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -e
cd "$(dirname "$0")"
find . -name "*.tt" -print0 | xargs -0 -t -L 1 sh -c '(dotnet t4 "$0" || exit 255)'
1 change: 1 addition & 0 deletions build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ if "%1"=="docs" shift & goto :docs
dotnet restore && dotnet tool restore ^
&& call :codegen MoreLinq\Extensions.g.cs -x "[/\\]ToDataTable\.cs$" -u System.Linq -u System.Collections MoreLinq ^
&& call :codegen MoreLinq\Extensions.ToDataTable.g.cs -i "[/\\]ToDataTable\.cs$" -u System.Data -u System.Linq.Expressions MoreLinq ^
&& call MoreLinq\tt ^
&& for %%i in (debug release) do dotnet build -c %%i --no-restore %* || exit /b 1
goto :EOF

Expand Down
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ codegen() {
}
codegen MoreLinq/Extensions.g.cs -x "[/\\\\]ToDataTable\.cs$" -u System.Linq -u System.Collections MoreLinq
codegen MoreLinq/Extensions.ToDataTable.g.cs -i "[/\\\\]ToDataTable\.cs$" -u System.Data -u System.Linq.Expressions MoreLinq
MoreLinq/tt.sh
if [[ -z "$1" ]]; then
configs="Debug Release"
else
Expand Down