This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
MsOfficeDiff is a repository containing .NET global tools for comparing Microsoft Office documents:
- MsWordDiff (
diffword) - Compares two Word documents using Microsoft Word's COM automation, showing tracked changes. - MsExcelDiff (
diffexcel) - Compares two Excel workbooks using Microsoft's Spreadsheet Compare (SPREADSHEETCOMPARE.EXE).
src/MsOfficeDiff.slnx
# Build the solution
dotnet build src/MsOfficeDiff.slnx
# Build release
dotnet build src --configuration Release
# Install MsWordDiff as global tool locally
dotnet pack src/MsWordDiff/MsWordDiff.csproj
dotnet tool install -g MsWordDiff --add-source ./nugets
# Install MsExcelDiff as global tool locally
dotnet pack src/MsExcelDiff/MsExcelDiff.csproj
dotnet tool install -g MsExcelDiff --add-source ./nugets-
Word.cs - Core functionality using COM interop to automate Microsoft Word:
- Opens documents read-only via
Word.ApplicationCOM object - Uses
CompareDocumentsAPI to generate comparison view - Creates Windows Job Object to terminate Word when parent process exits
- Configures Word window (minimizes ribbon, optionally shows source documents and revision pane)
- Accepts
quietparameter to control source documents visibility
- Opens documents read-only via
-
CompareCommand.cs - Main CLI command using CliFx:
- Validates document paths
- Supports
--quietoption to hide source documents - Reads settings asynchronously and merges with command-line options (CLI overrides settings)
- Invokes
Word.Launch()with merged configuration
-
SettingsCommand.cs - View settings command:
settings- Display settings file path and current settings
-
SetQuietCommand.cs - Configure Quiet mode:
set-quiet <true|false>- Set default Quiet mode value
-
Settings.cs - Settings model with
Quietproperty -
SettingsManager.cs - Async settings persistence:
- Reads/writes JSON settings from
%USERPROFILE%\.config\MsWordDiff\settings.json SetQuiet()- Update Quiet setting- Handles missing/corrupted settings gracefully
- Configurable settings path for testing
- Reads/writes JSON settings from
-
Program.cs - CLI entry point using CliFx
-
Logging.cs - Serilog configuration writing to console and rolling file logs
MsExcelDiff compares two Excel workbooks using Microsoft's Spreadsheet Compare (SPREADSHEETCOMPARE.EXE), bundled with Office Professional Plus / Microsoft 365 Apps for Enterprise.
-
SpreadsheetCompare.cs - Core functionality:
- Auto-detects
SPREADSHEETCOMPARE.EXEin common Office install paths (Office16/Office15, x86/x64) - Auto-detects
AppVLP.exe(Office Click-to-Run virtualization launcher) and uses it when present - Writes both file paths to a temp file (one per line) and passes it as argument
AppVLP.exeis a launcher that exits immediately; the code finds the realSPREADSHEETCOMPAREprocess by name- Creates Windows Job Object to terminate Spreadsheet Compare when parent exits
- Maximizes the Spreadsheet Compare window and brings it to foreground after launch
- Temp file is deleted by the exe on success; cleaned up on failure
- Auto-detects
-
CompareCommand.cs - Default CliFx command:
- Two positional
FileInfoparameters for workbook paths - Reads settings for optional custom exe path
- Invokes
SpreadsheetCompare.Launch()
- Two positional
-
Settings.cs - Settings model with
SpreadsheetComparePathproperty -
SettingsManager.cs - Async settings persistence at
%USERPROFILE%\.config\MsExcelDiff\settings.json -
SetSpreadsheetComparePathCommand.cs -
set-pathcommand to configure custom exe location -
SettingsCommand.cs -
settingscommand to display current settings
Click-to-Run Office installs require launching SPREADSHEETCOMPARE.EXE via AppVLP.exe (the App-V virtualization layer). The exe crashes (0xC0000409) if launched directly because it depends on the virtual filesystem/registry that AppVLP.exe provides. The start menu shortcut uses the same pattern:
AppVLP.exe "...\SPREADSHEETCOMPARE.EXE"
Uses TUnit framework.
# Run MsWordDiff tests
dotnet run --project src/Tests
# Run MsExcelDiff tests
dotnet run --project src/ExcelTestsMsWordDiff [Explicit] tests require Word to be installed. MsExcelDiff [Explicit] tests require Spreadsheet Compare (Office Professional Plus / Microsoft 365 Apps for Enterprise).
- MsWordDiff uses dynamic COM interop (no Word interop assemblies required)
- MsExcelDiff launches external Spreadsheet Compare exe (no COM)
- Windows-only due to COM automation and Windows Forms dependency
- Targets .NET 10.0 with
RollForward: LatestMajorfor compatibility - Warnings CA1416 (platform compatibility) suppressed intentionally