Skip to content

test: Save Xbox game config atomically in build hook - #2937

Merged
jpnurmi merged 2 commits into
mainfrom
jpnurmi/fix/xbox-game-config-race
Nov 11, 2026
Merged

jpnurmi merged 2 commits into
mainfrom
jpnurmi/fix/xbox-game-config-race

Conversation

@jpnurmi

@jpnurmi jpnurmi commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

The Xbox build preprocessor in the integration test project now saves ScarlettGame.config to the project's Temp folder and swaps it into ProjectSettings with File.Replace, instead of saving it in place.

Unity watches the game config and re-reads it on change. Saving in place with XmlDocument.Save keeps the file locked while writing, so a re-read that lands mid-write fails with a sharing violation. Unity logs that as an error, and BuildOptions.StrictMode fails the build. This made the Xbox integration build flaky (failed run).

The watcher should still see the replaced file and reload it. On the first Xbox build, it is worth confirming that the built MicrosoftGame.config still contains PersistentLocalStorage.

#skip-changelog

The Xbox build preprocessor saved `ScarlettGame.config` in place with
`XmlDocument.Save`, which holds the file open exclusively while
writing. Unity watches the game config and re-reads it on change, so a
read that lands mid-write fails with a sharing violation. Unity logs
that as an error, and `BuildOptions.StrictMode` turns it into a failed
build:

```text
Failed to read Game Config file, System.IO.IOException: Sharing violation on path <...>
```

Save to the project's `Temp` folder instead and swap the complete file
in with `File.Replace`, so the watcher never sees a partially written
file.

Failed run: https://github.com/getsentry/sentry-xbox/actions/runs/42793976990/job/129758551877
@jpnurmi
jpnurmi marked this pull request as ready for review November 10, 2026 14:18
@jpnurmi
jpnurmi merged commit 25eb185 into main Nov 11, 2026
72 checks passed
@jpnurmi
jpnurmi deleted the jpnurmi/fix/xbox-game-config-race branch November 11, 2026 12:26
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.

2 participants