Replacing old "PixelShaderCompile" task with fxc.exe
See the question and my original answer on StackOverflowThe original PixelShaderCompile task was declared like this in a .csproj:
<Target Name="EffectCompile" Condition="'@(Effect)' != '' ">
<PixelShaderCompile Sources="@(Effect)">
<Output TaskParameter="Outputs" ItemName="Resource" />
</PixelShaderCompile>
</Target>
What this did is 1) compile the .fx files as .ps files (compiled effects) and 2) declare them as Resource
for the MSBuild system (same as Visual Studio Build Action Resource
) which is understood by WPF project types as WPF resources:
So, when you're building for WPF, you want to emulate that behavior, which you can do like this (my original answer initially only had the Exec
command):
<Target Name="EffectCompile" Condition="'@(Effect)' != '' ">
<Exec Command=""$(MSBuildProgramFiles32)\Windows Kits\10\bin\10.0.22621.0\x64\fxc.exe" /T ps_3_0 /Fo %(Effect.RelativeDir)%(Effect.FileName).ps %(Effect.Identity)"/>
<!-- Add this if you need to embed the file as WPF resources -->
<ItemGroup>
<Resource Include="%(Effect.RelativeDir)%(Effect.FileName).ps" />
</ItemGroup>
</Target>