Skip to content

Instantly share code, notes, and snippets.

@Mr-Byte
Last active August 29, 2015 14:15
Show Gist options
  • Save Mr-Byte/21da1020ddee3f0e0dee to your computer and use it in GitHub Desktop.
Save Mr-Byte/21da1020ddee3f0e0dee to your computer and use it in GitHub Desktop.
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Detect whether or not to include debug symbols in the shader build. -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<ShaderDebugSymbols>false</ShaderDebugSymbols>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<ShaderDebugSymbols>true</ShaderDebugSymbols>
</PropertyGroup>
<!-- Select the FXC compiler in order of precedence -->
<Choose>
<When Condition=" '$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots@KitsRoot81)' != '' ">
<PropertyGroup>
<CompilerPath>$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots@KitsRoot81)bin\x86\fxc.exe</CompilerPath>
</PropertyGroup>
</When>
<When Condition=" '$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots@KitsRoot)' != '' ">
<PropertyGroup>
<CompilerPath>$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots@KitsRoot)bin\x86\fxc.exe</CompilerPath>
</PropertyGroup>
</When>
</Choose>
<ItemGroup>
<CompiledShaderObject Include="@(Shader -> '$(IntermediateOutputPath)%(Filename).cso' )" />
</ItemGroup>
<Target Name="ShaderCompileInfo" BeforeTargets="ShaderCompile">
<Message Text="Using compiler '$(CompilerPath)'" />
</Target>
<!-- Compile shaders -->
<Target Name="ShaderCompile"
BeforeTargets="BeforeBuild"
Inputs="@(Shader)"
Outputs="@(CompiledShaderObject)">
<!--TODO: Turn off debug symbols when compiled in release. -->
<Exec Command="&quot;$(CompilerPath)&quot; /T %(Shader.Profile) /Fo &quot;$(IntermediateOutputPath)%(Filename).cso&quot; /Zi /Fd &quot;$(OutputPath)%(Filename).pdb&quot; &quot;%(FullPath)&quot;"
Condition="$([System.DateTime]::Parse('%(ModifiedTime)').Ticks) &gt; $([System.IO.File]::GetLastWriteTime('$(IntermediateOutputPath)%(Filename).cso').Ticks)"
IgnoreExitCode="true" />
</Target>
<!-- Embed resources -->
<Target Name="BeforeBuild" AfterTargets="ShaderCompile" BeforeTargets="Build">
<ItemGroup>
<EmbeddedResource Include="@(CompiledShaderObject)">
<LogicalName>$(RootNamespace).Shaders.%(Filename)</LogicalName>
</EmbeddedResource>
</ItemGroup>
<Message Text="Embedded the following files: [@(CompiledShaderObject)]" Importance="high" />
</Target>
<Target Name="Clean">
<Delete Files="@(CompiledShaderObject)"/>
</Target>
</Project>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<IntermediateOutputPath>C:\temp\</IntermediateOutputPath>
</PropertyGroup>
<Target Name="Build">
<Message Text="Running build target." />
</Target>
<ItemGroup>
<VertexShader Include="test.hlsl" />
</ItemGroup>
<!-- TODO: Set the ShaderIncludePath here -->
<PropertyGroup>
<ShaderIncludePath></ShaderIncludePath>
<VertexShaderProfile>vs_5_0</VertexShaderProfile>
<GeometryShaderProfile>gs_5_0</GeometryShaderProfile>
<PixelShaderProfile>ps_5_0</PixelShaderProfile>
</PropertyGroup>
<Import Project="shaders.targets" />
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment