A preprocessor for WPF XAML files that enables conditional compilation using XML comments, providing functionality similar to C#'s #if...#endif
preprocessor directives.
- Use conditional compilation in XAML files
- Compatible with existing DefineConstants from C# projects
- Integrates with MSBuild process
- Supports both true/false conditions
- Preserves source files (processes intermediate copies)
- Full UTF-8 with BOM support for XAML compatibility
<!-- fix_issue_001:true -->
<Button Content="New Implementation"/>
<!-- end fix_issue_001:true -->
<!-- fix_issue_001:false -->
<Button Content="Old Implementation"/>
<!-- end fix_issue_001:false -->
Install via NuGet Package Manager:
Install-Package XamlPreprocessor
Define your constants through:
- MSBuild command line:
msbuild.exe /p:DefineConstants="fix_issue_001;feature_002"
- Or project file (
.csproj
):
<PropertyGroup>
<DefineConstants>$(DefineConstants);fix_issue_001;feature_002</DefineConstants>
</PropertyGroup>
- During build, creates preprocessed copies of XAML files in the intermediate directory
- Applies XSLT transformation based on defined constants
- Uses preprocessed copies for compilation while preserving source files
- Handles proper UTF-8 encoding with BOM for XAML compatibility
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License