A simple Visual Studio extension that runs a command (i.e. a command line application), whenever a file is saved in Visual Studio. Available for free on the Visual Studio Marketplace.
The command to be run is specified in a .onsaveconfig
file, which has the same syntax and behavior as .editorconfig files.
Here's an example .onsaveconfig
file that calls dotnet-csharpier on C# files:
# run dotnet csharpier on C# files, whenever they're saved.
[*.cs]
command = dotnet
arguments = csharpier {file}
The following options are supported:
.cmd
and .bat
files, make sure the file extension is included in the command. The following placeholder can be used in the command:
{solution_directory}
- The directory of the solution file (e.g. C:\MySolution){file}
- The file that was saved, fully qualified (e.g. C:\MySolution\MyProject\Program.cs){file_in_solution}
- The file that was saved, relative to the solution_directory (e.g. MyProject\Program.cs){filename}
- The file name of the file that was saved (e.g. Program.cs){directory}
- The directory containing the file that was saved (e.g. C:\MySolution\MyProject){solution_directory}
- The directory of the solution file (e.g. C:\MySolution)true
to disable this behavior, so the command will always run. This may be required if you have additional extensions that also modify the file on save.Similar to .editorconfig
, specific files can be ignored by setting the command to unset
or ignore
:
[*.cs]
command = dotnet
arguments = csharpier {file}
[BigFile.cs]
command = ignore
Logo by icons8.