Skip to content

feat(mobilecore): add in-process facade + net10.0-android target for mobile hosts - #313

Open
IoannisMaras wants to merge 3 commits into
iOfficeAI:mainfrom
IoannisMaras:feat/android-multitargeting
Open

feat(mobilecore): add in-process facade + net10.0-android target for mobile hosts#313
IoannisMaras wants to merge 3 commits into
iOfficeAI:mainfrom
IoannisMaras:feat/android-multitargeting

Conversation

@IoannisMaras

Copy link
Copy Markdown

What

  • Multi-targets officecli for net10.0 (existing CLI) and net10.0-android (new: library only, no Program.cs/CLI entry point) via <TargetFrameworks> + per-target OutputType/publish conditions.
  • Adds officecli.mobilecore, a small in-process facade (MobileDocumentSession) over the existing document engine for Android/iOS hosts that need to open, edit, and render OOXML documents in-process: no subprocess, no MCP stdio, no named pipes, no shell.

Why

Embedding officecli directly in a mobile app process (so an on-device AI agent can edit a document without shelling out or running a local server) needs officecli to build as a library for net10.0-android, and needs a narrow, mobile-safe surface instead of the full CLI/MCP/plugin/installer surface. officecli.mobilecore intentionally exposes only: open/create, render-to-HTML, outline/get/query, set/add/remove, save. No CLI parsing, no watch server, no browser automation, no raw package writes, no arbitrary output paths.

Validation

The net10.0-android target has been building and running this exact flow inside a real Android app throughout development (WebView-rendered live preview, structured mutations end to end). Reproducible without Android, same facade, net10.0 desktop target:

$ dotnet run -c Release
MobileDocumentSession.Create("mobilecore-smoke-f9abc90a6b8d43288a3024ebfd320d3a.docx")
  -> created blank .docx, session open
Execute(Add paragraph) -> success=True message=/body/p[@paraId=00100000]
Outline() -> {"fileName":"mobilecore-smoke-f9abc90a6b8d43288a3024ebfd320d3a.docx","paragraphs":1,"tables":0,"images":0,"equations":0,...
RenderHtml() -> 50084 chars, contains added text: True
Save() -> ok
File on disk: True, 5193 bytes
Smoke test passed.

(3-line Program.cs + a ProjectReference to officecli.mobilecore.csproj. Happy to add this as a real test project in the repo if useful.)

Adds net10.0-android as a second TargetFramework alongside the desktop
net10.0 build. On Android the project compiles as a Library (no CLI entry
point — Program.cs is excluded there) instead of a self-contained
single-file Exe, so it can be embedded directly in a host app process
instead of shelled out to as a binary.

GlobalUsings.Android.cs adds #if ANDROID type aliases for OpenXML types
that collide with Android SDK binding names on that target only.

No behavior change on net10.0; this is purely additive multi-targeting.
officecli.mobilecore wraps WordHandler/ExcelHandler/PowerPointHandler with
a small, mobile-safe surface (open/create/render/outline/get/query/set/add/
remove/save) for hosts that embed the engine directly in-process, such as
an Android or iOS app. It deliberately excludes CLI parsing, MCP stdio,
named pipes, watch servers, plugins, installers, browsers, subprocesses,
raw package writes, and arbitrary output paths — an AI tool layer talking
to this facade gets document-local operations only, never a shell.

Multi-targets net10.0;net10.0-android alongside the officecli core engine
patch in this branch.
Unconditional TargetFrameworks broke the desktop CLI's default build:
dotnet build/run/publish with no -f now require an explicit framework
once a second TargetFramework exists, and building at all without the
Android SDK installed hard-fails with XA5207. Both would have broken
this repo's own release CI (dotnet publish with no -f, 8-platform
matrix) and any contributor building locally without Android tooling.

Gate the Android target behind IncludeAndroidTarget (default off), so
building/running/publishing officecli with no extra property behaves
exactly as it did before this target existed. officecli.mobilecore
always needs the Android target, so it requests it explicitly via
ProjectReference Properties instead of requiring callers to remember
to pass anything.

Verified: dotnet publish src/officecli/officecli.csproj -c Release -r
win-x64 -o publish --nologo (this repo's exact CI command) and plain
dotnet run both succeed with no extra flags, matching pre-PR behavior.
@IoannisMaras

Copy link
Copy Markdown
Author

Pushed a fix (87cf912) after testing this against a clean checkout more carefully: the original version made net10.0-android an unconditional second TargetFramework, which would have broken this repo's own release CI. dotnet publish src/officecli/officecli.csproj -c Release -r <rid> -o publish --nologo (the exact command build.yml runs, no -f) fails once a project targets multiple frameworks without one specified, on every OS in the matrix, and plain dotnet build/dotnet run for the desktop CLI would also start requiring the Android SDK/workload to be installed even for contributors who only touch the CLI.

Fixed by gating the Android target behind an opt-in property (IncludeAndroidTarget, default off). With no extra property, dotnet build/run/publish behave exactly as they did before this target existed - verified by running this repo's exact CI publish command and a plain dotnet run against the fix, both succeed with zero Android tooling involved. officecli.mobilecore (which always needs the Android target) requests it explicitly via ProjectReference Properties, so nothing downstream needs to remember to pass anything.

Should not affect anything else in this PR - same two commits, same scope, just a safer default on the new target.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant