Simple way to write a custom build rules for HLSL at Visual Studio

This article explains how to add a custom build rule for HLSL at Visual Studio in a simple way.


At first, you should add fxc.exe directory path to the PATH environment variable.

C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Utilities\bin\x86

Next, write the following line at "Property->Custom Build Tool -> CommandLine" for your HLSL file.

fxc "%(FullPath)" /Fo "%(Filename).fxo" /nologo /TMyProfile  /EMyEntryPoint

And write the following line at "Property -> Custom Build Tool -> Output filename" for your HLSL file.

%(Filename).fxo


Here are some examples to build HLSL shaders in Visual Studio at build time.

fxc "%(FullPath)" /Fo "%(Filename).fxo" /nologo /Tvs_4_0 /EMyVSEntryPoint

fxc "%(FullPath)" /Fo "%(Filename).fxo" /nologo /Tgs_4_0 /EMyGSEntryPoint

fxc "%(FullPath)" /Fo "%(Filename).fxo" /nologo /Tps_4_0 /EMyPSEntryPoint

fxc "%(FullPath)" /Fo "%(Filename).fxo" /nologo /Tcs_5_0 /EMyCSEntryPoint