How to Build OfficeCLI from Source Using the .NET 10 SDK
Build OfficeCLI by cloning the repository and running dotnet publish with the Release configuration and your target runtime identifier to produce a single-file, self-contained executable.
OfficeCLI is a cross-platform command-line tool for automating Microsoft Office documents. Because the project targets .NET 10 (net10.0) and publishes as a trimmed, single-file binary, you can compile it from source on any platform that supports the .NET 10 SDK. This guide walks through the exact build steps derived from the project's configuration in officecli.csproj.
Prerequisites
Before building, ensure you have the .NET 10 SDK installed. The SDK includes the dotnet CLI tool used for compilation and publishing.
- Windows: Download the installer from the .NET website or use
winget install Microsoft.DotNet.SDK.10 - macOS: Use Homebrew (
brew install dotnet) or download the PKG installer - Linux: Follow the distribution-specific instructions from Microsoft (e.g.,
apt install dotnet-sdk-10.0on Ubuntu)
Verify your installation:
dotnet --version
Understanding the Build Configuration
The build behavior is controlled by properties defined in src/officecli/officecli.csproj. Key settings include:
<TargetFramework>net10.0</TargetFramework>– Compiles against .NET 10 APIs<PublishSingleFile>true</PublishSingleFile>– Bundles the application into one executable<SelfContained>true</SelfContained>– Includes the .NET runtime in the output<PublishTrimmed>true</PublishTrimmed>– Removes unused assemblies to reduce file size<CETCompat>false</CETCompat>– Disables Control-flow Enforcement Technology for single-file compatibility
The project references two critical NuGet packages declared in the same file:
DocumentFormat.OpenXmlfor OOXML manipulationSystem.CommandLinefor parsing CLI arguments (used in [Program.cs](https://github.com/iOfficeAI/OfficeCLI/blob/main/src/officecli/Program.cs))
Step-by-Step Build Instructions
1. Clone the Repository
Download the source code to your local machine:
git clone https://github.com/iOfficeAI/OfficeCLI.git
cd OfficeCLI
2. Restore NuGet Packages
While dotnet publish handles restoration automatically, you can explicitly restore dependencies first:
dotnet restore src/officecli/officecli.csproj
3. Publish the Binary
Run the publish command with your target runtime identifier (RID). Common RIDs include win-x64, linux-x64, or osx-arm64.
dotnet publish src/officecli/officecli.csproj \
-c Release \
-r win-x64 \
--self-contained true \
-p:PublishSingleFile=true \
-p:PublishTrimmed=true \
-o ./publish
Parameters explained:
-c Release– Optimizes the build for production-r win-x64– Specifies the target platform (adjust for your OS)--self-contained true– Bundles the .NET runtime-p:PublishSingleFile=true– Creates a single executable file-p:PublishTrimmed=true– Strips unused code-o ./publish– Places output in thepublishdirectory
After completion, find your executable at:
- Windows:
./publish/officecli.exe - Linux/macOS:
./publish/officecli
4. Verify the Build
Test the compiled binary by checking the help output:
./publish/officecli --help
You should see the command list defined in the CommandBuilder classes (see [CommandBuilder.Help.cs](https://github.com/iOfficeAI/OfficeCLI/blob/main/src/officecli/CommandBuilder.Help.cs)).
Optional System-Wide Installation
To install OfficeCLI globally, copy the built binary to a directory in your system PATH. The repository includes [install.sh](https://github.com/iOfficeAI/OfficeCLI/blob/main/install.sh) as a reference implementation:
sudo cp ./publish/officecli /usr/local/bin/
On Windows, add the publish directory to your system environment variables or move officecli.exe to a location already in your PATH.
Key Source Files Reference
Understanding these files helps when modifying or debugging the build:
| File | Purpose | Link |
|---|---|---|
src/officecli/officecli.csproj |
MSBuild project file with target framework and publish settings | View source |
src/officecli/Program.cs |
Application entry point and command routing | View source |
src/officecli/CommandBuilder.cs |
Defines CLI verbs and argument parsing | View source |
src/officecli/BlankDocCreator.cs |
Handles the create command implementation |
View source |
src/officecli/Core/SkillInstaller.cs |
Manages embedded skill installation | View source |
src/officecli/Core/Watch/WatchServer.cs |
Implements the resident file-watching server | View source |
install.sh |
Bash script for system-wide binary installation | View source |
Summary
- OfficeCLI targets .NET 10 (
net10.0) and requires the corresponding SDK - The project is pre-configured for single-file, self-contained, trimmed publishing via
officecli.csproj - Use
dotnet publish -c Release -r <RID> --self-contained trueto build platform-specific executables - The output is a standalone binary that requires no external .NET runtime installation
- Reference [
install.sh](https://github.com/iOfficeAI/OfficeCLI/blob/main/install.sh) for deployment automation
Frequently Asked Questions
What version of the .NET SDK do I need to build OfficeCLI?
You need the .NET 10 SDK or later. The project file explicitly specifies <TargetFramework>net10.0</TargetFramework>, which requires a SDK that supports .NET 10. You can check your installed version by running dotnet --version in your terminal.
Can I build OfficeCLI as a framework-dependent deployment instead of self-contained?
Yes. While the default configuration sets <SelfContained>true</SelfContained>, you can override this by passing --self-contained false to the dotnet publish command. This produces a smaller binary that requires the .NET 10 runtime to be pre-installed on the target machine.
Why does the build produce a single file?
The officecli.csproj file sets <PublishSingleFile>true</PublishSingleFile> to simplify distribution. This bundles all dependencies, including the DocumentFormat.OpenXml and System.CommandLine libraries, into one executable without external DLLs.
Where is the application entry point located?
The entry point is in [src/officecli/Program.cs](https://github.com/iOfficeAI/OfficeCLI/blob/main/src/officecli/Program.cs). This file configures global settings like UTF-8 encoding and culture, initializes the RootCommand via CommandBuilder, and dispatches execution to the appropriate handlers such as BlankDocCreator or SkillInstaller.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →