Files
WpfExtended/WpfExtended/ShaderCompiler.target
T
2025-08-01 16:31:06 +02:00

32 lines
1.6 KiB
SYSTEMD

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ShaderDir>$(ProjectDir)</ShaderDir>
<!-- Use MSBuildProjectDirectory to get a more reliable path to the solution root -->
<SolutionRootDir Condition="'$(SolutionDir)' == '' OR '$(SolutionDir)' == '*Undefined*'">$(MSBuildProjectDirectory)\..</SolutionRootDir>
<SolutionRootDir Condition="'$(SolutionDir)' != '' AND '$(SolutionDir)' != '*Undefined*'">$(SolutionDir)</SolutionRootDir>
<Fxc>$(SolutionRootDir)\tools\fxc.exe</Fxc>
<FxcArgs>/O3 /T ps_3_0 /nologo /Fo</FxcArgs>
</PropertyGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<!-- Check if fxc.exe exists before attempting compilation -->
<PropertyGroup>
<FxcExists Condition="Exists('$(Fxc)')">true</FxcExists>
</PropertyGroup>
<Message Importance="High" Text="Looking for fxc.exe at: $(Fxc)" />
<Message Condition="'$(FxcExists)' == 'true'" Importance="High" Text="Compiling shader effect files..." />
<Message Condition="'$(FxcExists)' != 'true'" Importance="High" Text="fxc.exe not found at $(Fxc), using pre-compiled shaders..." />
<ItemGroup Condition="'$(FxcExists)' == 'true'">
<_ShaderFiles Include="$(ShaderDir)**\*.fx" />
</ItemGroup>
<Exec Condition="'$(FxcExists)' == 'true'" Command="&quot;$(Fxc)&quot; $(FxcArgs) &quot;$([System.IO.Path]::ChangeExtension('%(_ShaderFiles.Identity)', '.ps'))&quot; &quot;%(_ShaderFiles.Identity)&quot;" />
<ItemGroup>
<Resource Include="$(ShaderDir)**\*.ps" />
</ItemGroup>
</Target>
</Project>