Skip to content

Script Integration

Dave Grochocki edited this page Apr 11, 2020 · 21 revisions

The power of XAML Styler is also wrapped in a small executable that can be integrated into build scripts, git commit templates, and more. Xstyler.exe is built on top of the same styling engine that powers the Visual Studio plugin, and can be configured by specifying an external configuration.

NuGet version

Getting Started

Install as a global tool

  1. Install the XamlStyler.Console as dotnet global tool:
dotnet tool install --global XamlStyler.Console
  1. Use the command xstyler directly in any shell.

Install as a local tool

  1. Install XamlStyler.Cosole as dotnet local tool:
dotnet new tool-manifest
dotnet tool install XamlStyler.Console
  1. In any shell, use the following commands:
dotnet tool restore
dotnet xstyler

Basic Usage

./xstyler.exe -f "MainPage.xaml" -c "Config.json"
./xstyler.exe -r -d "C:\Solution\" -c "Config.json"

Help

XAML Styler #.#.#.#
Copyright (c) Xavalon 2016

  -f, --file         XAML file to process (supports comma-separated list).

  -d, --directory    Directory to process XAML files in.

  -c, --config       JSON file containing XAML Styler settings configuration.

  -i, --ignore       (Default: False) Ignore XAML file type check and process
                     all files.

  -r, --recursive    (Default: False) Recursively process specified directory.

  -p, --passive      (Default: False) Check files follow proper formatting without
					 making any modifications.

  -l, --loglevel     (Default: Default) Levels in order of increasing detail:
                     None, Minimal, Default, Verbose, Debug

  --help             Display this help screen.

Note: xstyler.exe cannot detect Visual Studio indentation options (see Indent Size and Indent with Tabs for more information).

Examples

  • Batch File - Batch process XAML files in your projects.
  • Git Bash - Running xstyler.exe from Git Bash.
  • Git Hook - Integrate with your commit process to ensure XAML files are formatted before getting checked in.

Have a useful recipe? Let us know, and we will add it to the Wiki for others to use in their projects.