A custom tool can be added by calling DiffTools.AddTool
var resolvedTool = DiffTools.AddTool(
name: "MyCustomDiffTool",
autoRefresh: true,
isMdi: false,
supportsText: true,
requiresTarget: true,
launchArguments: new(
Left: (tempFile, targetFile) => $"\"{targetFile}\" \"{tempFile}\"",
Right: (tempFile, targetFile) => $"\"{tempFile}\" \"{targetFile}\""),
exePath: diffToolPath,
binaryExtensions: [".jpg"])!;
Add a tool based on existing resolved tool:
var resolvedTool = DiffTools.AddToolBasedOn(
DiffTool.VisualStudio,
name: "MyCustomDiffTool",
launchArguments: new(
Left: (temp, target) => $"\"custom args \"{target}\" \"{temp}\"",
Right: (temp, target) => $"\"custom args \"{temp}\" \"{target}\""))!;
New tools are added to the top of the order, the last tool added will resolve before any existing tools. So when the following is executed the last tool that supports the file types will launch:
await DiffRunner.LaunchAsync(tempFile, targetFile);
Alternatively the instance returned from AddTool*
can be used to explicitly launch that tool.
var resolvedTool = DiffTools.AddToolBasedOn(
DiffTool.VisualStudio,
name: "MyCustomDiffTool",
launchArguments: new(
Left: (temp, target) => $"\"custom args \"{target}\" \"{temp}\"",
Right: (temp, target) => $"\"custom args \"{temp}\" \"{target}\""));
await DiffRunner.LaunchAsync(resolvedTool!, "PathToTempFile", "PathToTargetFile");
exePath
is the path to the executable.
If the file cannot be found AddTool*
will return null.
- Environment.ExpandEnvironmentVariables is used to expand environment variables.
*
can be used as a wildcard.- In the case where multiple matches are resolved the newest will be used.
So for example %ProgramFiles(x86)%\Microsoft Visual Studio\*\*\Common7\IDE\devenv.exe
might discover the following:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\devenv.exe
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\devenv.exe
Then C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\devenv.exe
will be used.