Adding a CustomBuildStep
I'm trying to add a custom build steps to compile my shader files, but the custom build properties are empty.
I derive from Project.Configuration.CustomFileBuildStep and fill in the properties of the class:
public class ShaderCompileBuildStep : Project.Configuration.CustomFileBuildStep
{
ShaderCompileBuildStep(string sourceFileName)
{
// fill in KeyInput, Executable, etc.
}
I add the extension to the project's supported extensions:
SourceFilesExtensions.Add(".fx");
I then override Project.ExcludeOutputFiles():
protected override void ExcludeOutputFiles()
{
base.ExcludeOutputFiles();
GenerateShaderCustomBuildSteps();
}
In GenerateShaderCustomBuildSteps(), I add the custom build steps to the project configuration:
private void GenerateShaderCustomBuildSteps()
{
foreach (var f in ResolvedSourceFiles.Where(f => System.IO.Path.GetExtension(f).ToLower() == ".fx"))
{
foreach (Project.Configuration conf in Configurations)
{
conf.CustomFileBuildSteps.Add(new ShaderCompileBuildStep(f));
}
}
}
In Visual Studio, my .fx files have the proper "Item Type" of "Custom Build Tool", but all of the properties in "Custom Build Tool" are empty.
What am I doing wrong?
I managed to add support for hlsl files and included a link to it, hoping it can help other help people. https://github.com/sammyfreg/netImgui/blob/master/Build/netImgui.sharpmake.cs
I have tweaked mine to generate a c header file with the compiled shader, but can easily be adapted to other needs, by looking up the fxc commandline compile options.
@sammyfreg That's a really useful example, thank you so much!