Search code examples
c#shaderhlslsharpdx

How to compile hlsl shader file in Visual Studio C# project


I would like to compile a hlsl shader file in my C# project in Visual Studio 2015. With a C++ project I immediately get the correct properties if I add an hlsl file like the picture below:

HLSL build properties in C++

However when I want to do this in my C# project (with SharpDX) I do not get such options and thus can't compile to an CSO file for my project.

Does anyone know a solution for this?


Solution

  • There's now a NuGet package, Microsoft.HLSL.CSharpVB, that adds support for HLSL shader properties to C# and VB projects:

    This package installs MSBuild support for HLSL compilation in C# and VB projects.

    Please reload your project or restart Visual Studio for the new shader Build Actions to appear in the properties window.